Square wave to sine wave converter?
achilles03
Posts: 247
I'm looking for a relatively easy way to convert a square wave to a sine wave. It doesn't have to be super efficient, and it doesn't have to be a "perfect" sine wave. The frequency range I'm looking at is between 500 to 1000 Hertz. One method that I liked is shown here:
www.wenzel.com/graphics/pinet.gif
But my circuit analysis classes have faded from memory, so I can't model the response of that circuit to get an idea of how well it would work. Are there any other suggestions? Or any pointers how I could figure out that circuit?
Just to nip it in the bud, the speed at which I need to change frequencies is too fast to use the freqout command, and I need to basically switch pin states (i.e. a square wave).
Thanks in advance!
Dave
www.wenzel.com/graphics/pinet.gif
But my circuit analysis classes have faded from memory, so I can't model the response of that circuit to get an idea of how well it would work. Are there any other suggestions? Or any pointers how I could figure out that circuit?
Just to nip it in the bud, the speed at which I need to change frequencies is too fast to use the freqout command, and I need to basically switch pin states (i.e. a square wave).
Thanks in advance!
Dave
Comments
You can use any general circuit simulator to get a feel for testing that circuit. I can tell you though that for your application you would want to select the L and C so that it is close, but not at a resonate frequency of your input. The reason is that if you allow the circuit to resonate it will peak at that particular frequency in orders of magnitude and could saturate other parts of your circuit. By running your square wave frequency just under or just over resonate frequency you will have a response that's much easier to deal with over a frequency variance.
Another method, that you might be able to incorporate, is to have a reference LC circuit that IS at resonance and time slice it as you need to produce your sine wave. I did this with the Propeller here...
http://forums.parallax.com/showthread.php?p=739083
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Anyways, I've set-up a time incrementation program in Matlab, but I'm still working out the equations.
I'm a little rusty, so I could still use some help figuring out the circuit. What would the equivalent mechanical diagram for that be? I can see that it's a dashpot and spring in parallel with a mass, but I can't figure out where to place the left-most capacitor.
Thanks,
Dave
For quick and dirty "pop-corn" simulation stuff, I have been using this java based circuit simulator that Metron9 posted some time ago.· I have a local copy on my machine so I don't need to be online to use it.· It seems to be fairly accurate, fast, and stable.
http://www.falstad.com/circuit/
·If you play with various frequencies and component values, you will see that a sine wave will be produced, but also notice the amplitude of the sine wave will change as you sweep your frequency.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 1/6/2009 6:36:57 AM GMT
achilles03,
Here is another method that may work better for you.· It still suffers from a decaying amplitude as the frequency increases, but it isn't as bad as the pi-filter method.· This method requires two oscillators running into the inputs of an XOR gate.· The result is a PWM stream proportional to the differences in frequency.· i.e. if one input to the XOR is 4kHz and the other input is 3.5kHz then a 500Hz Sine wave will be produced on the output with a simple resistor/capacitor low-pass filter.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
I still haven't come up with the differential equation for the pi network shown above. I might try Beau's idea if I can't come up with the solution.
Anyone else want to take a shot at it? Just as a refresher, I'm wondering what the equivalent mechanical system would be for the following circuit:
www.wenzel.com/graphics/pinet.gif
Thanks in advance!
Dave