Closed loop systems can have stability issues, meaning that the system has the tendency to start oscillating or to overshoot with sudden changes of the input parameter.
The "Barkhausen criterion" for sustained oscillation of a closed loop system is that the oscillation will occur at the frequency where the phase around the loop is 0 (or 360) degrees and the loop gain is equal to or higher than 1.
Note that we are talking about the phase around the loop and the loop gain. This is not the same as the closed loop gain and phase.
The image below shows a closed loop system with an amplifier having gain A, which is typically very big, and feedback with transfer function F.
The closed loop gain (transfer function) is shown:
To investigate the stability of a closed loop system, we need to check if the loop gain (A * F) gets close to -1, indicating that the system will be unstable when closing the loop. To be able to check the loop gain, we need to break the closed loop open and input the signal directly into the amplifier and check the output at the feedback point. The ratio between this output and input gives us the loop gain (A * F) that we are interested in.
Breaking the loop and inserting a signal is not always a good idea because it can change the DC operating point and influence the behavior of the circuit.
To investigate the loop gain (A * F) and check if it gets close to -1, we can choose between 2 different approaches:
Do an AC analysis of the loop gain (A * F), where we investigate both the loop gain and phase over the whole frequency range using Bode plots. For this AC analysis, the closed loop system needs to be broken open and an AC voltage source is placed in between the amplifier input and the feedback node.
Using the bode plot, we check at which frequency the gain becomes 0dB = 1x. At this frequency, the phase should be at least 45 degrees. So when closing the loop using negative feedback adding -180 degrees, the phase should be at least 45 degrees less than -180 degrees, being >= -135 degrees.
These 45 degrees phase around the loop, when the loop gain = 0dB, is called the phase margin (PM).
It prevents that the Barkhausen criterion is met (gain >= 0dB and phase =0).
Using the bode plot, we check at which frequency the phase around the loop becomes 0 degrees. This will result in a -180 degrees phase when the loop is closed. At this frequency, we check the loop gain. The loop gain should be lower than 1x, so lower than 0dB). Typically a gain margin of 6 to 10dB is used, so the loop gain should be -6 to -10 dB at the frequency where the phase around the loop becomes 0 degrees.
It prevents that the Barkhausen criterion is met (gain >= 0dB and phase =0).
Do a transient analysis of the closed loop circuit while injecting a square wave signal at the input of the circuit and checking for oscillatory tendency at the output of the circuit. In fact, we bang on the door of the circuit to check if we see a tendency of oscillation at the output in the form of damped oscillations or overshoots. Damped oscillations or overshoots indicate that the circuit is unstable or at the edge of instability. Temperature variations or component tolerances could push the circuit over the edge.
Below is an example of a closed loop system in the form of a buffer implemented with an OPAMP. The OPAMP has a capacitive load of 33nF directly connected to the output. OPAMP's don't like capacitive loads, because the extra pole in the open loop gain reduces the phase and gain margin, causing instability, as we will see further.
Let's first do an AC analysis of the OPAMP in open loop, so without feedback. This gives us the Bode plot of the gain and phase of the OPAMP over the whole frequency range.
The easiest way to do an AC analysis on a circuit is using a simulator like LTSpice, because not everyone can afford an expensive network analyser to analyse the actual circuit. You could do this with a function generator and an oscilloscope, by manually finding the frequency at which the gain becomes 1x (0 dB) and checking the phase between in and output at that frequency.
But for the sake of study, I'll show you how to do it with LTSpice.
The image below shows the AC analysis of the OPAMP in open loop, with the Bode plot of the gain and phase.
P.S.: When checking the datasheet of the LT1006 OPAMP, the bode plot of the gain corresponds with the one in the datasheet, but the phase plot doesn't. Not sure why that is. I tried different ways of applying the AC source, biasing the OPAMP inputs and loading the output, but I didn't manage to get the same phase plot as in the datasheet. Maybe it is a limitation of the model in LTSpice?
The OPAMP, without feedback, cuses a phase shift of ca. 42 degrees at a frequency of ca. 584kHz, where the gain = 1x (0 dB).
This means that the phase margin is close to the required 45 degrees, so the circuit will be stable when the loop is closed.
So far, so good.
Now let's see what happens to the open loop gain and phase when we add a capacitive load of 33nF directly at the output of the OPAMP.
With the capacitive load added to the output of the OPAMP, the open loop phase at 0dB is close to 0 degrees at a frequency of ca. 194kHz.
So the phase margin is ca. 0 degrees. This means that when closing the loop using negative feedback, the closed loop phase for a frequency of 194kHz will be -180 degrees with a gain of 1x (0dB). So the Barkhausen criterion for oscillation is met.
As we discussed before, we can also use the transient analysis of the closed loop circuit in LTSpice to check the stability of the circuit. Therefor we inject a 1kHz square wave signal into the circuit and check the output for oscillatory tendency.
The image below shows the transient analysis of the closed loop circuit output signal while inputting a square wave signal of 1kHz with 50% duty cycle. The output signal shows significant damped oscillations, so the circuit is very close to sustained oscillation and not really stable.
The next image zooms in on the oscillations, so we can measure the frequency using the cursors in the LTSpice plot:
The frequency of the oscillatons is ca. 191 kHz.
Previously, the AC analysis of the open loop OPAMP + capacitive load showed us that at a frequency of ca. ca. 194kHz, the loop phase got very close to 0 degrees while the gain = 1x (0dB). This frequency at which the system becomes unstable, corresponds with the frequency of the oscillations seen in the transient analysis. This verifies that the AC analysis makes sense.
To compensate the circuit and kill the oscillations, we need to create more phase margin in the loop gain at gain = 1x (0dB) to get further away from the danger zone. This is accomplished by adding a series resistance between the OPAMP output and the capacitive load to isolate the OPAMP output from this load. Additionally, an extra split feedback network is added with a capacitor and a resistor.
The image below shows the transient analysis of the circuit including the compensation network while inputting a 1kHz symmetrical square wave signal. In the transient analysis of the circuit with compensation, the output doesn't show any oscillations anymore:
Let's do an AC analysis and check the loop gain of the OPAMP including the feedback with compensation to see the difference.
In order to do an AC analysis of the loop gain, we need to break open the loop and insert our AC signal in between the feedback node and the input of the amplifier. The ratio between the voltage at the feedback node (Vfb) and the voltage at the input of the amplifier (Vin) gives us the transfer function of the loop = loop gain (A * F). In the bode plot, we check if the phase margin at gain = 1x (0db) is larger than 45 degrees, so the circuit will be stable when closing the loop using negative feedback (= adding -180 degrees of phase shift).
The AC analysis shows that the phase at gain = 1x (0dB) is 54 degrees at a frequency of 256 kHz.
So, due to the compensation network, the gain margin has changed from 0 degrees (unstable) to 54 degrees (stable).
When closing the loop, the circuit will be stable, as shown before by the transient analysis on circuit in closed loop.