Author Topic: Low pass filtering for differential opamp  (Read 6636 times)

0 Members and 1 Guest are viewing this topic.

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Low pass filtering for differential opamp
« on: July 30, 2018, 08:18:14 pm »
(I meant low pass filter)
I use an opamp in differential setup for measuring current. I need a low pass filter to cut off everything above 10-100Hz (not sure about the frequency yet).  I would like to have as steep fall as possible up to 40-60dB, as flat as possible. I want gain to be unaffected for low frequencies.

An option is to put active filter after the opamp, but I want to keep it as simple as possible.

It will be use for overcurrent and short circuit protection. Accuracy is not that important. I will have gain and offset correction in software and even after the correction 2-5% error is fine.

I was thinking about something like the attached schematic and tweak the values experimentally. But if I can get a schematic with simple formulas that I can put my values and calculate it'll be better.
« Last Edit: August 07, 2018, 06:48:38 am by npelov »
 

Offline b_force

  • Super Contributor
  • ***
  • Posts: 1381
  • Country: 00
    • One World Concepts
Re: High pass filtering for differential opamp
« Reply #1 on: July 30, 2018, 08:34:21 pm »
Try to searh for a differential mfb (multiple feedback) filter.
I believe Texas Instruments has some good papers on it as well.

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5871
  • Country: de
Re: High pass filtering for differential opamp
« Reply #2 on: July 30, 2018, 08:59:35 pm »
Please be precise: do you mean low pass or high pass? In any case, the op amp you already have can give you 20 dB/decade. If you want it steeper, a second amp can give you 20 dB more (= 40 dB/decade).
MFB is a very good idea, stay away from Sallen-Key filters.

 

Offline b_force

  • Super Contributor
  • ***
  • Posts: 1381
  • Country: 00
    • One World Concepts
Re: High pass filtering for differential opamp
« Reply #3 on: July 30, 2018, 09:53:47 pm »
Please be precise: do you mean low pass or high pass? In any case, the op amp you already have can give you 20 dB/decade. If you want it steeper, a second amp can give you 20 dB more (= 40 dB/decade).
MFB is a very good idea, stay away from Sallen-Key filters.
Since when are sallen key filters wrong?

Offline Audioguru

  • Super Contributor
  • ***
  • Posts: 1507
  • Country: ca
Re: High pass filtering for differential opamp
« Reply #4 on: July 30, 2018, 10:40:08 pm »
The opamp is not used as a differential amplifier since it has only one input. Also it is not an "active" filter, since the three RC lowpass filters are not inside the opamp's feedback loops making a droopy response.

The R2 C1 filter has a cutoff frequency of 114Hz.
The R4 C2 filter has a cutoff at 4.4Hz so it cuts all frequencies above 4.4Hz at -20dB per decade. Surely this is wrong.
The R6 C3 filter has a cutoff frequency at 160Hz.

Why not make an active filter?

The datasheet of the LM358 shows an absolute maximum allowed negative input of 0.3V but yours is at 1V which might destroy it.
 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Low (not High) pass filtering for differential opamp
« Reply #5 on: July 31, 2018, 08:46:07 am »
The opamp is not used as a differential amplifier since it has only one input.

It is differential opamp. R3 might look like it's connected to ground but it's not. It's connected to R1 terminal to be more accurate. Any wire/trace between R1 and ground will add to the resistance.

 
Also it is not an "active" filter, since the three RC lowpass filters are not inside the opamp's feedback loops making a droopy response.

Isn't C2 in the opamp feedback?

Try to searh for a differential mfb (multiple feedback) filter.

I did, but I couldn't find. I found this: http://www.ti.com/lit/an/slyt343/slyt343.pdf - it has an example for single ended output diff amp with a 50kHz low pass filter and gain of 10. I guess gain is R2/R1, but I have no idea how to change the other components to change the frequency. Is it the same as this schematic with ground as the negative output. However they give formulas, but only for gain=1.
« Last Edit: July 31, 2018, 08:52:25 am by npelov »
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19519
  • Country: gb
  • 0999
Re: High pass filtering for differential opamp
« Reply #6 on: July 31, 2018, 09:03:52 am »
The datasheet of the LM358 shows an absolute maximum allowed negative input of 0.3V but yours is at 1V which might destroy it.
Yes not good, but it won't destroy the op-amp because it has reverse protection diodes and the 3k resistor limits the current to a safe level.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5871
  • Country: de
Re: High pass filtering for differential opamp
« Reply #7 on: July 31, 2018, 09:20:52 am »
Please be precise: do you mean low pass or high pass? In any case, the op amp you already have can give you 20 dB/decade. If you want it steeper, a second amp can give you 20 dB more (= 40 dB/decade).
MFB is a very good idea, stay away from Sallen-Key filters.
Since when are sallen key filters wrong?

This has been discussed several times. Sallen-Key is not "wrong", but it's not a very good filter. It's simple and easy to calculate.
But the component sensitivities are high and always higher than 1.
It can be used for low gain, low Q applications, but the MFB is better.

 

Offline b_force

  • Super Contributor
  • ***
  • Posts: 1381
  • Country: 00
    • One World Concepts
Re: High pass filtering for differential opamp
« Reply #8 on: July 31, 2018, 10:13:45 am »
Please be precise: do you mean low pass or high pass? In any case, the op amp you already have can give you 20 dB/decade. If you want it steeper, a second amp can give you 20 dB more (= 40 dB/decade).
MFB is a very good idea, stay away from Sallen-Key filters.
Since when are sallen key filters wrong?

This has been discussed several times. Sallen-Key is not "wrong", but it's not a very good filter. It's simple and easy to calculate.
But the component sensitivities are high and always higher than 1.
It can be used for low gain, low Q applications, but the MFB is better.
In most applications you just want a Q of 0.707 or there abouts, so I don't see the issue.
The gain can easily be fixed by adding a very simple resistor attenuator somewhere in the circuit
It works perfectly fine in trillions of circuits around the world, I find it a little bit a wild-goose chase with a bizarre conclusion.

Anyway, here is the TI document;
https://www.fmf.uni-lj.si/~ponikvar/PDFji/A%20Differential%20Op-Amp%20Circuit%20Collection%20-%20sloa064a.pdf

Page 5 for example.

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Low (not High) pass filtering for differential opamp
« Reply #9 on: July 31, 2018, 10:40:41 am »
Anyway, here is the TI document;
https://www.fmf.uni-lj.si/~ponikvar/PDFji/A%20Differential%20Op-Amp%20Circuit%20Collection%20-%20sloa064a.pdf

Page 5 for example.

This is differential output too. I need single ended output. Also it sais R1-R2, so gain is 1. If I change the gain the formulas won't work (I guess).

The datasheet of the LM358 shows an absolute maximum allowed negative input of 0.3V but yours is at 1V which might destroy it.
Yes not good, but it won't destroy the op-amp because it has reverse protection diodes and the 3k resistor limits the current to a safe level.

@Hero999
Where did you see -1V? The input current is 10A with 1-2A noise that I want to cancel. Drop on shunt is 0.1V with 10-20mV noise (still above zero). For positive input the output is positive, so opamp inputs are both above zero.
 

Offline b_force

  • Super Contributor
  • ***
  • Posts: 1381
  • Country: 00
    • One World Concepts
Re: Low (not High) pass filtering for differential opamp
« Reply #10 on: July 31, 2018, 10:47:22 am »
Anyway, here is the TI document;
https://www.fmf.uni-lj.si/~ponikvar/PDFji/A%20Differential%20Op-Amp%20Circuit%20Collection%20-%20sloa064a.pdf

Page 5 for example.

This is differential output too. I need single ended output. Also it sais R1-R2, so gain is 1. If I change the gain the formulas won't work (I guess).

The datasheet of the LM358 shows an absolute maximum allowed negative input of 0.3V but yours is at 1V which might destroy it.
Yes not good, but it won't destroy the op-amp because it has reverse protection diodes and the 3k resistor limits the current to a safe level.

@Hero999
Where did you see -1V? The input current is 10A with 1-2A noise that I want to cancel. Drop on shunt is 0.1V with 10-20mV noise (still above zero). For positive input the output is positive, so opamp inputs are both above zero.
Just replace the same circuit for a differential to single ended circuit.

Calculating parts;
http://www.beis.de/Elektronik/Filter/ActiveLPFilter.html
or
http://sim.okawa-denshi.jp/en/OPtazyuLowkeisan.htm

Keep an eye on the caps, one of them is shared, so you need to change the value.
Use something like LTSpice to verify your final circuit.
« Last Edit: July 31, 2018, 10:50:33 am by b_force »
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19519
  • Country: gb
  • 0999
Re: Low (not High) pass filtering for differential opamp
« Reply #11 on: July 31, 2018, 03:24:47 pm »
@Hero999
Where did you see -1V? The input current is 10A with 1-2A noise that I want to cancel. Drop on shunt is 0.1V with 10-20mV noise (still above zero). For positive input the output is positive, so opamp inputs are both above zero.
Yes, you're right, audioguru confused Amps with Volts and I didn't question him. The shunt resistor is 0R01 and if the current is 10A, the volt drop will be 0.1V.

As drawn, the current is a sinusoidal source, with a peak value of 10A, so the voltage on the shunt will go below 0V. It will swing between +0.1V and -0.1V. The LM358 can handle small negative voltages, but its output will clip at just above 0V, as it can't go negative.
 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Low (not High) pass filtering for differential opamp
« Reply #12 on: August 01, 2018, 10:31:16 am »
As drawn, the current is a sinusoidal source, with a peak value of 10A, so the voltage on the shunt will go below 0V. It will swing between +0.1V and -0.1V. The LM358 can handle small negative voltages, but its output will clip at just above 0V, as it can't go negative.
it is still not going negative. It's 1A sine with 10A DC offset. That means sine goes from 9 to 11A. The whole thing started with my bad current source that I use to test my circuit. It's oscillating a bit, but the multimeter shows stable value at 5 sps. I should be able to do that too. Although I don't think the multimeter can show 5hz correctly. It does measure 5sps, but it ramps up for one or two measurements. So the DMM cut off is about 2-3Hz too aggresive for overcurrent protection.

Just replace the same circuit for a differential to single ended circuit.
...
Keep an eye on the caps, one of them is shared, so you need to change the value.
Use something like LTSpice to verify your final circuit.
So whatever connects tonegative output in diff-out should connect to ground? And when I use those single ended input calculators, whatever connects to ground I connect to negative input?

Btw, I've seen C1 on your circuit replaced with two aps in series in other circuits. Maybe that's how they deal with caps shared between inputs.
 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Low (not High) pass filtering for differential opamp
« Reply #13 on: August 01, 2018, 11:19:35 am »
One more question. When I use calculators, the Q factor must be as high as possible without making the system oscillate, right? If it's too low the fall won't be as steep.  If it's too high - oscillation is possible. This calculator shows oscillation if Q is more than 0.5 (MFB low pass). But b_force said it should be about 0.707. What's the best Q for MFB low pass filter?
 

Offline b_force

  • Super Contributor
  • ***
  • Posts: 1381
  • Country: 00
    • One World Concepts
Re: Low (not High) pass filtering for differential opamp
« Reply #14 on: August 01, 2018, 11:37:06 am »
One more question. When I use calculators, the Q factor must be as high as possible without making the system oscillate, right? If it's too low the fall won't be as steep.  If it's too high - oscillation is possible. This calculator shows oscillation if Q is more than 0.5 (MFB low pass). But b_force said it should be about 0.707. What's the best Q for MFB low pass filter?
What is the circuit exactly used for?

I think you're mixing up beta vs Q.
Although a Q of 1 is perfectly stable as well as sallen key or mfb.

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Low (not High) pass filtering for differential opamp
« Reply #15 on: August 01, 2018, 01:28:19 pm »
So higher Q doesn't mean less stability? Then why when I play with values the calculator says that the circuit will oscillate when Q goes higher than 0.5:
I tried these values:
R1 = 3k
R2 = 15k
R3 = 75k
C1 = 1uF
C2 = 20nF

Quote
Oscillation frequency
f = 6.6261486736273[Hz]

and if I rise C2 to 47nF I get Q = 0.33 and "The system does not oscillate."

No, I didn't simulate that yet to test if it's true.

I also tried with gain = 1. Still the same results.

Can you explain the impact of Q and what value should I try to achieve? I also noticed that if Q gets too high I get overshoot close to the cut-off frequency.
 

Offline b_force

  • Super Contributor
  • ***
  • Posts: 1381
  • Country: 00
    • One World Concepts
Re: Low (not High) pass filtering for differential opamp
« Reply #16 on: August 01, 2018, 02:04:49 pm »
So higher Q doesn't mean less stability? Then why when I play with values the calculator says that the circuit will oscillate when Q goes higher than 0.5:
I tried these values:
R1 = 3k
R2 = 15k
R3 = 75k
C1 = 1uF
C2 = 20nF

Quote
Oscillation frequency
f = 6.6261486736273[Hz]

and if I rise C2 to 47nF I get Q = 0.33 and "The system does not oscillate."

No, I didn't simulate that yet to test if it's true.

I also tried with gain = 1. Still the same results.

Can you explain the impact of Q and what value should I try to achieve? I also noticed that if Q gets too high I get overshoot close to the cut-off frequency.
I don't know what you're talking about, but a Q factor of 0.5 is very low.
Once again, you seem to mix up the Q with the damping ratio ΞΆ.

I don't really know what they mean by oscillation on this website.
It looks like they mean the frequency were the "boost" is of the Q.

You should read a bit more on to it like;
https://www.maximintegrated.com/en/app-notes/index.mvp/id/1762
https://www.edn.com/electronics-blogs/bakers-best/4418766/Closer-to-real-world-analog-filters
There are many more examples and explanations.

In general for Sallen Key filters you're totally fine for Q factors up to 3-5.
For most practical circuits I wouldn't know why someone would even want to go higher than that.
One huge advantage is that the unity gain is much more accurate for example for example.
But in general all these advantages and disadvantages are only gonna be an issue when looking for the limits (high bandwith, high Q factor, huge gains)
So it's not really worth going all into crazy debates about it.

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5871
  • Country: de
Re: Low (not High) pass filtering for differential opamp
« Reply #17 on: August 01, 2018, 02:44:36 pm »
For 2nd order and higher filters, Q is defined from the characteristic you want. The most common are Bessel, Butterworth or Chebyshev for maximally flat phase, maximally flat amplitude response or maximum cutoff with minimal peaking, but you can basically select any value between these, or even select higher Q at the cost of significant amplitude peaking.

All types converge on the same asymptote above the cutoff frequency (-40 dB/decade for 2nd order).

 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Low pass filtering for differential opamp
« Reply #18 on: August 07, 2018, 07:13:27 am »
I noticed I also need filter on the battery voltage, which I also measure with diff amp because I have 3 Li-ion cells. I've put together a filter by tweaking the values to get a nice curve in simulation. I still haven't done frequency response analysis of the real circuit. I'll have to do that one day...

The problem is that I don't get unity at zero frequency. Battery voltage is 3.786V, but I measure 3.54V (offset at 0V is 10-20mV). The diff amp before with 47k resistors was working fine with about 1% error. All resistors are 1%. I know the high value resistors are not a good idea with an opamp that has bias current 40 (typ) to 500 (max) nA and offset current 45-200nA. But I'm not sure that's the problem. I've tried the same circuit with 470k resistors and it gives exactly the same gain error. I've compensated the error in software and it seams to work fine, but I want to know where the error comes from. The simulation does not show the error. I guess the model is not perfect.
 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Low pass filtering for differential opamp
« Reply #19 on: August 07, 2018, 07:32:38 am »
Well as soon as I posted the schematic I knew what's wrong  |O. I've put the feedback resistors directly across the capacitors and not after R19/R20, which makes R19/R20 part of the gain. I fixed that and the readings came back to <1% error.

I noticed that whatever I do with the values the slope never gets bigger than 40dB/decade. So I only control the steepness near the transition frequency and the transition frequency itself, right? That's for this particular filter. If I want steeper fall, I need higher order filter.

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf