Deep dive: the instability of op-amps

(lcamtuf.substack.com)

114 points | by lapnect4 days ago

11 comments

  • dragontamer4 days ago
    It's almost criminal that all of these bode plots are missing their phase diagrams.

    Phase diagrams + OpAmp phase shift specs / phase margin are what you need to predict instability.

    -------

    EDIT: IMO it's also a lot easier to explain in the frequency domain. At 180-degree phase shift, all your negative feedback turns into positive feedback, causing instability. You need your amplifier to stay as far away from 180-degree phase shift as possible.

    I get that what the author was trying to get to with the 'Tape Delay OpAmp' example. But it should be double downed upon and the starting point of the discussion rather than something brought up later IMO.

    • ChuckMcM4 days ago
      I appreciate what you're saying. That said, not everyone learns the same way and for me, his explanations have always been clear and insightful. My theory is that different brain architectures ingest information in different ways (this is actually studied but not conclusively proven AFAICT) and that the language of exposition has a sort of 'impedance match' with brain architecture. So sometimes you can say something and the person hearing/reading it will just "get it" right away, and sometimes they will look at you like "that didn't help at all."

      That said, I agree that if you're used to thinking about things in the frequency domain it makes sense to explain it in those terms. Myself, as a young EE in college found thinking about things in the frequency domain to be useless, in part because I didn't understand the math, and in part because I didn't really understand sinusoidal waveforms. It wasn't until I started diving into SDRs and really unpacking the FFT and how it worked and why did I manage to connect a lot of dots that retroactively gave me a better insight into what my control systems professor was trying to teach me back in the day.

      • H8crilA3 days ago
        You don't actually need to reach for theories about the inner workings of a brain. A person's education history can strongly bias towards one form of information presentation over another. For example imagine a self learned musician who doesn't even know the notation vs a classically trained one.
    • FunkyDuckling4 days ago
      I agree.

      Phase Margin (How far away you are from 180 Phase Shift) is a critical parameter used whenever designing any kind of feedback loop and testing for stability.

      This is very to measure at the 0dB gain he pointed out, but lacked the phase diagram to show this shift.

      • arijo4 days ago
        This is only true for LTI (linear time-invariant systems).

        Nonlinear systems responses to a sine signal are in general not just a change in phase and amplitude.

        It works if the perturbation stays small and within a linearised version of the dynamics.

        • 4 days ago
          undefined
      • dsv3099i4 days ago
        I agree the overall math is easier in the frequency domain, especially because you don’t know which frequencies are problematic so best to look at all of them, but I think the concept is best explained at first, in the time domain.

        Here’s my attempt in a couple of sentences.

        It takes time for the signal to propagate from input to output in any real circuit. If that time is a substantial fraction of the period under consideration then the input of the amplifier, which includes the feedback signal, cannot effect the output before it has moved. And if the delay through the amplifier is just wrong relative to the signal period one can end up in a dog chasing its own tail situation and the output oscillates.

        The rest is just math. :)

        P.S. this explanation also explains why we use phase and not seconds to measure the delay of the circuit. Because everything is relative to the input signal period and if we use phase we get that for free. No extra divide.

  • neuralRiot4 days ago
    Ahh the good times I remember designing and building some configurable audio crossovers with “memories” so they could be adjusted and stored. This was of course before DSPs were even a thing. We gave up because the only solutions were inserting mosfets on the opamp loop or using transconductance opamps. Both solutions were terrible in terms of audio quality, we decided for “cartridges” that were the whole x-over stage.
  • Buttons8404 days ago
    This is tangential, but I took an EE class at community college and the very first thing they did was start teaching op-amps. I don't remember ever getting any insight from working with them, only that we had to follow instructions and build one in the lab.

    When I see people asking questions about op-amps and doing "deep dives" into op-amps, I'm left wondering what's so deep about these things we do in week 2 of EE 101.

    I've forgotten almost everything from that class though, so maybe it was just a bad class? I switched majors and never took another EE class.

    • michaelt4 days ago
      > I'm left wondering what's so deep about these things we do in week 2 of EE 101.

      Part core concept, part outdated nonsense that's taught due to tradition.

      If you've got components that can halve a voltage, then by putting that in a feedback loop you can double a voltage.

      And you can make an accurate amplifier even if some of your components - like the op-amp's gain - are inaccurate. So long as your voltage-halving components are accurate, your voltage doubler will be accurate whether your op-amp's gain is 10000x or 20000x

      You can chuck other components into the feedback loop too - want a higher current output from your voltage doubler? Have the op-amp control a high-power transistor.

      You know how a feedback loop can turn a voltage-halver into a voltage-doubler? It can invert other mathematical functions too. Put a capacitor into your op-amp circuit and you can integrator or differentiate. There are even op-amp circuits for summing inputs!

      You now understand feedback loops, precise gains, power output stages, integration and differentiation. You can now make a PID controller - a key concept in control theory! Just what you need to position control a robot's joints.

      Except making PID controllers out of op-amps is obsolete; they're all done in software these days.

      • jcgrillo4 days ago
        Building a PID controller to control the temperature of a (IIRC) piezoelectric cooler (or was it a hot plate? I don't remember exactly) was such a fun exercise. It took me until like 3am to get it working, most fun I had in junior year physics lab.
    • masspro4 days ago
      It is a headscratchingly bad idea to put op-amps in week 2 of course #1. I can’t even remember for sure if we did them in the first course, but if so, it was at the very end, after you already know how to do algebraic working-out of values in a circuit. From there, they give a couple algebraic rules to figure out what an op-amp circuit does. And a key point that is usually glossed over is: op-amps are basically useless when not in a feedback configuration, and some of the analysis rules are based on already assuming the op-amp is in a feedback configuration.
    • analog314 days ago
      I'd say that nothing can be covered deeply in an introductory survey class. If it's being taught at the 101 level, the students don't yet have the math to scratch anything beneath the surface. And one of the points of op amps, if not the main point, is the correspondence between their mathematical representation, and their real world behavior.

      There are entire books about op amps and their uses. They're a cornerstone of analog design.

      • Buttons8404 days ago
        Now that you mention it, I remember the point was the difference between the theoretical math and the actual behavior.
        • WJW4 days ago
          I can definitely see how a more advanced student can get a ton of valuable insights about the "abstraction leaks" of opamps, and I would even submit that opamps could be a particularly fertile place of such leaks (for our more software minded brethren: opamps are like databases: they are perfect until you start to push their boundaries and then you very quickly start to see just how imperfect they are), but I doubt you can teach a student enough about the theoretical math to get a useful intuition about the behavior of opamps in under 2 weeks.
        • analog314 days ago
          Indeed, but you have to grasp one before it makes sense to learn about the other, and neither is going to happen in a 101 class.
    • fourier544 days ago
      If your only interaction was "follow instructions and build one in the lab", doesn't that tell you exactly there is something deep you didn't understand at all?
    • BobbyTables24 days ago
      Starting with op-amps sounds like a horrible way of teaching EE.

      We started with transistors (BJT and FET) analyzed many types of designs, and only then moved on to op-amps.

    • Metacelsus4 days ago
      Yeah I was very confused by them in high school, I just internalized "op amps are weird" and then became a biologist. This article was a great explainer. Similar feedback loops happen in biology!
    • szundi4 days ago
      These are pesky little things
    • pbazarnik4 days ago
      When I first discovered OPAMPs I my teen years while self learning the electronics I was astonished by the beauty and power of an abstract opamp: the mythical component with infinite differential voltage gain, zero common mode gain, infinite input impedance and zero output resistance. This marvelous device can only exist, without destroying the world by its infinite output power, by staying in equilibrium defined by negative feedback. /s

      You have to appreciate the reason it was invented in Bell Labs: analog computers, which primary applications at that time were in military applications for computing artillery solutions.

      Now, as a professional EE, I still think fondly of them, even though I know well about their real life limitations. My advice is to try to stay first at ideal OPAMP abstraction level to appreciate the mathematical usefulness of that abstract construct. This is almost entirely how professionals use them.

      I can only lament the educational system, which invariably makes the students miss the forrest for the trees by not presenting well the power of ideal opamp

  • ilayn4 days ago
    This is a bit of a strange presentation of stability but I liked it. I don't agree with the phase margin absence in the other comment but it would have been much clearer if the author chose to present it once via a Nyquist plot, then stuck with the magnitude plots which would clarify what we are talking about. It is also very welcome clarity to see that we are not using the weird dB unit in Bode plots.

    For those who are not related to the field, what the reported subject here (and destabilizing effect of the negative feedback) is fixed by Black to remedy amp ringing, led to Bell labs, develop frequency domain techniques later analyzed by Nyquist and Bode (also seniors in Bell labs) then made western control theory kick off (then united with the Soviet techniques) and today everybody losing their mind about boosters coming back to base with SpaceX (which was already done a few times historically decades ago).

  • RossBencina4 days ago
    If you want an actual deep dive watch James K. Roberge's OCW course and/or get the book "Operational Amplifiers Theory and Practice".
  • buildsjets4 days ago
    But the ringing, sustained oscillations, and excessive gain are sometimes desired characteristics of a particular op-amp implementation.

    https://youtu.be/SrS9EtfcANg?si=MwbtbuPWu85Tbjzq

    • ericwood4 days ago
      Those op amp characteristics aren't really coming into play for that delay sound, it's just vanilla digital delay. Most of the "vibe" of the DD-3 is coming from the companding and filtering scheme it uses to work around the limitations of the digital pieces.

      You will hear the effects of this in many hard clipping distortion circuits, though, where the amplifier gain factor will far exceed the voltage rails and be pushed into undefined clipping territory. Behaviors in this range can be an important part of the sound, e.g. the Proco Rat and the infamous LM308 op amp with its slow slew rate. Some like the TL072 exhibit a really nasty phase inversion that results in a pretty horrific (usually undesired) distortion.

      It's a balancing act, though; search "op amp motorboating" in any DIY stompbox forum and you'll find thread after thread of people trying to keep op amp gain stages from oscillating. I know more than a few noisier artists who enjoy when designs can be tortured into doing that, though :)

      • kazinator4 days ago
        Motorboating feels like a strawman version of op-amp oscillation. It occurs because the tinkerers are using single supply circuits, without adequate bypassing to ensure that their virtual ground network has very low resistance. Thus the current dumped to ground by any circuit generates a voltage which appears to it and all the other circuits (ground loop). Another ingredient in motorboating is that there are multiple amplification circuits cascaded together which are coupled using capacitors (due to the single supply operation, again, which tends to discourage DC coupling). The ground loop creates a feedback path across multiple amplifiers, and the coupling capacitors create the phase shift.
        • ericwood4 days ago
          I'm not sure what you mean by "strawman version of op amp oscillation"; for many it's the colloquial term for oscillation. You can accomplish it very easily with many classic distortion circuits, especially on a breadboard. Guitar pedals are almost always run off a unipolar 9V supply. Large bypass caps are the normal (usually cargo culted over as a 100u at the input).

          There's a lot of constraints that either remain due to the restrictive power supply requirements on top of tradition or people building off designs from the 90s that were hand assembled and took BOM golf to the next level.

          • kazinator4 days ago
            Motorboating is not a colloquial term for all oscillation. It's a very low frequency instability consisting of a train of pulses which, when played through a speaker, sound like an internal combustion engine with a short exhaust.

            The op-amp oscillation the article is talking about occurs in the radio frequency range. Tiny parasitic capacitances induce 180° phase shift at some very high frequency where the op-amp's open loop gain has dropped to unity.

            You can't hear this directly since it's not in the audio range. It brings about distortion. The amp may pass audio signal, but the oscillation prevents it from performing properly.

            • ericwood3 days ago
              In the contexts I was talking about (hobbyist DIY guitar pedal forums) motorboating is often used as a catch-all for many types of oscillation, probably because the symptoms you describe are a very common error. Sometimes you get lucky and can tune the resulting oscillator by turning the guitar's volume knob!

              I wasn't trying to assert anything about the article, just responding to a comment about desired op amp imperfections in guitar effects. It's fairly common practice to bandwidth limit high gain op amp stages to avoid the issues discussed in the article, amongst other things.

    • analog314 days ago
      Sure, the Wien bridge oscillator. But then, oddly enough, even sustained oscillations need to be controlled in their amplitude, and the Wien Bridge has a secondary feedback loop for that purpose -- the temperature dependent resistance of a light bulb.
  • ggm4 days ago
    Did op amps on a uni CS degree in 79-82 and they never explained why. "Learn this" was an unhelpful approach where "these are building blocks which matter in digital communications, IO, control systems and signal processing" might have helped.

    Same with numerical methods. Zero sense of why we had to learn, and I failed spectacularly.

  • Metacelsus4 days ago
    Until reading this article I never really understood what an op-amp actually did (I remember coming across them as high schooler and being confused).
  • davidhyde4 days ago
    What an absolute goldmine of a website. So many varied topics. Just amazing.
  • 0823498723498724 days ago
    to what degree does the Gartner hype cycle resemble the Gibbs phenomenon?
    • marcosdumay4 days ago
      To the degree that society is a complex system with feedback.

      But notice that the Gartner hype cycle is full of unjustifiable hidden assumptions (like the fact that the thing being hyped is useful at all) so it has no predictive power. It only happens that some times people act like that.

      Also, there's no guarantee that the society's response to a change will be stable.

      • WJW4 days ago
        One of the most "useful" insights I ever had is that

        0. Any transfer function higher than 2nd order overshoots.

        1. Society is super complex, has a ton of internal feedback loops and would easily be higher than 2nd order.

        2. So of course it overshoots all the time.

        I haven't been able to actually "use" it for anything but it does describe a lot of what we see every day in society.

        • RossBencina4 days ago
          > Any transfer function higher than 2nd order overshoots.

          That's false. Any LTI system higher than first order might overshoot. But it's easy to design high-order systems that don't overshoot. Consider for example a cascade of first-order sections. Related terms: Bessel filter, complex vs real poles, overdamped system.

  • sobriquet94 days ago
    The tape delay methaphor confused me. Tape recorders do not record DC or other frequencies much lower than, say, 20 Hz. So that circuit would run into one of the rails just as quickly as the previous cirquit without DC feedback.
    • mrob4 days ago
      It must be an FM encoded tape, which can record DC. There were upgraded versions of both VHS and Betamax with FM audio support (although I expect in practice the inputs were AC coupled).
      • sobriquet94 days ago
        FM audio does not carry DC either. PLL in the receiver/decoder will eventually catch up with the constant frequency shift.
        • ddingus4 days ago
          It can carry frequencies much closer to DC.

          The above mentioned FM upgrade to VHS, called HI-Fi VHS I believe, had excellent audio recording capabilities. I used it to archive albums back in the day, and when I play some of the warped ones back today, the speaker cone can be seen moving where it would playing the original vinyl.

          • sobriquet94 days ago
            But not DC itself. Even if it goes down to 1 Hz, the circuit in question will saturate in a few seconds, or be in saturation when initially turned on and never get to zero as there is no DC feedback.
            • ddingus3 days ago
              Yes, I did not mean to imply otherwise.

              The way I have always come to understand this boils down to what modulation actually is. DC is not modulation. Anything above DC can be, or maybe technically is and must be managed or accounted for. Frequency drift might be one example.

              DC is basically continuous wave and the signaling, if any is intended, is basically limited to turning the wave on or off, or the wave just being present.

              The VCR was basically reproducing very low frequency waves. One could see the cones moving in and out with the rotation of the 33 RPM vinyl.

              The only other analog device that did something similar was an old vacuum tube reel to reel running a very high tape speed. And the effect was not as dramatic.

              Both of those devices could basically archive a CD respectably. The VCR added about 3db and the reel a bit more that I was not in a position to measure.

              The most striking things about that ancient reel to reel device were that it was rack mounted with some other gear, EQ, pre-amp, amp, and some other things, and how much better it could really do when using pretty great tape at crazy speeds. The highs would start to roll off pretty high, 18khz or so. The usual was 10 to 12.

              That was a very fun old piece of gear. Left over relic from the 60's available for curious high schoolers to tinker with.

        • mrob4 days ago
          Who says you have to use an analog PLL decoder? FM audio tape is clearly capable of storing DC because you can store a constant sine wave at a different frequency to your carrier frequency. Maybe you'll decode it with software defined radio software.
          • sobriquet94 days ago
            Even when you decode with an SDR, you still need to adjust the receiver frequency to match that of the transmitter, as reference oscillators might have slightly different frequencies that can also slowly shift, e.g., due to changes in temperature. In case of a tape recorder, tape speed during recording and playback can also be slightly different due to mechanical factors.
            • mrob3 days ago
              Sync everything to GPS. Record a harmonic of the carrier on the same tape, or just record the carrier itself on a parallel track. Have the SDR use this reference tone to undo any tape speed fluctuation artifacts. You can bring the deviation from DC so low that your comment no longer has any relevance to tape machines and just becomes a pedantic comment that mathematically perfect DC doesn't exist in physical reality.
              • sobriquet92 days ago
                Tape machines predate GPS.

                A metaphor should be referring to something common, not something that can be made in theory to fit a different set of requirements, but does not really exist.