Eng.Fahd
Junior Member level 3
- Joined
- Aug 17, 2011
- Messages
- 25
- Helped
- 4
- Reputation
- 8
- Reaction score
- 4
- Trophy points
- 1,283
- Activity points
- 1,467
I want to generate a sinewave with variable frequency (from Hz to 1 MHz) using microcontroller.... First I used DDS method and it worked but I couldn't reach to 1 MHz ... so this method didn't work
Here we are: **broken link removed** Specs: MC ATtiny2313, 20 MHz quartz, Fsampling=2222ksps, output frequency [0.1 Hz-1000 kHz], you need LF-filter 0-1000 kHz, an encoder tunes the frequency with 0.1 Hz, 1 Hz, 100 Hz, 1 kHz and 10 kHz steps. Peculiarity: the output signal is not interrupted during the tuning.
Thanks GeorgeM, but when I try to download the firmware then site give me this message (На сервере проводятся технические работы. Сервер будет доступен в течение 48 часов). Can you give an available link of the circuit board and firmware.
here is a link to a popular and very simple DDS with full details, which is the same as the russian one i suspect...
You can theoretically get 1MHz with this using a 20MHz crystal, but the number of points on your highest freq will be only 2.2 per cycle.
Also since the sampling freq is 2.2Mhz then the image will be at 1.2Mhz, and almost impossible to filter.
you can try to increase the sampling freq by shifting the LUT to SRAM instead of Flash. This gives an additional benefit of 1 cpu cycle per 9 cycles or a speed increase upto 2.5Mhz
with a properly designed and well implemented 5-pole or 7-pole LPF on the output you could get a fairly decent high frequency output. But it won't be great.
Also at the higher end, you have to look out for the sin(x)/x amplitude droop.
1) Also the filter can correct the amplitude sin(x)/x fall.
3) Attiny2313 has 128 byte ram only, so you cannot reduce the number of cycles less than 9 for 24-bit phase accumulator. Especially for Jesper I’d reduced it to 8 cycles per sample and sent him email.
But even with 8 cycles per sample (2.5 Msamples/s) my own DDS can still accept the tuning commands from the encoder or through the RS232 line without interruption of the output signal. That’s main feature of my DDS.
And I didn't find the file dds24plc.zip
well of course the output signal will get interrupted !! It's just that @20MHz and 50nS per cycle, the isr (for uart or kbd) can be very small in comparison and the 'error' caused by it almost un-noticeable. I cannot see a way to avoid it - as you claim.
No, it isn't allowed to make any disturbance in sample output timing (jitter). MC outputs samples exactly in every 450 ns (9MC-mashine cycle). Try the code below.
Especially for Jesper I’d reduced it to 8 cycles per sample and sent him email.
Good, if you can get 7MC, then it's very easy to get 8MC. Just add one NOP to your codecan you explain how you reduced it to 8 without the RAM ?
I know of a method to reduce it to 7 w/o extra RAM, and down to 6 with enough RAM.
and maybe even down to almost 3 with some additional trickey calculations
Good, if you can get 7MC, then it's very easy to get 8MC. Just add one NOP to your code.
Welcom.Very clever code. Thanks !! Good way to divide the extra 2 cycles of the rjmp
Welcom.
Please answer the question.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?