# Filtering a Square Wave into a Sine Wave

I am trying to Filter a +-4V odd inverted square wave into a sine wave. How should I go about doing so?

So far I have computed the Fourier series of my particular input signal to be:

Which I know to be correct. I am trying to isolate the first harmonic frequency to get my sinusoidal output, which is 1Hz.

I am trying to use an active feedback filter using a TL072 op-amp. So far I have only simulated on LT-Spice and I am getting this output and I cannot figure out why.

I used the frequency band .3 Hz to 1.7 Hz with a corner frequency (.3^2 + 1.7^2)^(1/2), and an Av Gain of 40. I computed R1 and R2 and then computed a common C that would center the frequency range at the corner frequency. They are shown in the circuit diagram.

This is where I got the filter design and model equations from:

(Scroll to Infinite Gain Multiple Feedback Active Filter at

I have tried bumping up the input square wave voltage offset so that the op amp minimum output doesn't limit the output, but I seem to still be getting that effect. I have to use an Active filter design in order to do this.

Here are my square wave output and sine wave output together:

The top starts to look like a sine wave but then the bottom half appears to not pass through the filter. I am thinking that I have the op amp configured incorrectly. When I remove the ground from the - terminal, it crashes the simulation.

## 1 Answer

You need a bipolar amp with a bipolar signal, the bottom half is cut off because the negative power terminal of the amp is connected to ground. The amplifier can't create a voltage lower than the negative power terminal.

Either shift the signal up to half of (or within) the range of the amplifier, or create a negative rail.

You need grounds in the simulation, or the node voltage cannot be determined by the simulator (just like you can't solve the voltage on paper without the ground either).

• What do you mean by negative rail? Should I remove the ground from the negative terminal of the op amp? When I do so, the simulation crashes. Commented Jun 18, 2019 at 17:53
• Create a -5V power supply for the opamp, like the one shown here: i.sstatic.net/khVKf.png Commented Jun 18, 2019 at 17:55
• Either that or change the sine wave so it varies from 0 to 5V with an offset of 2.5V Commented Jun 18, 2019 at 17:55
• Aaah. Solved thank you. Commented Jun 18, 2019 at 18:03