You have built some clever analog circuit and now, when you go to check it with an oscilloscope, you find that the output signal is a mess: not what you expected, but a mass of oscillation riding on the output signal.
(This is one of many reasons why you need an oscilloscope to check out an analog circuit: it is the only way to find problems like this one. And we have some fine scopes for that ;).
There are, alas, a number of reasons a circuit may oscillate. If you are unlucky, there may be more than one thing going wrong. Fundamentally, some signal is working its way around a complete loop, from output to input, with a phase shift that is equal to or greater than 360 degrees, and magnitude greater than unity. That said, it’s often not obvious which loop(s) are causing the problem.
You need to tackle the possible causes one at a time. It’s essential to be systematic, and it helps to keep notes of your progress – or lack of it.
Is it really oscillation?
An interfering signal, perhaps coupled into a high impedance point in the circuit or via some long wires, can masquerade as oscillation. If the signal changes dramatically when you move it or move metal objects in the vicinity, it may be an interfering signal. For example, I mis-identified as oscillation a signal that turned out to be electrical noise from a cooling fan. Turning off the fan instantly identified that it was the culprit. The solution: operate the fan from a separate supply, with its own separate wiring.
Is it likely to oscillate?
The grizzled veterans among us can eyeball a circuit and tell whether it’s likely to oscillate. More stages inside the feedback loop, higher gain inside the feedback loop, cascaded sections with different bandwidths – these are warning signs that oscillation could be a problem. Then, at the design stage, you can be prepared: if the loop oscillates, how can we fix it?
Power supply decoupling.
The circuit causes an alternating current to flow in the power supply and gound leads. That AC current should ideally be localized to that particular circuit, and the way to do that is with a bypass capacitor between power supply and ground. Always, always, always put 100nF between supply and ground at each integrated circuit or circuit function. Sometimes, a larger capacitor is required. Sometimes, a smaller capacitor is required in addition to to the 100nF unit.
Put a large electrolytic capacitor, in parallel with 100nF, between each supply voltage, where it enters the board, and ground. This will minimize the effect of the wiring impedance due to the connection between your circuit and the bench power supply.
How did you build the circuit? On a protoboard? Those things are a wonderful invention, and they are great for testing a small circuit that is unlikely to oscillate. But the minute you see oscillation, you should be thinking about relocating to a copper ground plane, aka printed circuit board. Start with a bare copper board and then build up the circuit, dead bug style, using soldered connections. Solder terminal strips and banana jacks to the board to make the input and output connections. If the circuit involves high frequency signals, use BNC connectors to bring the signals onto the circuit.
Some people suggest using glue to hold the components. I find that soldered connections, using solid wire, tie the components in place well enough.
If you are building on a copper board, then you have a nice solid ground to connect to, and that will minimize voltages that are set up by currents in the ground plane.
You have decoupled all the circuit blocks (such as integrated circuits), you have decoupled the power supply and the circuit is solidly mounted on a copper PC board ground plane. And it still oscillates. Now what? Have a look at the datasheets for the active devices used in your circuit. They may have important clues. For example, power op-amps and audio amplifiers often have an RC ‘snubber’ network between the output and ground: something like 1 ohm in series with 220nF, for example. At frequencies above 700kHz, the 1 ohm resistance appears across the output and acts with the output resistance of the amplifier to form a voltage divider. This reduces the output signal high frequencies, where oscillation is likely to occur.
There are some situations that should be an immediate red flag to a circuit designer where oscillation is concerned.
– Emitter followers have a tendency to oscillate. This is counter-intuitive, because the voltage gain of an emitter follower is less than one. But the emitter follower *does* have power gain, and for certain phase conditions it will oscillate. The solution is a resistor in the base lead of the emitter follower: a few hundred ohms for a single emitter follower, about 5000 ohms for a darlington pair.
– Resistor-capacitor lag (low pass) networks in the loop. Each RC lag contributes up to 90 degrees of phase shift. Assuming that there is a sign change somewhere in the loop, then an additional 180 degrees of phase lag will cause oscillation. These RC lag networks are often part of the ‘hidden schematic’, invisible components such as stray wiring capacitance or the collector-base capacitance of transistors. A common technique is to bypass the resistance with a capacitance, thereby turning the network into a ‘lag-lead’ network and at (least partially) cancelling the phase lag.
– Another form of the RC lag problem is a capacitive load at the output of an op-amp. This interacts with the output resistance of the amplifier to create phase lag and thereby destabilize the operation of the amplifier. The simplest solution is to isolate the capacitance with a resistance that is outside the feedback loop of the amplifier – if the circuit will allow it. If this is not possible, then a buffer amplifier between the amplier and capacitive load may help. There are also ways to include this ‘buildout resistance’ inside the negative feedback loop, but they require some careful analysis.
Fast-Slow Compound Circuit
You have now dealt with all the ‘red flag’ items and the circuit still oscillates. Here’s an insight that I learned from Jim Williams: a circuit will oscillate if the feedback loop includes two stages and the first stage is much faster (greater bandwidth) than the second stage. This is a very common situation, for example, where a relatively fast op-amp drives a power amplifier stage containing high-current power transistors. The power transistors have a much lower bandwidth. When a correction signal arrives at the op-amp, it attempts to adjust the output via the buffer amplifier. But because the buffer is slow, the op-amp overshoots on its output signal. Then it belatedly detects the overshoot at the output of the buffer and tries to correct in the opposite direction, again overshooting. The result is oscillation.
In conceptual terms, the solution is very simple. Speed up the buffer stage or slow down the op-amp. In general, speeding up the buffer stage is not an option, so the op-amp must be slowed down to the point where the buffer can accurately track the op-amp output. Often, it is sufficient to put a small capacitor between the inverting input and the output of the op-amp. This makes the op-amp behave as an integrator for fast signals, reducing the slew rate for a step and reducing the AC gain for a sine wave. This doesn’t always work perfectly: the capacitor adds phase shift as well as reducing gain, so it may not be a perfect solution. For example, it is sometimes advantageous to put a resistance in series with this feedback capacitance. Then at high frequencies, where the feedback capacitor is small compared to this resistance, the amplifier gain is reduced by the resistance.
To find the optimum value for this resistance, you may need to do a more detailed analysis or use circuit simulation.
Too Much Gain at High Frequencies
The output snubber network and the fast-slow compensation capacitor both work by reducing the gain of an op-amp at high frequencies. There is another technique that can be very effective: a resistor-capacitor network between the input pins of an op-amp, to reduce the so-called ‘noise gain’.
The shunt resistor across the input acts to form a voltage divider with the feedback resistors. For example, if the feedback resistance is 1k and the shunt resistance is 100 ohms, then the loop gain is reduced by a factor of 10. We want this gain reduction not to occur at low frequencies, so the shunt resistor is placed in series with a capacitor. At high frequencies, the capacitor becomes a short circuit and the shunt resistor comes into effect. For example, if the oscillation is occurring at 1MHz, then choose the resistor and capacitor to become effective at, say, 1kHz. Again, simulation may help to optimize this circuit.
Circuit simulation (like LTSpice) is a wonderful tool, and it can be very useful in exploring circuit stability. However, there are some caveats.
– The accuracy of the simulation depends on the accuracy of the circuit model. For example, we recently worked on a power op-amp circuit that displayed oscillation when sinking current, but not when sourcing current. That behaviour did not show up in the circuit model.
– Circuit simulation is of no help diagnosing grounding and power supply problems because the inductance and capacitances of the wiring are generally not known. They are part of the ‘hidden schematic’.
– A circuit simulator does not suggest solutions to a problem. (Hey, Pete, I think you should increase the phase margin of the second stage of this circuit by adding a lead-lag network.) There may come a day when circuit simulators have that capability, but we’re not there yet. Consequently, you need to have some ideas of Things To Try, and hopefully the points given above will provide a starting point.
Simulation is no substitute for building a prototype and testing it thoroughly.
Try stuff to see what happens
Sometimes, it can be difficult to tell where to direct attention in the circuit. If it’s a large loop with several components, is there one location where a fix can be applied? Well, try stuff. Place a capacitor around one of the op-amps in the circuit and see if that has an effect. No effect? Then try some other part of the circuit. Sometimes, making things worse is a valuable clue where the problem lies.
It’s stable! Now test it to be sure.
After hours of work, the circuit has been tamed. It does what it should do, and does not oscillate. Are we done? No. The circuit could be marginally stable and some change in the circuit – component drift, temperature dependence, power supply sensitivity – could send it back into oscillation. Now you need to inject a transient signal into the system and see how it responds. The degree of overshoot and ringing indicates the stability of the system – technically, the gain and phase margin. You want an overdamped or slightly underdamped response: multiple overshoots and ringing indicate that the system is dangerously close to instability. Conversely, you may find that yes, you’ve killed the oscillation, but the step response is terribly slow. So maybe you can lighten the compensation networks – usually, this means reducing a compensation capacitance somewhere.
Bode Plots, Gain and Phase Margin
It’s very useful to understand the concepts behind stability in negative feedback systems. By all means, learn how to interpret open-loop and closed loop gain plots, and how these techniques I have discussed appear on these plots. Together with a simulation, these techniques can give you a very clear idea why a given circuit is unstable.
An example: Years ago, I built a regulated power supply, using an op-amp for negative feedback. It oscillated. I tried various ad-hoc fixes and nothing worked. Finally, I consulted one of the local experts on negative feedback. His advice: You need to construct a Bode plot and engineer a solution properly. Somewhat chastised, I did as he advised. The Bode plot solution suggested a feedback capacitor and resistor of certain values. Without much hope, I installed those components in the circuit and lo, the oscillation went away.
So the ad-hoc methods I have described above are some help and can sometimes lead to a quick solution, but be prepared to do a proper analysis if they don’t work.
We recently debugged oscillation problems in a new product. The protoboard circuit oscillated and did not yeild to simple fixes, so we moved the circuit to a copper PC board. The copper board version seemed to be more stable and it was certainly easier to work on.
– an oscillating darlington transistor, cured with a resistor in the base lead. – two fast-slow feedback loops that could be tamed by slowing down the fast stage. – one power-op amp stage that (per the datasheet) required a snubbing network on the output. Simulation indicated that a noise gain network and a series RC local feedback network would be required to make it stable. That turned out to be the case. – an RC lag network that could be compensated with a lead capacitor.
Now it’s stable, and we have confidence in the circuit based on transient tests with worst-case capacitor loads attached.