Adding a lowpass filter to an op-amp to filter out high frequency noise

Thread Starter

UncleDongle

Joined Jan 19, 2024
3
I'm measuring a 50Hz signal, but I'm getting some high frequency noise on the output that I'd like to get rid of. My idea was to add a lowpass filter to the circuit, with a cutoff frequency of 50Hz. I can get the cutoff frequency to be around 50Hz when adding an RC filter at the input, but that creates a voltage drop at the input, which is unwanted behavior.

Can anyone help me understand where I should add the filter to the circuit to avoid a voltage drop on the input(and as a result, the output as well), while filtering out noise above 50HZ?

The circuit without the filter:
1705701439193.png
 

crutschow

Joined Mar 14, 2008
34,454
Look up Sallen-Key lowpass filter design with gain, which will have a 2-pole rolloff above the corner frequency.
You can add the filter components to the op-amp you are using.
Here's a design tool to help you with that.

Ask here if you have any questions about that.
 

Thread Starter

UncleDongle

Joined Jan 19, 2024
3
Thank you for the answers. I already tried putting a cap across R5, seems to do nothing.

I tried the Sallen-Key calculator you linked crutschow, but I still don't get exactly where to add the filter components to my existing circuit. I tried it like this, which does create a lower cutoff frequency, but now just outputs 3.3V without oscillating and the gain rises again after 10KHz.
1705706554963.png

The bodeplot honestly looks completely messed up to me. Here is a screen of it.
1705706712219.png
 
Last edited:

AnalogKid

Joined Aug 1, 2013
11,052
By definition, the output of a single-pole filter will be down 3 dB at the corner frequency. If you have a filter with a corner freq of 50 Hz, then with a 50 Hz signal, the output will be 70.7% of the input. If you go with a multi-pole filter, and it is a Butterworth configuration, the same will be true no matter how many poles there are. The attenuation above 50 Hz will increase with each additional pole, but the behavior at the corner freq is a constant.

One way to improve things is to change the corner frequency. If you move the corner to 100 Hz, the response at 50 Hz will be down only 1 dB. This means less attenuation at higher noise frequencies, but you can compensate for that by using a 2- or 3-pole configuration.

If the signal freq is a constant 50 Hz, as opposed to a nominal value with some additional bandwidth, then the attenuation at the corner freq can be compensated for with a gain stage.

What is the total bandwidth of the signal? Also, what is its wave shape? Everything above is true for a sine wave, but a more complex waveform has harmonics that can be attenuated by the filter, creating distortion in the output signal.

An interesting alternative are the switched-capacitor filters from Linear Technology and Maxim.

As you can see, there is no such thing as a perfect filter and there are several tradeoffs in filter design. You have to decide where your priorities are and which compromises are tolerable, and then you can search for a topology that meets your requirements.

ak
 

crutschow

Joined Mar 14, 2008
34,454
Here's the sim of your circuit with some modifications:

I increased some of the resistor values to give more reasonably sized capacitors.

I moved the 100kΩ bias resistors to the input so they don't affect the frequency response and gain.

The rise in gain at high frequencies is likely due to the limited gain-bandwidth of the op-amp.
I added R7 and C5 at the input so the output response never rises above about -96dB at high frequencies, if that high frequency rise is a problem..

1705712211859.png
 

Bordodynov

Joined May 20, 2015
3,180
Here is a filter that does not have record parameters, but was made without further ado. And it is not picky about the range of capacitor values.F50Hz.png
 

Ian0

Joined Aug 7, 2020
9,822
some high frequency noise on the output
What is the frequency of the noise? Unless you know that, you will never know the best way of getting rid of it.
If you use an active filter, you can only filter out frequencies that the op-amp is able to amplify without excessive phase shift. Depending on your op-amp, a Sallen & Key filter is not going to work well above the audio range (say 20kHz)

@Bordodynov 's passive 2-pole filter is always going to be best at removing high frequency noise, but its initial roll off is very slow. It could be improved a little by making R4=10k C5=33n.
Your 2-pole Sallen & Key will remove noise that is between 100Hz and 20kHz, as your Bode plot shows.
@crutschow 's 3-pole filter does a good job, because it has a single passive pole BEFORE the active part, and the passive filter removes the very high frequency noise.
If it is very high frequency noise, an LC filter might work best, or a ferrite bead for really high frequencies.
 

Thread Starter

UncleDongle

Joined Jan 19, 2024
3
These are som amazing responses, thank you so much.

I might have left out too much information originally, so I'll try to fill in a bit:
- The signal is just a current transformer on a mains connection, so it should be a very steady 50Hz sinusoidal at all times.

- The real op-amp I'm using is an MCP6002. I only chose the LT1677 randomly for the simulation because I couldn’t find the MCP in LTSpice, and it had rail-to-rail output of the supply voltage (3.3V) like the MCP.

- I don't know the source of the high frequency noise. When I connect an oscilloscope to the output, I can see that the frequency of the noise jumps around, but as far as I recall, it's mostly in the KHz range.

I tried out the suggested circuit diagrams, and Bordodynovs filter seems to do the job. I get almost rail to rail on the output and the cutoff frequency is at around 180Hz, which I think is fine. However, I have been told that the phase margin should never be larger than 160 degrees, or the system might become unstable, so I worry if the 157 degrees the system has now is too high?

1705763780783.png

I have read about the Sallen Key filters to try and understand how this works. Do I have it right that if the caps and resistors are swapped, we will get a high pass filter instead?
I also wonder why I seem to get a much higher dB gain than both crutschow and Bordodynov using the same values for components.

Again, thank you for the great responses and help from everyone, I really appreciate it.
 
Top