# Closed loop compensator

What does it mean if you've been told to design a compensator to ensure that the closed loop phase margin is at least 120 degrees? Isn't a compensator typically designed using the open loop transfer function? Using the matlab command allmargin() for both closed loop and open loop transfer functions of the same system yields different results!

Phase margin is indeed read from an open-loop transfer function, but the rationale behind it is to prevent the closed-loop from going unstable. As you might recall: $$T(s) = \frac{GC}{1+GC}$$ Looking at this function from a mathematical viewpoint, this function explodes when $$GC = -1$$. In bode-plot terms, $$GC = -1$$ if $$|GC| = 0dB$$ and $$\angle GC = -180 \deg$$. As most dynamical systems cross this $$0dB$$ point somewhere, one should prevent the phase is anywhere close to $$-180\deg$$. Phase margin describes the distance to $$-180\deg$$ when the magnitude crosses the $$0dB$$ line.
• if you apply a gain on the open loop tf as you explained, the point where it crosses $0dB$ shifts. Therefore you need to recompute you lead compensator with the gain included. However, it could be that because of this gain, the phase margin is already 120, which means the lead compensator is not needed. – Petrus1904 Nov 27 '20 at 15:27