Microcontroller provides an alternative to DDS
Use a microcontroller to generate the codes for a DAC.
Daniele Danieli, Eurocom-Pro, Venice, Italy; Edited by Martin Rowe and Fran Granville -- EDN, January 7, 2010
Audio and low-frequency circuit systems often require a signal source with a pure spectrum. DDS (direct-digital-synthesis) devices often perform the signal generation by using these specialized integrated circuits. A DDS device uses a DAC but often with no more than 16-bit resolution, limiting the SNR (signal-to-noise ratio). You can perform the same task with a microcontroller programmed as a DDS and use an external high-resolution DAC. To achieve 18 to 24 bits of resolution requires a large memory table containing the cosine function for any values of phase progression.
An alternative approach lets you use a standard microcontroller with a small memory and still implement an effective synthesizer. You can design a circuit to produce a sine wave using a scalable digital oscillator built with adder and multiplier block functions in a simple structure.

Figure 1 shows a microcontroller driving an audio DAC. To develop your code to generate a sine wave, the circuit in Figure 2 comprises two integrators with an analog feedback loop equivalent to that of an ideal resonator. Parameter F defines the frequency and ranges from 0 to –0.2, and Parameter A sets the amplitude of the output signal with a single initial pulse at start-up. The following equation derives the frequency of generated signals: FOUT=
/(2×π×T), where T denotes the time for computing an entire sequence to obtain output data. The firmware for implementing this system is relatively straightforward. It requires just a few additions and one multiplication. Thus, you can use a slow microcontroller. Remember, though, that the precision of every operation must be adequate to warrant a complete signal reconstruction. Processing data with 8 or 16 bits isn’t sufficient. You must write your firmware to emulate a greater number of bits, which requires accurate code implementation.
| See all of EDN's Design Ideas |
If you properly develop your code, then you should generate the DAC output codes that produce a sine wave (Figure 3). Remember that Parameter F is nonlinear with respect to the output frequency. If you need a directly proportional rate, you can square the value of F before applying it to the input. You’ll find it useful when you need to make an easy frequency setting.

You can use just about any microcontroller to implement the oscillator, together with a high-performance DAC. You can achieve an output SNR greater than 110 dB. Many audio DACs operating in monophonic mode have 20- to 24-bit resolution at a 192-kHz sampling rate. They also offer a dynamic range of 120 dB or more.
Update (Aug 29, 2011)
You can use this Excel file for testing the algorithm. This application was implemented years ago on Texas Instruments microcontroller. While the complete code has not survived, an early assembler routine can be found here. It is very basic, but might be a useful starting place.
-
Could somebody please explain the Figure 2 to me?
Thank You in advance.
piadex2 - 2011-24-8 07:22:48 PDT -
Hello Danieli: Could I also please have a copy of your excel file that demonstrates your design idea? Like Gus, I'm having trouble making the jump from the information in your published design idea to a working algorithm that generates a steady sine wave. Any additional information at all would be great, and I'd be particularly interested to see some pseudocode that implements your basic algorithm.
Henry Frederiksen - 2010-25-2 18:32:00 PST -
Hello Danieli
Where is your excel file located ? It would be very nice if you could send me an email at x@nope9.com so that I can exchange ideas with you. Can you express your algorithm in z transform format ? Thank you
Best
Gus
Gus S. Calabrese - 2010-23-2 16:59:00 PST -
Dear Reader,
The concept of signal processing in digital domain using two integrators with an feedback loop is well know to DSP developers. If properly write the code are very simple and error-free. For reply to him today have implemented a demo in EXCEL, after few minutes of work the spreadsheet show a clear sinewave. EXCEL file are available, I hope appreciate this contribute.
Best regards
Author
Danieli Daniele
Danieli Daniele - 2010-7-2 13:18:00 PST -
I have placed my latest EXCEL spreadsheet at h t t p oh-god dot com slash dir slash EDN
I look forward to hearing from EDN.
Gus S. Calabrese - 2010-3-2 19:34:00 PST


















