Low pass filtering for differential opamp - Page 1
Forum section: electronics / beginners

author: npelov
author_rank: Frequent Contributor
timestamp: July 30, 2018, 08:18:14 pm
content: (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.

author: b_force
author_rank: Super Contributor
timestamp: July 30, 2018, 08:34:21 pm
content: Try to searh for a differential mfb (multiple feedback) filter.I believe Texas Instruments has some good papers on it as well.

author: Benta
author_rank: Super Contributor
timestamp: July 30, 2018, 08:59:35 pm
content: 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.

author: b_force
author_rank: Super Contributor
timestamp: July 30, 2018, 09:53:47 pm
content: Quote from: Benta on July 30, 2018, 08:59:35 pmSince when are sallen key filters wrong?

author: Audioguru
author_rank: Super Contributor
timestamp: July 30, 2018, 10:40:08 pm
content: 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.

author: npelov
author_rank: Frequent Contributor
timestamp: July 31, 2018, 08:46:07 am
content: Quote from: Audioguru on July 30, 2018, 10:40:08 pmIt 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.Quote from: Audioguru on July 30, 2018, 10:40:08 pmIsn't C2 in the opamp feedback?Quote from: b_force on July 30, 2018, 08:34:21 pmI 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 asthis schematicwith ground as the negative output. However they give formulas, but only for gain=1.

author: Zero999
author_rank: Super Contributor
timestamp: July 31, 2018, 09:03:52 am
content: Quote from: Audioguru on July 30, 2018, 10:40:08 pmYes 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.

author: Benta
author_rank: Super Contributor
timestamp: July 31, 2018, 09:20:52 am
content: Quote from: b_force on July 30, 2018, 09:53:47 pmThis 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.

author: b_force
author_rank: Super Contributor
timestamp: July 31, 2018, 10:13:45 am
content: Quote from: Benta on July 31, 2018, 09:20:52 amIn 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 circuitIt 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.pdfPage 5 for example.

author: npelov
author_rank: Frequent Contributor
timestamp: July 31, 2018, 10:40:41 am
content: Quote from: b_force on July 31, 2018, 10:13:45 amThis 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).Quote from: Hero999 on July 31, 2018, 09:03:52 am@Hero999Where 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.

author: b_force
author_rank: Super Contributor
timestamp: July 31, 2018, 10:47:22 am
content: Quote from: npelov on July 31, 2018, 10:40:41 amJust replace the same circuit for a differential to single ended circuit.Calculating parts;http://www.beis.de/Elektronik/Filter/ActiveLPFilter.htmlorhttp://sim.okawa-denshi.jp/en/OPtazyuLowkeisan.htmKeep 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.

author: Zero999
author_rank: Super Contributor
timestamp: July 31, 2018, 03:24:47 pm
content: Quote from: npelov on July 31, 2018, 10:40:41 amYes, 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.

author: npelov
author_rank: Frequent Contributor
timestamp: August 01, 2018, 10:31:16 am
content: Quote from: Hero999 on July 31, 2018, 03:24:47 pmit 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.Quote from: b_force on July 31, 2018, 10:47:22 amSo 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.

author: npelov
author_rank: Frequent Contributor
timestamp: August 01, 2018, 11:19:35 am
content: 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 calculatorshows 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?

author: b_force
author_rank: Super Contributor
timestamp: August 01, 2018, 11:37:06 am
content: Quote from: npelov on August 01, 2018, 11:19:35 amWhat 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.

author: npelov
author_rank: Frequent Contributor
timestamp: August 01, 2018, 01:28:19 pm
content: So higher Q doesn't mean less stability? Then why when I play with valuesthe calculatorsays that the circuit will oscillate when Q goes higher than 0.5:I tried these values:R1 = 3kR2 = 15kR3 = 75kC1 = 1uFC2 = 20nFQuoteand 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.

author: b_force
author_rank: Super Contributor
timestamp: August 01, 2018, 02:04:49 pm
content: Quote from: npelov on August 01, 2018, 01:28:19 pmI 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/1762https://www.edn.com/electronics-blogs/bakers-best/4418766/Closer-to-real-world-analog-filtersThere 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.

author: Benta
author_rank: Super Contributor
timestamp: August 01, 2018, 02:44:36 pm
content: 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).

author: npelov
author_rank: Frequent Contributor
timestamp: August 07, 2018, 07:13:27 am
content: 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.

author: npelov
author_rank: Frequent Contributor
timestamp: August 07, 2018, 07:32:38 am
content: Well as soon as I posted the schematic I knew what's wrong. 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.