---
title: Gain, phase and delay margins
heading: How far a stable loop is from instability, measured as gain margin, phase margin, delay margin and the peak sensitivity, how to read them from Bode and Nyquist plots, typical targets, and what the phase margin says about overshoot
eyebrow: S9 · Lesson 25 · Gain, phase and delay margins
xp: 50
---

::: hook
A loop that's stable on paper may not be stable on the bench: the real plant's gain drifts with temperature, a sensor adds a little delay, an unmodeled resonance adds phase lag. Margins measure how much of each the loop can absorb before it oscillates. They're the numbers on every control design review and every power-supply datasheet that quotes a loop's phase margin, and they connect the frequency-domain picture to the overshoot you'll see on a scope.
:::

::: play
- The Bode plot of $L = K/(s(s + 1)(s + 5))$, with the phase crossover marked at $\sqrt{5}$ rad/s, where the phase is −180°.
- The **gain margin** is how far the magnitude is below 0 dB there: 30/K, so 3 (9.5 dB) at K = 10.
- The **phase margin** is how far the phase is above −180° where the magnitude crosses 0 dB. Lower K and both margins grow: at K = 4 the phase margin is 49° and the gain margin 7.5.
:::

```sim plot
view: bode
x: w = 0.05..50 rad/s log
slider: K = 1..30 = 10 log
H: K/((j*w)*(j*w + 1)*(j*w + 5))
marker: x = sqrt(5) | label: phase crossover
readout: gain margin = 30/K | digits: 3
readout: gain margin, dB = 20*log(30/K) | digits: 3
```

::: predict
## The loop with K = 10 has a 25.4° phase margin at its 1.23 rad/s crossover. How much pure time delay could it tolerate before oscillating?

- [ ] About 25 ms
- [x] About 0.36 s
- [ ] About 1.4 s
- [ ] None: any delay destabilizes it

::: reveal
A delay T takes away $\omega_cT$ radians of phase at the crossover without changing the magnitude. The margin of 25.4° is 0.443 rad, so the loop can lose it all with $T = 0.443/1.227$ = 0.361 s of delay.
:::
:::

::: nameit
## The four margins

- **Gain margin** GM = $1/|L(j\omega_{180})|$, at the **phase crossover** $\omega_{180}$ where ∠L = −180°: the factor by which the gain can rise. Often quoted in decibels.
- **Phase margin** PM = 180° + ∠L(jω_c), at the **gain crossover**: the extra phase lag the loop can take.
- **Delay margin** = PM (in radians)/$\omega_c$: the extra delay the loop can take.
- **Modulus (stability) margin** $s_m = \min_\omega|1 + L(j\omega)| = 1/M_s$: the shortest distance from the Nyquist plot to −1. $M_s$ is the peak of the sensitivity $|S|$, the worst-case amplification of disturbances.

On a Nyquist plot, GM is how far inside −1 the plot crosses the real axis, PM is the angle from −1 to where the plot crosses the unit circle, and $s_m$ is the radius of the largest circle around −1 that the plot doesn't enter. A small $M_s$ guarantees both of the others:

$$\text{GM} \ge \frac{M_s}{M_s - 1}, \qquad \text{PM} \ge 2\sin^{-1}\frac{1}{2M_s}$$

## Targets

Common targets are GM ≥ 2 (6 dB), PM between 45° and 60°, and $M_s$ between 1.4 and 2. $M_s$ = 1.4 guarantees GM ≥ 3.5 and PM ≥ 41.8°; $M_s$ = 2 guarantees GM ≥ 2 and PM ≥ 29.0°.

## Phase margin and overshoot

For the standard loop $\omega_n^2/(s(s + 2\zeta\omega_n))$, PM = $\tan^{-1}\frac{2\zeta}{\sqrt{\sqrt{1 + 4\zeta^4} - 2\zeta^2}}$: 45° ↔ ζ = 0.42 (23% overshoot), 60° ↔ ζ = 0.61 (9%). Real loops roughly follow this.
:::

::: example
## Find all the margins of $L = 10/(s(s + 1)(s + 5))$.

::: solution
1. **Phase crossover.** It's at $\sqrt{5}$ = 2.24 rad/s, where
   $$|L| = 10/30$$
   so GM = 3 (9.5 dB).
2. **Gain crossover.** At 1.23 rad/s the phase is −154.6°:
   $$\begin{aligned} \text{PM} &= 180° - 154.6° \\ &= 25.4° \end{aligned}$$
3. **Delay margin.**
   $$\text{PM}/\omega_c = 0.361\ \text{s}$$
4. **Sensitivity peak.** The Nyquist plot passes closest to −1 at 1.40 rad/s, at distance 0.368, so
   $$\begin{aligned} M_s &= 1/0.368 \\ &= 2.72 \end{aligned}$$
   Disturbances near 1.4 rad/s are amplified 2.7 times.
5. **Read the margins together.** The gain margin looks fine, but the phase margin and $M_s$ show a poorly damped loop.

**Answer:** GM = 3 (9.5 dB), PM = 25.4°, a delay margin of 0.361 s and $M_s$ = 2.72.
:::
:::

::: example
## Drop the gain to K = 4. What changes?

::: solution
1. **Gain margin.** The phase crossover stays at 2.24 rad/s, so
   $$\begin{aligned} \text{GM} &= 30/4 \\ &= 7.5 \end{aligned}$$
   or 17.5 dB.
2. **Phase margin.** The gain crossover moves down to 0.66 rad/s, where the phase margin is 49.0°.
3. **Sensitivity peak.** $M_s$ falls to 1.61.
4. **Step response.** It overshoots 19% and settles in about 9.6 s.
5. **The trade.** Lower gain bought damping at the cost of speed; lesson 26 shows how a lead compensator buys both.

**Answer:** GM rises to 7.5 (17.5 dB), PM to 49.0°, and $M_s$ falls to 1.61, while the crossover drops to 0.66 rad/s.
:::
:::

::: example
## Find the margins and the sensitivity peak of $L = e^{-0.5s}/s$.

::: solution
1. **Phase margin.** Crossover is at 1 rad/s, so
   $$\begin{aligned} \text{PM} &= 90° - 0.5\ \text{rad} \\ &= 90° - 28.6° \\ &= 61.4° \end{aligned}$$
2. **Delay margin.** The loop can take 1.07 s more delay:
   $$\text{PM}/\omega_c = 1.07\ \text{s}$$
3. **Gain margin.** The phase reaches −180° where 0.5ω = π/2, at 3.14 rad/s, where |L| = 1/3.14:
   $$\text{GM} = 3.14$$
   or 9.9 dB.
4. **Sensitivity peak.** A numerical search gives $M_s$ = 1.59, a modulus margin of 0.63.
5. **Check against the bounds.** That's consistent with the bounds it guarantees: GM ≥ 2.69 and PM ≥ 36.6°.

**Answer:** PM = 61.4°, a delay margin of 1.07 s, GM = 3.14 (9.9 dB) and $M_s$ = 1.59.
:::
:::

::: check
given: K = 5 | 20 | 60; a = 1 | 2; b = 5 | 10
answer: 20*log(a*b*(a + b)/K)
unit: dB
tolerance: 0.05

## What's the gain margin of $L = \given{K}/(s(s + \given{a})(s + \given{b}))$ in decibels?

::: right
Right. At $\omega_{180} = \sqrt{ab}$, $|L| = K/(ab(a + b))$, so GM = {answer} dB.
:::

::: misses
- [a*b*(a + b)/K] That's the factor; in decibels take $20\log$.
- [-20*log(a*b*(a + b)/K)] The margin is positive when the loop is stable: $-20\log|L(j\omega_{180})|$.
- [any] Not yet. GM = $1/|L(j\omega_{180})|$.
:::
:::

::: check
given: P = 30 | 45 | 60; w = 2 | 50 | 800
answer: P*pi/180/w*1000
unit: ms
tolerance: 0.5%

## A loop has a {P}° phase margin at a {w} rad/s crossover. What's its delay margin?

::: right
Right. PM in radians over $\omega_c$: {answer} ms.
:::

::: misses
- [P/w*1000] Convert the margin to radians first.
- [any] Not yet. A delay T costs $\omega_cT$ radians.
:::
:::

::: check
given: K = 2 | 10 | 40; T = 5 | 20
answer: 90 - K*T/1000*180/pi
unit: °
tolerance: 0.5%

## A loop $L = Ke^{-sT}/s$ has K = {K} s⁻¹ and T = {T} ms. What's its phase margin?

::: right
Right. It crosses at $\omega_c$ = K, where the phase is −90° − $\omega_cT$: PM = {answer}°.
:::

::: misses
- [90] The delay costs $KT$ radians at the crossover.
- [any] Not yet. Find the crossover, then the phase there.
:::
:::

::: check
given: T = 1 | 10 | 100
answer: pi/(2*T/1000)
unit: s^-1
tolerance: 0.5%

## An integrator with a {T} ms delay in the loop, $L = Ke^{-sT}/s$. What's the largest K before it oscillates?

::: right
Right. The phase reaches −180° at $\omega = \pi/2T$, where |L| = K/ω, so K < $\pi/2T$ = {answer} s⁻¹.
:::

::: misses
- [1/(T/1000)] The phase crossover is at $\pi/2T$, not $1/T$.
- [any] Not yet. Find where $-90° - \omega T = -180°$.
:::
:::

::: check
given: M = 1.2 | 1.4 | 1.7 | 2
answer: 2*asin(1/(2*M))*180/pi
unit: °
tolerance: 0.5%

## A loop's peak sensitivity is $M_s$ = {M}. What phase margin is it guaranteed?

::: right
Right. $2\sin^{-1}(1/2M_s)$ = {answer}°.
:::

::: misses
- [asin(1/(2*M))*180/pi] Double it: the unit circle meets the circle of radius $1/M_s$ around −1 at that half-angle.
- [any] Not yet. PM ≥ $2\sin^{-1}(1/2M_s)$.
:::
:::

::: check
given: z = 0.3 | 0.5 | 0.7
answer: atan(2*z/sqrt(sqrt(1 + 4*z^4) - 2*z^2))*180/pi
unit: °
tolerance: 0.5%

## A loop $\omega_n^2/(s(s + 2\zeta\omega_n))$ has ζ = {z}. What's its phase margin?

::: right
Right. {answer}°, close to 100ζ.
:::

::: misses
- [100*z] That's the rule of thumb; use the exact formula.
- [any] Not yet. Find the crossover and the phase there.
:::
:::

::: check
kind: parts
given: M = 1.2 | 1.4 | 1.7 | 2

## A loop's sensitivity peaks at $M_s$ = {M}.

::: part
answer: M/(M - 1)
tolerance: 0.5%

### What gain margin is guaranteed, as a factor?

::: misses
- [any] $\text{GM} \ge M_s/(M_s - 1)$.
:::
:::

::: part
answer: 2*asin(1/(2*M))*180/pi
unit: °
tolerance: 0.5%

### What phase margin?

::: misses
- [any] $\text{PM} \ge 2\sin^{-1}\frac{1}{2M_s}$.
:::
:::
:::

::: check
kind: derivation
vars: K = 0.1..10, T = 0.01..1

## A loop $L = Ke^{-sT}/s$ with KT < π/2.

::: step
answer: K

### Where does it cross over?
:::

::: step
answer: pi/2 - K*T

### What is its phase margin, in radians?
:::

::: step
answer: pi/(2*T)

### Where is its phase −180°?
:::

::: step
answer: pi/(2*K*T)

### What is its gain margin, as a factor?
:::

::: right
Right. For an integrator with delay, every margin depends only on the product KT.
:::
:::

::: explain
## Why isn't a good gain margin alone enough to call a loop robust?

::: model
The gain margin only measures the distance to −1 along the negative real axis, at the one frequency where the phase is −180°. The Nyquist plot can still pass very close to −1 from another direction, for example at the gain crossover with little phase margin, and then a small change in phase, such as a little extra delay, would push it through. The loop with K = 10 above has a gain margin of 3 but only 25° of phase margin and a peak sensitivity of 2.7, so it rings and amplifies disturbances. The modulus margin, the closest approach to −1 in any direction, captures both, which is why modern designs specify $M_s$.
:::
:::

::: practice

::: check
given: K = 3 | 30; a = 0.5 | 3; b = 4 | 12
answer: 20*log(a*b*(a + b)/K)
unit: dB
tolerance: 0.05

## Gain margin of $\given{K}/(s(s + \given{a})(s + \given{b}))$ in dB?

::: misses
- [any] $20\log(ab(a + b)/K)$.
:::
:::

::: check
given: P = 35 | 55; w = 10 | 3000
answer: P*pi/180/w*1000
unit: ms
tolerance: 0.5%

## Delay margin: {P}° at {w} rad/s?

::: misses
- [any] PM in radians over $\omega_c$.
:::
:::

::: check
given: M = 1.3 | 1.5 | 1.8
answer: M/(M - 1)
tolerance: 0.5%

## Guaranteed gain margin (as a factor) for $M_s$ = {M}?

::: misses
- [any] $M_s/(M_s - 1)$.
:::
:::
:::
