# Square wave to sine wave conversion?

#### spasticteapot

Joined Nov 14, 2009
4
Is there a good way to convert a square wave between 50hz and 5khz to a reasonably neat sine wave?

#### ericwertz

Joined Aug 26, 2009
14
Depends entirely upon what you mean by "good".

You've pretty much stumbled on the totality of what "engineering" is all about.

#### Wendy

Joined Mar 24, 2008
23,429
What is the source of the square wave?

#### russ_hensel

Joined Jan 11, 2009
825
Particurlarly hard to do if you want to vary the frequency and have the output amplitude to stay the same. I wonder if a phase lock loop could manage this.

#### davebee

Joined Oct 22, 2008
540
A microcontroller could be programmed to read the period of the incoming square wave and use pulse width modulation to generate a sine of the same frequency over that range.

If the PWM was much faster than 5 kHz then a single high-frequency low-pass filter might be good enough to clean up the entire frequency range well enough.

#### danny2

Joined Oct 28, 2009
29
If you first convert the square wave to a triangle wave, check out this link......

www.analogzone.com/den7.pdf

Here is another approach....... http://mypeoplepc.com/members/scottnoanh/sitebuildercontent/sitebuilderfiles/th_sine_shape.jpg

mind to know whr is the breakpoint voltage?when i simulate on pspice,the value for Iu is wrong,some of the formula are wrong too.please check it out.

use my circuit that i attach,and use the formula on the pdf to calculate according my circuit.
the red arrow indicate current flow

#### Attachments

• 51.3 KB Views: 468
• 14.7 KB Views: 438
• 44.4 KB Views: 330
Last edited:

#### BillB3857

Joined Feb 28, 2009
2,571
Danny,
I am not the author of the article so cannot lend any insight into how it was developed or respond to any errors it may contain. I simply located it and presented it for your evaluation.. Now to your simulation. Please note that the total conversion is made by having multiple sections, each providing a slightly different slope at different activation levels or breakpoint. From the first paragraph on the first page........

"The sine converter is a classic diode-resistor multiple -breakpoint shaper It achieves an approximately piecewise - linear sinusoid approximation and is based on optimizing the breakpoint locations to minimize function error by uniformly spreading the error across a range of the function. The five-breakpoint circuit is shown below."

Your simulation shows only one section and would only produce a slight modification to the slope of the triangle wave applied to its input. With multiple sections, as the input continues to rise, more and more modification to the slope would be evident, up to the point of the peak where the slope would approach almost flat.

#### danny2

Joined Oct 28, 2009
29
i know you are not the author.
i was referring the formula and did some calculation for the circuit.see the page 2.i was very vey confuse about this formula on page 2.i spend alot of time today by analysis it,but some formula seem error and i dont know how to fixed it.im here by asking for help about the formula on page no.2.

#### Audioguru

Joined Dec 20, 2007
11,248
I used a switched-capacitor lowpass filter IC to convert a square-wave into a very good sine-wave. The cutoff frequency of the filter is adjusted with the frequency of its clock which is 100 times the cutoff frequency.

#### BillB3857

Joined Feb 28, 2009
2,571
Maybe you could send a PM to member named "Mathematics!" (with the explanation point) He stated in another thread that he has a Master's Degree in Pure Mathematics.

#### Bernard

Joined Aug 7, 2008
5,784
Also check out Forrest M. Mims III, Engineers Notebook II, pg 81; 4 op amps, first square wave gen, 2nd, to triangle, 3rd triangle to sine, 4th amplifier. Two caps used in conversion. Fixed frequency of 1 kHz.