The purpose of frequency compensation in an amplifier with negative feedback is to prevent there being an excess phase lag round the feedback loop which reaches 180 deg. at the frequency where the gain round the feedback loop has fallen to unity. If this does occur the amplifier will theoretically have infinite closed-loop gain at that frequency, and will almost certainly oscillate. In practice the unity loop gain frequency is not fixed, it is a function of the load impedance the amplifier is driving, and also it can vary over a wide range when close to amplitude clipping, close to slew rate limiting, and when switching on or off. The phase shift is not determined only by the frequency compensation, it also depends on the load, and for amplifier designers this is one of the most difficult problems because we have no control over what sort of load will be connected.
Even if the conditions for oscillation are not exactly met there needs to be a safety margin, otherwise there may be other undesirable effects such as a peak in the closed-loop gain. If the feedback causes an increase in gain then it is by definition positive feedback. The feedback is not necessarily positive just because the phase lag reaches 180 deg. if the loop gain is still high, but in this case the amplifier may have only 'conditional stability' because under some conditions the loop gain can fall, and unless the phase lag falls under those same conditions the amplifier can become unstable.
The simplest frequency compensation is a single -6dB per octave reduction in loop gain, which adds only 90 deg. phase lag. This is shown in blue in the following gain and phase plots. The phase is then always 90 deg. away from the 180 deg. danger area, so there is an excellent safety margin. The loop gain however is reduced more than is really necessary, and we can generally accept a lower safety margin in return for higher feedback and therefore reduced distortion. One recommendation made by H.W.Bode is sometimes quoted, to use -9dB/octave attenuation, which gives a constant 45 deg. safety margin. This result is shown in black.
Optimising the MJR7.
The optimum rate of attenuation depends on the properties of the circuit being used, for example the effect of load impedance depends on the open-loop output impedance of the amplifier, and for the MJR7 the Bode 'optimum' would limit the ability to drive the commonly used capacitive test load of 2uF, which can add further phase lag approaching 60 deg.
The MJR7 response is shown in red, and has about 15dB greater loop gain at 20kHz compared to the simpler -6dB/octave, and consequently greater distortion reduction, but still maintains a phase shift safety margin over 60 deg. Adding a 2uF load the phase lag round the feedback loop is shown in green, and it can be seen that this approaches the 0 deg. line (where the excess phase lag is 180 deg.) around 100kHz. The low margin at this frequency is not normally a problem because the loop gain is still high enough, and it will only drop close to unity near to clipping. Fortunately the use of shunt capacitance compensation in this circuit ensures that near clipping when loop gain falls the phase lag added by the compensation also falls, and so there is no serious reduction in stability margin. This is not always the case for alternative compensation methods.
Near the end of the MJR7-Mk5 test results page is a photo of the clipping response with a 2uF load, and there is no sign of instability. The test results also show the square wave output with a 2uF load, more commonly used as a test of stability, but this often just shows the effect of the output inductor resonating with the load. Some amplifiers are unstable with smaller capacitances, so a range of loads from 1nF up to 4uF need to be tried, but even then square wave testing may not show that stability is only conditional, which is why I also do the clipping test.
All three plots compared have the same unity gain frequency. In any amplifier there are additional sources of phase shift at high frequencies, some of them depending on layout and not easily predictable, so there is a practical limit to how high we can confidently set the unity gain frequency. This is why frequency compensation is often essential, to get the loop gain down to unity before these high frequency effects become a serious problem. Mosfet amplifiers can generally be made stable with a higher unity gain frequency than bipolar designs. The examples shown have unity gain at 5MHz, but the MJR7 simulation used here was a small signal linear approximation which excludes input stage effects, so in reality the unity gain is lower, around 4MHz.