Oscillations on output of an op amp differentiator - Page 1
Forum section: electronics / projects

author: madladlabs
author_rank: Newbie
timestamp: July 31, 2022, 02:47:17 am
content: I'm working on an audio detection circuit. The purpose is to detect a sonic shockwave. The working principle is to use a microphone to measure the sound pressure wave (shockwaves have a near vertical leading edge) using a microphone, then use an op amp differentiator to detect that sharp vertical edge (the sharpness of the edge depends on the mechanical damping of the sound wave). I threw together a circuit on a breadboard but I'm seeing some unexpected oscillations on the output of the differentiator.The circuit (the op amp is LM358, the microphone is a jellybean electret, built on a breadboard):The response (this was me clapping or snapping my fingers):The green trace is AC coupled to TP1 on the schematic, output of the follower on the electret.The orange is the numerically differentiated signal. The yellow trace is AC coupled to TP2 on the schematic and it's the output of the differentiator. Can anyone explain the extra oscillations on the output as compared to the expected signal.

author: Phoenix
author_rank: Frequent Contributor
timestamp: July 31, 2022, 03:00:15 am
content: Some opamps don't like the capacitive loading of an oscilloscope probe and will oscillate. You can decouple it with a 1k resistor before the probe tip.

author: moffy
author_rank: Super Contributor
timestamp: July 31, 2022, 05:32:03 am
content: An opamp differentiator tends to be fundamentally unstable because R4/C3 produce an extra phase shift into the -ve input which leads to instability. You can try to put a resistor in series with C3 or better still make your differentiator purely passive C3 followed R4 with one side connected to ground and adjust the values so that the area of interest is in 20db/decade region.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 31, 2022, 09:41:05 am
content: LM358 and you're asking if it's misbehaving?!It's not oscillating, it's just stabilizing. Try a 4.7k pullup on the output, forcing it into class A operation. LM358 is NOTORIOUS with its class-B output stage having bad enough crossover distortion that, well, I for one don't even like using it for control purposes (error amp) if I can avoid it.As for the application, I wonder how one would discriminate between real shockwave/sonic boom, and just loud crashes or sharp sounds. Is there anything distinctive about the waveform (leading vs. trailing edge)? Can a high explosive be reliably distinguished from a low explosive (e.g. firecracker), or the bullet crack and muzzle blast from a firearm (one or both of which may be supersonic!)? What about reflections and other filtering effects, how robust should it be to those? (Would it be in relatively free air, on top of a tower perhaps, or in a chase plane?) What kind of a microphone is that anyway, surely these are intense pressure levels and a regular mic will not suffice? (Most clip in the 90dBa range IIRC. For such loud signals, with a differentiator, I would have to guess you wouldn't even need a preamp, or much of one anyway, on a dynamic mic.) How compact does this thing need to be, could it just be a recorder instead, and later processing done to detect the desired wave shape? Would it be practical to run such analysis in real time with a modestly powerful (probably >30MHz) CPU, DSP, or SBC? (Differentiation is notoriously noise sensitive and a more nuanced signal processing method is almost certainly helpful. Even if just bandpass filtering, for example.)Tim

author: David Hess
author_rank: Super Contributor
timestamp: July 31, 2022, 10:53:41 am
content: By definition an operational amplifier differentiator is unstable. The gain increases at 6dB per octave and the feedback network has 90 degrees of phase lag so combined with the amplifier's phase lag, it *will* oscillate.The solution is to limit the high frequency response by adding a resistance in series with C3, so above the resistance and C3 breakpoint, The 90 degrees of phase lag is removed and gain no longer rises.Drawing out the bode plot for the differentiator circuit along with a -6dB per octave line which intersects the unity-gain frequency will show what the frequency breakpoint needs to be. In practice it needs to be like a decade lower for enough phase margin to provide good performance.I remember a differentiator made with a pair of integrators if better performance is required.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 31, 2022, 11:54:18 am
content: Isn't that phase lead? Lag would be decreasing with frequency, the more usual case.Or wait, the asymptotic equivalent circuit is input-shorted, which very much tends to oscillate (especially due to a complex (resonant) source impedance); is that the equivalent condition?Hmm, I must be surprisingly rusty on Bode plots and stability, intuition seems lacking for once...In any case, yeah, a resistor to introduce a pole is a good idea.Another way to put it: op-amps are only operational while the loop gain is very high. But a differentiator necessarily needs extraordinarily high gain, in comparison to the normal behavior of an op-amp: indeed the inverse of it, as an op-amp (dominant pole compensated, voltage mode) is an integrator over most of its frequency range. So to get any meaningful gain, and useful differentiation behavior, you need to be far enough down on that (integrator) curve that loop gain is high enough to meet your (operational) assumptions.Which also means the amp rolls off by itself, whether you mean it to or not; though because it runs out of feedback at high frequencies, it may not be all that well controlled in the process. (There will also be a null and subsequent recovery of gain, at frequencies where the amp is simply not doing anything at all (loop gain ~ 0, so, >> 1MHz) and the equivalent circuit reduces to an R+C in series with the amp's output impedance, i.e. the input feeding forward through the feedback network.)Tim

author: David Hess
author_rank: Super Contributor
timestamp: July 31, 2022, 09:17:14 pm
content: Quote from: T3sl4co1l on July 31, 2022, 11:54:18 amIn the differentiator configuration, the capacitor at the input and resistor for feedback makes 90 degrees of phase lag from the output back to the inverting input at high frequencies, which is sure to result in oscillation; internally there is 90 degrees of phase lag from the Miller compensation, (1) and external feedback to the inverting input is 180 degrees of phase lag, making a total of 360 degrees and trouble. The integrator configuration becomes unity gain and 0 degrees at high frequencies, which requires unity gain stability of the operational amplifier for stability.Practical operational differentiators must have the input series resistor for stability, but usually also have a parallel feedback capacitor to limit high frequency noise.I do not remember where I saw the double integrator replacement for a differentiator. Its advantages were inherent stability and lower noise. It was likely a Burr-Brown application note or Burr-Brown book about operational amplifier applications.(1) Nothing requires the use of 90 degree Miller compensation for stability! I have no doubt that someone, somewhere, has used a feedback amplifier with 45 degrees or less of compensation as a differentiator. Feedback amplifiers like this are very useful for driving capacitive or poorly defined loads, like what you might connect to a power supply. (2)(2) I have a truly marvelous implementation of a 45 degree integrator which this forum is too narrow to contain.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: August 03, 2022, 01:48:42 pm
content: Oh yeah, the intuition just came back... superposition of course.Consider the case with the input grounded, series cap, feedback resistor. Draw the capacitor vertically from -IN to GND, to emphasize the fact that this makes an RC lowpass filter from output to -IN. Thus, above Fc = 1 / (2 pi Rf C), phase tends to 90°, obviously problematic versus an integrator-like error amp.And then, if that's all that it is (ideal integrator), it's still stable, but rings arbitrarily badly (poles far apart, approaching the axis, but still LHP); but in practice, there are additional poles in the amp itself, and may be others in the surrounding circuit, which tip the phase over 180 degrees, and the poles slide over to the RHP.Source resistance provides a zero, returning some phase margin but limiting HF gain (thus, worsening the differentiation; but again, it can't be perfect anyway, and you wouldn't really want it to, for all the usual reasons).Quote from: David Hess on July 31, 2022, 09:17:14 pmIncidentally, my margins are adequate;https://seventransistorlabs.com/Calc/Coilcraft1.html#netnot that it's very wide of a range, but can be extended arbitrarily. A well characterized filter also appears in AoE2/3 for generating pink noise.Tim

author: madladlabs
author_rank: Newbie
timestamp: August 04, 2022, 09:00:40 pm
content: Quote from: T3sl4co1l on July 31, 2022, 09:41:05 amPull down resistors on both the follower and the differentiator outputs fixed the issue. From testing, the follower was also unnecessary.Quote from: T3sl4co1l on July 31, 2022, 09:41:05 amhttps://apps.dtic.mil/sti/pdfs/ADA299215.pdfAuthors of this US ARL paper used an array of microphones to classify the different rounds (ranging from bullets to tank rounds) flying past them.Quote from: T3sl4co1l on July 31, 2022, 09:41:05 amIn my case, I'm using a COTS electret and if that won't work I'll use a COTS piezo disc.https://apps.dtic.mil/sti/pdfs/AD1064218.pdfUS Army Corps of Engineers analyzes the use of condenser microphones for explosives.https://www.pcb.com/sensors-for-test-measurement/pressure-transducers/blast-transducersThis company makes piezo based sensors.Right now, I'm getting my amplifier circuits (with electret and piezo disc) roughly tuned for "clap sound levels". I'm hoping to go down to the range in the next two weeks or so to test the COTS components and my circuits to see if they are practical for small caliber munitions. Just waiting for my fiber optic USB extender to come in so that I can put a Picoscope with the amplifier circuit down range. Maybe I'll make a video out of it if the results are interesting. I'm specifically looking at what can you get away with when using cheapo COTS components.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: August 04, 2022, 09:59:55 pm
content: Hm, interesting!Tim

author: StillTrying
author_rank: Super Contributor
timestamp: August 05, 2022, 10:20:19 pm
content: Quote from: madladlabs on July 31, 2022, 02:47:17 amYou won't get a good edge in air from those, about the best way I found was to hand hold something very stiff such as a small ceramic tile over the mic and bounce a small steel ball off the top of it, you get quite good at catching the ball in the end.I think this is just a cheap EMC, from many years ago.https://www.eevblog.com/forum/testgear/siglent-cml-firmware/msg1203852/#msg1203852There's one here on detecting gunshots.https://www.eevblog.com/forum/projects/rip-me-a-new-one-how-bad-is-my-circuit-(bang-o-meter)/