TExcelTAD
Home › Control Systems & Automation › Gain and Phase Margins, Delay and the Nichols Chart

Gain and Phase Margins, Delay and the Nichols Chart

The heater block of the intro reads its temperature through a thermistor glued to the far side of the block: the sensor sees a change about 10 s10\ \text{s} late. A PI controller that was comfortable without the delay now rings, and with a little more gain it oscillates. How close to the edge is a loop, and how much delay, gain error or model error can it take before it fails? Stability margins answer that with two or three numbers that every control datasheet and tuning report quotes.

The definitions

For a stable open loop L(s)L(s) (see Nyquist for why the margins measure distance to the point −1-1):

Margin Where it is read Definition Typical target
gain margin GMGM phase crossover ωpc\omega_{pc}, where ∠L=−180∘\angle L = -180^\circ GM=1∣L(jωpc)∣GM = \frac{1}{\lvert L(j\omega_{pc}) \rvert}, or −20log⁡10∣L(jωpc)∣-20\log_{10}\lvert L(j\omega_{pc}) \rvert in dB ≥2\ge 2 (6 dB6\ \text{dB})
phase margin PMPM gain crossover ωc\omega_c, where ∣L∣=1\lvert L \rvert = 1 PM=180∘+∠L(jωc)PM = 180^\circ + \angle L(j\omega_c) 45∘45^\circ to 60∘60^\circ
delay margin gain crossover τm=PM (rad)ωc\tau_m = \frac{PM\ (\text{rad})}{\omega_c}: the extra delay that destroys the phase margin larger than any delay you cannot rule out
peak sensitivity MsM_s frequency of the peak Ms=max⁡ω∣S(jω)∣M_s = \max_\omega \lvert S(j\omega) \rvert, the inverse of the shortest distance to −1-1 1.3 to 2

The gain margin says how much the loop gain may grow (a hotter heater, a stronger motor, a wrong sensor scale) before instability. The phase margin is linked to damping: for a loop that behaves like a second-order system, ζ≈PM/100\zeta \approx PM/100 for margins up to about 60∘60^\circ, so PM=45∘PM = 45^\circ gives roughly 20–25 % overshoot and 60∘60^\circ about 10 %. MsM_s guards against both at once and against nearby "almost crossings" that the two classic margins miss.

Delay: phase lag without gain

A pure delay e−sθe^{-s\theta} has unit magnitude and phase −ωθ-\omega\theta (radians). It leaves ωc\omega_c unchanged and subtracts ωcθ\omega_c\theta from the phase margin. Sources of delay in real loops: transport (a fluid in a pipe), sensor placement (the thermistor above), sampling and computation (about 1.51.5 sample periods for a sampled controller, see Sampled-Data Loops), and communication over fieldbuses. Rational methods such as Routh cannot handle e−sθe^{-s\theta}; frequency-response margins can, exactly. python-control needs a rational approximation for time responses: ct.pade(theta, n) returns the numerator and denominator of an nn-th order Padé approximant.

Worked example: PI on the heater with a sensor delay

Given: G(s)=4 e−10s300s+1G(s) = \frac{4\,e^{-10 s}}{300 s + 1} (K/W), PI controller C(s)=Kp(1+1Tis)C(s) = K_p\left(1 + \frac{1}{T_i s}\right) with Ti=300 sT_i = 300\ \text{s} (zero on the plant pole) and Kp=3 W/KK_p = 3\ \text{W/K}.

Find: ωc\omega_c, the phase margin, the gain margin, the delay margin.

Solve: with the zero on the pole, L(s)=4Kp300se−10s=0.04se−10sL(s) = \frac{4K_p}{300 s}e^{-10 s} = \frac{0.04}{s}e^{-10 s}.

  • Gain crossover: ∣L∣=0.04/ω=1\lvert L \rvert = 0.04/\omega = 1 gives ωc=0.04 rad/s\omega_c = 0.04\ \text{rad/s}.
  • Phase there: −90∘−0.04×10 rad=−90∘−22.9∘-90^\circ - 0.04 \times 10\ \text{rad} = -90^\circ - 22.9^\circ; PM=67.1∘PM = 67.1^\circ.
  • Phase crossover: −90∘−ω⋅10=−180∘-90^\circ - \omega \cdot 10 = -180^\circ needs ωpc=π/210=0.157 rad/s\omega_{pc} = \frac{\pi/2}{10} = 0.157\ \text{rad/s}; ∣L∣=0.04/0.157=0.255\lvert L \rvert = 0.04/0.157 = 0.255, so GM=3.93GM = 3.93 (11.9 dB11.9\ \text{dB}).
  • Delay margin: 67.1∘×π/1800.04=29.3 s\frac{67.1^\circ \times \pi/180}{0.04} = 29.3\ \text{s}. The loop tolerates the sensor being up to about 39 s39\ \text{s} late in total.

Check: the figure marks both margins; the program computes them on a dense frequency grid with the exact delay and compares with python-control on a Padé model.

-40 -20 0 20 40 |L| dB 0.001 0.01 0.1 1 -90 -180 -270 -360 w rad/s phase deg PM 67 deg GM 11.9 dB 0.040 rad/s 0.157 rad/s
python · try it yourself
import numpy as np
import control as ct

Kp, Ti, theta = 3.0, 300.0, 10.0
w = np.logspace(-4, 0, 200001)
L = Kp * (1 + 1 / (1j * w * Ti)) * 4 * np.exp(-1j * w * theta) / (300j * w + 1)
ic = np.argmin(abs(abs(L) - 1))
ph = np.unwrap(np.angle(L))
ip = np.argmin(abs(ph + np.pi))
pm = 180 + np.degrees(ph[ic])
print(f"exact delay : w_c = {w[ic]:.4f} rad/s, PM = {pm:.1f} deg, "
      f"w_pc = {w[ip]:.4f} rad/s, GM = {1 / abs(L[ip]):.3f} ({-20 * np.log10(abs(L[ip])):.1f} dB)")
print(f"              delay margin {np.radians(pm) / w[ic]:.1f} s, Ms = {max(abs(1 / (1 + L))):.2f}")

num, den = ct.pade(theta, 6)
Lp = ct.tf([Kp * Ti, Kp], [Ti, 0]) * ct.tf([4], [300, 1]) * ct.tf(num, den)
gm, pmp, wpc, wgc = ct.margin(Lp)
print(f"Pade(6)     : w_c = {wgc:.4f} rad/s, PM = {pmp:.1f} deg, w_pc = {wpc:.4f} rad/s, GM = {gm:.3f}")
info = ct.step_info(ct.feedback(Lp, 1), T=np.linspace(0, 400, 8001))
print(f"closed-loop step: overshoot {info['Overshoot']:.1f} %, settling {info['SettlingTime']:.0f} s")
exact delay : w_c = 0.0400 rad/s, PM = 67.1 deg, w_pc = 0.1571 rad/s, GM = 3.927 (11.9 dB)
              delay margin 29.3 s, Ms = 1.44
Pade(6)     : w_c = 0.0400 rad/s, PM = 67.1 deg, w_pc = 0.1571 rad/s, GM = 3.927
closed-loop step: overshoot 0.1 %, settling 55 s

The closed-loop step settles in 55 s55\ \text{s} with practically no overshoot (0.1 %0.1\,\%, of which part is the Padé model's ripple); a phase margin of 67∘67^\circ is on the safe side. Raising KpK_p to 9 W/K9\ \text{W/K} would triple ωc\omega_c to 0.12 rad/s0.12\ \text{rad/s}, leave only PM=90∘−68.8∘=21.2∘PM = 90^\circ - 68.8^\circ = 21.2^\circ, and make the loop ring badly.

Intuition with the Bode lab

The Bode lab reads both margins directly. At its defaults (three poles at 1010, 100100, 1000 Hz1000\ \text{Hz}, K=20 dBK = 20\ \text{dB}): phase margin 54.9∘54.9^\circ at 77.98 Hz77.98\ \text{Hz}, gain margin 21.7 dB21.7\ \text{dB} at 333.2 Hz333.2\ \text{Hz}. Add 21.7 dB21.7\ \text{dB} of gain and the loop would sit exactly on the edge. Move the third pole down from 1000 Hz1000\ \text{Hz} (a slower sensor) and watch the phase margin shrink while the gain crossover barely moves: extra lag near crossover costs margin, just like a delay.

6040200-20-40-60-80|L| (dB)-270-180-90090100m1101001k10k100k1Mf (Hz)phase (deg)PM 54.9 degGM 21.7 dB|L| exactphase exactasymptotesunity-feedback closed loop: stable

The Nichols chart: an overview

The Nichols chart plots the open-loop response as ∣L∣\lvert L \rvert in dB (vertical) against ∠L\angle L in degrees (horizontal), with frequency as a parameter along the curve. The critical point −1-1 becomes (0 dB,−180∘)(0\ \text{dB}, -180^\circ). Its advantages: a gain change shifts the whole curve vertically without changing its shape, and a background grid of contours of constant closed-loop magnitude ∣T∣\lvert T \rvert (M-contours, the Nichols-chart images of the Nyquist-plane M-circles) and phase lets you read the closed-loop resonance peak directly. Gain margin is the vertical distance below the critical point where the curve crosses −180∘-180^\circ; phase margin the horizontal distance where it crosses 0 dB0\ \text{dB}. It was the tool of choice for hand design with graph paper; today it survives in loop-shaping tools and some drive tuning software. python-control draws it with ct.nichols_plot(L) and the grid with ct.nichols_grid().

Guided lab: measure the delay margin of the heater loop

Hand calculation. For your block, identify RthR_\text{th}, τ\tau and the sensor delay θ\theta from an open-loop step (see Model-Based Tuning). With Ti=τT_i = \tau, choose KpK_p for PM=60∘PM = 60^\circ: ωcθ=30∘=0.524 rad\omega_c\theta = 30^\circ = 0.524\ \text{rad}.

Simulation. Put your numbers into the program; check GMGM and MsM_s.

What you would measure. The 10 Ω10\ \Omega heater on a current-limited 12 V12\ \text{V} supply through a logic-level MOSFET with PWM, the thermistor or a digital sensor read by a microcontroller. Add a software delay buffer to the measurement (e.g. 0, 10, 20, 30 s) and log a setpoint step of 5 K5\ \text{K} for each. Expect the overshoot to grow with the added delay and sustained oscillation near the predicted delay margin, typically within 20 % (the thermal model is only first order plus delay). The oscillation period at the limit is about 2π/ωc2\pi/\omega_c.

Hazards and safe setup. The resistor and block get hot (keep the setpoint at or below 60 ∘C60\,^\circ\text{C}, mount on a heat-resistant base, add a thermal fuse or a software cut-off at 70 ∘C70\,^\circ\text{C}), current limit about 1.5 A1.5\ \text{A}, never unattended.

Pitfalls

  • Quoting a gain margin for an unstable open loop: margins assume P=0P = 0; use Nyquist instead.
  • Looking only at PMPM and GMGM: a loop can have both large and still pass close to −1-1 between them; check MsM_s.
  • Forgetting delays that do not appear in the model: sampling, filtering, PWM, communication.
  • Reading python-control's margin output in the wrong order: (gm, pm, w_pc, w_gc).

Practice

  1. L(s)=2se−0.2sL(s) = \frac{2}{s}e^{-0.2 s}. Find ωc\omega_c, PMPM and the delay margin.
  2. A loop has ωc=50 rad/s\omega_c = 50\ \text{rad/s} and PM=50∘PM = 50^\circ. A digital controller adds 3 ms3\ \text{ms} of delay. What is the new phase margin?
  3. On a Nichols chart, how does doubling the controller gain move the curve?
Answer
  1. ωc=2 rad/s\omega_c = 2\ \text{rad/s}; PM=90∘−0.4 rad=90∘−22.9∘=67.1∘PM = 90^\circ - 0.4\ \text{rad} = 90^\circ - 22.9^\circ = 67.1^\circ; delay margin 1.171/2=0.585 s1.171/2 = 0.585\ \text{s} (on top of the 0.2 s0.2\ \text{s}).
  2. 50×0.003=0.15 rad=8.6∘50 \times 0.003 = 0.15\ \text{rad} = 8.6^\circ: PM=41.4∘PM = 41.4^\circ.
  3. Up by 6.0 dB6.0\ \text{dB}, shape unchanged.

Test yourself

The phase margin is measured at

  1. the frequency where ∠L=−180∘\angle L = -180^\circ
  2. the frequency where ∣L∣=1\lvert L \rvert = 1
  3. zero frequency
  4. the closed-loop bandwidth

A loop with ωc=0.04 rad/s\omega_c = 0.04\ \text{rad/s} and PM=67∘PM = 67^\circ tolerates how much extra delay?

  1. about 1.7 s
  2. about 29 s
  3. about 67 s
  4. unlimited

Why can't Routh–Hurwitz analyse a loop with a pure delay exactly?

  1. delays are unstable
  2. e−sθe^{-s\theta} is not a rational function, so there is no finite characteristic polynomial
  3. delays have no frequency response
  4. Routh only works for first-order systems

On the Nichols chart the critical point is

  1. (0 dB,0∘)(0\ \text{dB}, 0^\circ)
  2. (0 dB,−180∘)(0\ \text{dB}, -180^\circ)
  3. (−3 dB,−90∘)(-3\ \text{dB}, -90^\circ)
  4. the origin of the complex plane