# Converting a square wave into a sine wave

I have been researching methods for converting a square wave into a sine wave, but I cannot seem to reach a conclusion. Is it possible to preserve the amplitude and frequency of a square wave when using a LPF with cascaded RC filters? I found the formula $$\f_c = 1/(2\pi*R*C) \$$ but this does not give me the output I need.

Below I tried using a 50 Hz input to get a 50 Hz output. Generally, my input is between the range of 50 - 60 Hz. I need to preserve amplitude because the AC signal will power some valves on a rocket that need 150 VAC w/ <= 1.5 amps.

Below are the specs for the valves.

• You could phase shift it by 360 degrees and no one will be the wiser – DKNguyen Feb 10 '20 at 5:19
• Can you please set your oscillogram background color to white? I can’t see a thing. – winny Feb 10 '20 at 5:48
• You willing to consider an active filter design? Or does it have to be passive? – jonk Feb 10 '20 at 6:51
• @jonk Yes I will consider an active filter – Hector Feb 10 '20 at 7:26
• This is starting to feel like an XY question. This feels like the wrong way to go about things. I mean...the OP wants it to pass power but has multiple 10K resistors in series with the output. Provide more information on these valves. Is this current just being used to power some solenoids? Or something more complicated and picky about the type of power it is getting? – DKNguyen Feb 10 '20 at 19:12

Is it possible to preserve the amplitude

No, you can't preserve the amplitude because the fundamental sinewave “inside” a square wave is 27.3% higher in peak magnitude (or $$\4/\pi\$$ in proper terms). In other words, the fundamental sinewave hiding inside a square wave is not the same amplitude as the square wave: -

You could adjust it after filtering it out. You can get a pretty decent looking sinewave after a 6th order filter and then just use a potential divider (or pot), and an amplifier and adjust to give you the right amplitude.

If you want to try something simple for 50 Hz filtering try this 4th order filter: -

Notice that the RC value remains constant but, as you move from left to right, R increases by ten times in order to reduce loading effects from stages to the right. Capacitance reduces by 10 times. You might get away with 3 or 4 times so, I would usrge you to experiment in your favourite simulator.

• Is this passive filter capable of providing about 150 VA of power? This is why I need to preserve amplitude. – Hector Feb 10 '20 at 19:02
• @Hector no, definitely not. These RC filters put a large series resistance between your square wave and your output sinusoid. – Ocanath Feb 10 '20 at 19:29
• @Hector I see your recent edit and have to suggest that if you are trying to get a 50 Hz power sinewave then you should use a transformer from the AC mains supply. When you get your ducks in a row maybe ask a new question because that new requirement is a different kettle of fish entirely. Please don’t revise your question any more or you’ll annoy all those who have already spent their valuable time producing answers to help you design a passive low power filter. – Andy aka Feb 10 '20 at 19:55
• You may ask why we assumed your requirement was low power and I’d answer that by asking how you might get 150 VA through the filter in your question. That circuit set the scene for your question and your recent edit is a million miles away. – Andy aka Feb 10 '20 at 19:56

Have a look at this, and note the simulation command details.

As you can see there's not a heck of a lot of the original signal left, and the output is absolutely dominated by the initial whack, even after thousands of cycles.

The low pass sections load the previous section so the response is not ideal, but that's not your main issue, even if you put an op-amp voltage follower after each stage, the results would be no better. Each stage gives you about 1-2% of the amplitude of the previous stage, so you get about 50nVp-p out, which is virtually unmeasurable.

If you intended the unloaded low pass section to have a cutoff frequency of 50Hz, the appropriate capacitor value would be 318nF, not 31.8uF, which would give you almost 100mV peak out.

• What do you suggest is the best way to preserve amplitude and frequency? – Hector Feb 10 '20 at 7:30
• You could use an active bandpass filter if your frequency will be fairly close to 50Hz. You'll need to specify the passband flatness and minimum attenuation in the stop bands. Presumably you know the range of input frequencies. You also know the components of a square wave from the Fourier series. TI has a free filter design tool that just about anyone can use. – Spehro Pefhany Feb 10 '20 at 7:34
• Note that the OP wants to use the signal to power some valves at 120V. – Elliot Alderson Feb 10 '20 at 17:47

Your corner on that RC combo (10K, 31.8u) is about half a hertz, not 50 hertz. However, the impedance of each stage is comparable to the impedance of the following stage, so they can't be evaluated independently; you'll have to treat it as a mesh.