Convert sine wave to square wave

JamesBourne1

Sep 26, 2010
6
Joined
Sep 26, 2010
Messages
6
Hi everyone,

I am building a circuit that will produce a sine wave as output.

I am using a 555 timer (astable) to create a frequency of 140Hz.  This produces a square wave with an amplitude of about +5V.
Note that voltage is 0V and +5V (not -5V and +5V).

My problem is that I do not know how to turn the square wave into a sine wave. 
I have read on various sites that you can use capacitors and inductors to filter
the signal to produce a sine wave, but calculations and explanations are nowhere to be found.

Please help.

 

Hero999

Oct 28, 2007
2,433
Joined
Oct 28, 2007
Messages
2,433
Don't post the same thing more than once, it's considered to be spamming, I deleted your other post.


It's easy yo convert a square wave to a sine wave using a low pass filter, as long as the frequency doesn't change.

A square wave is really a mixture of frequencies, you'll have 140Hz and its harmonics: 280Hz, 420Hz, 560Hz etc. all the way up to infinity, in theory but in practise there'll bee some limit on the frequency. 140Hz will be the strongest component, with the amount of energy diminishing at the higher frequency harmonics: look up Fourier analysis if you're interested.

Al this means is that you can get a 140Hz sine wave by filtering out all the harmonics, leaving just the fundamental left.

To get a decent sine wave, the filter needs to have more than one pole i.e. RC circuit. A single pole filter with a cut-off frequency of 140Hz will give a sawtooth wave, a two pole filter will give a more sinusoidal looking wave form and a three pole filter would give a near perfect sine wave. The trouble is, you need some amplification because the signal will be reduced to a faction of its original amplitude: 1/27 if I remember rightly.

 

JamesBourne1

Sep 26, 2010
6
Joined
Sep 26, 2010
Messages
6
Hi again,

I read a about the filters as you mentioned (RC filter) in your answer and have gotten some results.  I am posting my solution thoroughly, just to make sure I'm heading in the right direction as I'm still a newbie in electronics.

On Wikipedia I found the following equation under RC circuit:
f=1/2πRC

After crunching the numbers where f must equal 140Hz and C=10uF I got R=114Ω.
I used Electronics Workbench to simulate the circuit with the calculated values (3 pole as you suggested).
(See "sine wave output.JPG")

I used the square wave input (+5V) with an offset of +5V (to create the output form of 555) and got a good sine wave but with a new problem.  As you can see the output wave is also being offset by +5V.  Is it possible to reduce the offset to 0V? If so, how?

Thank you for your help.

View attachment 41163

 

Hero999

Oct 28, 2007
2,433
Joined
Oct 28, 2007
Messages
2,433
A 0 to +5V square wave is really a +/- 2.5V square wave with 2.5V of DC offset.

In the simulation you've posted, you have a 0V to +10V square wave. Set the offset to 0V, connect the middle pin of the signal generator to 0V and the +V to the input for a similar waveform to what you'd get out of the 555.

Oh and by the way, if the power supply to the 555 is 5V, you won't get 0V to 5V out, there's loss of  about 1.3V sourcing and 20mV sinking in the output stage, assuming an output current of 1mA , so you'll get something like 20mV to 3.7V out with a 5V supply.

Yes, you're on the right track and to get rid of the DC, use an AC coupling capacitor.

 
Top