Generating Digital Sine Waves
darthsnarkey
Posts: 9
I have been dabbling in the concept of making a tunable digital sine wave using 3 MCP42100 digital potentiometers. The basic schematic I'm using (for now) is available at:
https://www.circuitlab.com/circuit/565t62/digital-sine-wave/
I have made this public so anyone can edit it and help.
The concept is using variable resistance and voltage dividing to create a rough sine wave (more like steps than curves) then using a capacitor to act as a wave filter and smooth the shape of the wave to a low distortion sine wave. The concept has been proven sound but the hard part is the tuning of the pots in this to the correct (or closest to correct) resistance for several frequencies. the MCP42100 is a 100k ohm resistor and has 2 channels and can handle up to 10mHz each chip has a shift-register to control the wiper and has 256 even steps using 8 bit resolution.
Any Ideas and improvements would be greatly appreciated!
https://www.circuitlab.com/circuit/565t62/digital-sine-wave/
I have made this public so anyone can edit it and help.
The concept is using variable resistance and voltage dividing to create a rough sine wave (more like steps than curves) then using a capacitor to act as a wave filter and smooth the shape of the wave to a low distortion sine wave. The concept has been proven sound but the hard part is the tuning of the pots in this to the correct (or closest to correct) resistance for several frequencies. the MCP42100 is a 100k ohm resistor and has 2 channels and can handle up to 10mHz each chip has a shift-register to control the wiper and has 256 even steps using 8 bit resolution.
Any Ideas and improvements would be greatly appreciated!
Comments
if you would like some more detailed answers, I think some more input would be good. What is your aim? Why did you do it like this? How does your circuit work?
I chose this approach since it is relatively low cost and produces a fairly good sine wave. I suppose I could use flip-flops to accomplish the same thing but it seemed more controllable to do it this way. By using a shift register I can turn on and off all 6 channels with 3 pins and generate a wide variety of sine waves. The main reason I did it this way is I have never heard of Software DDS or Magic Sinewaves.
The circuit works like a voltage divider and creates "steps" up and down in voltage. While this would be close it is still too rough and by using a capacitor it smooths the difference in voltage and makes a reasonably good sine wave. The origin of this design is found at:
http://www.falstad.com/circuit/
It is under "Circuits > Analog / Digital >Digital Sinewave"
this will also demonstrate the functioning of the circuit.
I was going to build this for my dad who built from scratch a synthesizer
And there have been some audio playback demos - one that comes to mind based on personal experience is Kye's program to playback wav files from an SD card. On a hunch I took a PIR sensor, demo board, and Kye's code and made a dog detector for my mom's kitchen (I'm not living with her ;-) and my stern voice commanding the dog to leave the kitchen. IT worked, and I subsequently replaced the Prop with a Radio Shack playback module, but could have done interesting extensions with the prop.
The cool thing is that you won't need a ton of external hardware - unless you want it. e.g. a MIDI interface might be nice to add. No problem for the Prop ;-)
Edited to add - I think that Brad the author of BST had some success building a guitar tuner. He talked about the ideas but don't believe that he ever posted code.
( http://www.digikey.ca/scripts/dksearch/dksus.dll?k=multiplying+dac&vendor=0&mnonly=0&newproducts=0&ptm=0&fid=0&quantity=0&PV243=83&PV243=23&stock=1 )
By outputting values from a table you can create any waveform you want, and by having the output of one DAC as the input to a second DAC you can vary the output amplitude of the second DAC.
DAC two outputs the the waveform at the frequency you want, and DAC one controls the amplitude of DAC two to create the attack, sustain, and decay envelope.
True, but using two inexpensive 8 bit dac's provide a 16 bit (96db) audio output range, while you would need a more expensive 16 bit dac to do the same thing if you use one dac. It also saves a lot of cpu cycles that would be used for multiplying and shifting out 16 bit data.
As with most things it is a trade off that depends on the project goals.
24 bit stereo DACs are very cheap (WM8723 for instance, 0.66GBP at Farnell/Element14). Why compromise with 16 bits anyway?