Guidance, Navigation and Control · Theory · M3
M3-T4 — The Nyquist Criterion and Stability Margins
Closing a loop can destabilize it. The Nyquist plot says whether it will, and how close to the edge it is, from the open loop alone.
A stable controller on a stable plant can make an unstable loop, and an unstable plant can be made stable. The test is the Nyquist criterion: draw the open-loop frequency response as a curve in the complex plane and count how many times it goes round the point −1. This lesson states the criterion, shows how to apply it to Hopper's unstable pitch loop, and defines the three margins that say how much error in gain, phase or delay the loop can take before it fails. Of the three, the delay margin is the one that most often decides a real design.
Learning objectives
After this lesson, you should be able to:
- State the Nyquist criterion and apply it to a loop with an unstable open-loop pole.
- Read the gain margin, the phase margin and the delay margin from a loop's frequency response.
- Compute the delay margin from the phase margin and the crossover frequency.
- Relate the margins to the peak of the sensitivity function.
The intuition
The closed loop of M3-T2: What Feedback Buys and What It Costs has the characteristic equation . It is unstable if that equation has a root in the right half-plane. The Nyquist criterion counts such roots without finding them, using the frequency response of from the last lesson.
Why the point −1
The loop is closed with negative feedback. A signal that goes once round the loop comes back multiplied by . If, at some frequency, , the signal comes back unchanged: it feeds itself, and a sinusoid at that frequency can sustain itself with no input. That is the edge of instability. So the point in the complex plane is critical, and the question is how the curve is placed relative to it.
The criterion
Draw for from to . The negative frequencies give the mirror image of the positive ones, so the curve is symmetric about the real axis and closed. Count how many times it goes round .
- If the open loop is stable, the loop is stable if the curve does not go round .
- If the open loop has unstable poles, the closed loop is stable only if the curve goes round counterclockwise exactly times. The feedback has to supply the encirclements that the unstable poles would otherwise deny.
Hopper's pitch axis has one unstable pole, so the Nyquist plot of the pitch loop must encircle once counterclockwise. The figure shows that it does.
Margins: how far from the edge
A stable loop is not necessarily safe. A real plant differs from its model, and the question is how large a discrepancy the loop can take. Three numbers answer it, each reading a different part of the curve.
- The gain margin is the factor by which the loop gain could change before the curve passes through −1 on the real axis. It guards against a wrong gain, such as a loss of authority.
- The phase margin is the extra phase lag that would make the curve pass through −1 at the crossover. It guards against lags that were not in the model.
- The delay margin is the pure time delay that would do the same. A delay of adds a lag of , so the delay margin is the phase margin divided by the crossover frequency. It guards against computation, sensor and communication delays, and is the margin that real systems violate most often.
Hopper's loop has a phase margin of 55.5° at 6.07 rad/s, a delay margin of 0.160 s, and a lower gain margin of −30 dB. What each of these numbers means, and how to compute them, is the subject of the rest of the lesson.
The Nyquist plot answers one yes-or-no question (does the loop go round −1 the right number of times?) and the margins answer the question that matters in practice: how far from −1 does it pass, in gain, in phase and in time?
Definitions
- Nyquist plot
- The curve traced by in the complex plane as goes from to .
- Encirclements
- The net number of times the curve goes round , counted clockwise as positive.
- Open-loop unstable poles
- The number of poles of in the right half-plane. For Hopper's pitch loop, .
- Phase margin
- The angle between the curve at the crossover (where ) and the negative real axis: .
- Gain margin
- The factor by which the gain can be changed before the loop reaches the critical point: at the frequency where the phase is −180°. A loop with an unstable pole also has a lower margin: how far the gain can fall.
- Delay margin
- The largest added time delay that keeps the loop stable.
The Nyquist criterion relates three counts. The number of right-half-plane poles of the closed loop is:
The delay margin follows from the phase margin and the crossover frequency, since a delay changes only the phase:
The peak of the sensitivity bounds how small the phase margin can be:
Derivation: the criterion, the delay margin and the sensitivity peak
The Nyquist criterion is an application of the argument principle of complex analysis. The idea fits in four lines.
The closed-loop poles are the roots of the characteristic equation . The closed loop is stable when none of them is in the right half-plane.
The argument principle says that as goes round the boundary of the right half-plane (the imaginary axis closed by a large semicircle), the function goes round the origin once clockwise for every zero inside and once counterclockwise for every pole inside. The zeros of are the closed-loop poles , its poles are the open-loop poles .
Shifting a curve by 1 does not change how many times it goes round a point: going round the origin by is going round by .
Write the count as , the clockwise encirclements of −1 by . On the large semicircle is almost zero for any proper loop, so only the imaginary axis contributes, and that is the Nyquist plot.
The delay margin
A delay multiplies the loop by , which has magnitude 1: it does not move the gain crossover, only the phase.
The delay makes the curve pass through −1 when the phase at the crossover has fallen to −180°. This is the delay margin (with PM in radians).
The sensitivity peak and the phase margin
The sensitivity is the reciprocal of the distance between the curve and the critical point.
At the crossover lies on the unit circle at an angle PM from the negative real axis. Its distance to −1 is the chord of that angle.
The closest approach cannot be farther than the crossover point, so the peak of the sensitivity is at least the reciprocal of that chord. A phase margin of 30° forces ; one of 60° only .
The delay margin is the phase margin in time: PM divided by the crossover frequency. It is usually the smallest of the three margins that matters, because the phase margin shrinks and the crossover rises as a design gets faster.
A worked example
Find the margins of Hopper's pitch loop with its servo, , and check each by an independent calculation.
- Crossover and phase margin. Scan the frequency for : it happens at 6.07 rad/s. The phase there is −124.5°, so the phase margin is 55.5°, and the delay margin is s.
- Count encirclements. The open loop has one pole at +0.7, so . For gain factors of 0.05 and above, the Nyquist plot goes round −1 once counterclockwise (), so : stable. For 0.01 and 0.02 there is no encirclement, : unstable. The count matches the actual roots of in every case.
- Gain margin. Scanning with the exact roots, the loop is stable from up. The lower margin is therefore dB: the gain can fall to 3% before the divergence of the pitch axis wins. The proportional gain is and must exceed , so the exact lower limit is .
- The upper margin. There is none to find. With an ideal derivative the phase approaches −180° at high frequency and never crosses it, so the gain can be raised indefinitely in the model. The model does not include the delay that a real loop has, which is why the delay margin is the stricter measure.
- Check the delay margin by brute force. Add a delay to the loop and search for the largest one for which the Nyquist count still gives : 0.160 s, the same as to the digits shown.
- Compare with the sensitivity peak. The bound is , and the loop's peak is 1.16, above it as it must be.
import cmath, math
import gnckit as g
b, lam, wn, zeta = 19.62, 0.7, 4.0, 0.7
Kd, Kp = 2 * zeta * wn / b, (wn ** 2 + lam ** 2) / b
den = g.poly_mul([1, 0, -lam ** 2], [1 / 40, 1])
def loop(k=1.0, delay=0.0):
return g.TF([k * b * Kd, k * b * Kp], den, delay)
L = loop()
ws = g.logspace(-2, 3, 20000)
wgc = [ws[i] for i in range(len(ws) - 1) if (abs(L.freq(ws[i])) - 1) * (abs(L.freq(ws[i + 1])) - 1) < 0][0]
pm = 180 + math.degrees(cmath.phase(L.freq(wgc)))
print(f'gain crossover {wgc:.2f} rad/s, phase margin {pm:.1f} deg, delay margin {math.radians(pm) / wgc:.3f} s')
print('open-loop unstable poles P =', sum(1 for p in L.poles() if complex(p).real > 0))
print('gain k N (clockwise) Z = N + P closed-loop poles in the right half plane')
for k in (0.01, 0.02, 0.05, 0.5, 1.0, 50.0):
Lk = loop(k)
truth = sum(1 for r in g.poly_roots(g.poly_add(Lk.den, Lk.num)) if complex(r).real > 0)
print(f'{k:6.2f} {g.nyquist_encirclements(Lk):8d} {g.closed_loop_unstable_poles(Lk):10d} {truth:6d}')
ks = [10 ** (i / 100) for i in range(-400, 401)]
stable = [k for k in ks if all(complex(r).real < 0 for r in g.poly_roots(g.poly_add(L.den, [k * c for c in L.num])))]
print(f'stable for gains from {min(stable):.4f} ({20 * math.log10(min(stable)):.1f} dB) up to at least {max(stable):.0f} (the largest tried)')
lo, hi = 0.0, 1.0
for _ in range(30):
mid = (lo + hi) / 2
lo, hi = (mid, hi) if g.closed_loop_unstable_poles(loop(1.0, mid)) == 0 else (lo, mid)
print(f'largest added delay that keeps it stable (Nyquist search): {lo:.3f} s')gain crossover 6.07 rad/s, phase margin 55.5 deg, delay margin 0.160 s open-loop unstable poles P = 1 gain k N (clockwise) Z = N + P closed-loop poles in the right half plane 0.01 0 1 1 0.02 0 1 1 0.05 -1 0 0 0.50 -1 0 0 1.00 -1 0 0 50.00 -1 0 0 stable for gains from 0.0302 (-30.4 dB) up to at least 10000 (the largest tried) largest added delay that keeps it stable (Nyquist search): 0.160 s
In robotics
Margins are the common currency of control reviews, and the criteria are written in them.
- Requirements. Flight control requirements are commonly written as a minimum gain margin and phase margin, for example 6 dB and 45°, evaluated at every flight condition and often at each actuator, and a loop that meets them has a modest sensitivity peak (about 1.5 to 2 or below). They are measured on the loop broken at a chosen point, usually the actuator input.
- Delay margin in practice. A multirotor's attitude loop has a delay margin of a few tens of milliseconds; a software change that adds a 20 ms filter or a slower bus can turn a stable vehicle into an oscillating one. Timing budgets, the subject of UAV M7-T6: End-to-end latency, are budgets against the delay margin.
- Unstable plants. For Hopper's pitch loop the critical point is approached from two sides: too little gain and the divergence wins (the lower margin of −30 dB), too much lag and the loop oscillates. The window shrinks as the delay grows, which the next lesson turns into a limit of performance.
- Measuring margins. Margins can be measured on the real vehicle: inject a small sinusoid into the loop, record the response, and read the loop gain and phase at each frequency. Flight tests do this with sweeps before every envelope expansion.
- Tools.
margins,nyquist_encirclementsandclosed_loop_unstable_polesingnckitcompute them, and python-control'sstability_marginsandnyquist_plotdo the same. For loops with unstable poles use the encirclement count, since the simple rule of reading the margin from the crossing can be misleading.
Hopper's lab on this lesson, M3-L1: Rescue the Phase Margin, lets you break the loop of a heavier vehicle and measure its margins before fixing them.
Common misconceptions
“If the loop is stable, it is safe.”
A loop can be stable with a phase margin of 3°, which means that any unmodelled lag or delay destabilizes it. Stability is the yes-or-no question and the margins measure how much margin of safety there is. Hopper's loop has 55° and 0.160 s.
“An infinite gain margin means the loop cannot go unstable.”
It means that, in this model, raising the gain never makes the phase reach −180°. A real loop has delays the model lacks, and Hopper's loop with the delay margin of 0.160 s becomes unstable if a delay of that size is added, however the gain is chosen. The delay margin is the more honest number here.
“The Nyquist criterion only applies to stable plants.”
It applies to any loop, and the count includes the open-loop unstable poles. For Hopper, , and the correct picture has one counterclockwise encirclement. Reading a plot with the rule for stable plants says the loop is unstable when it is not.
“Phase margin by itself guarantees robustness.”
It measures only the phase at one frequency. A loop can have a good phase margin and a curve that passes close to −1 at another frequency, which the sensitivity peak reveals. Check the margins and the peak of together.
“The margins at one operating point hold throughout a flight.”
They change with the plant. Hopper's authority falls 40% over a flight, which scales the loop gain by 0.6 and moves the crossover. The margins must be checked at every trim point, or the design must be scheduled so that they are the same.
Key takeaways
- The loop is unstable if the closed-loop characteristic equation has a root in the right half-plane; the Nyquist criterion counts such roots from the frequency response: .
- With unstable open-loop poles, a stable loop needs counterclockwise encirclements of −1. Hopper's pitch loop has and one encirclement.
- The phase margin is the angle from −180° at the crossover, the gain margin the factor to −1 on the real axis, and the delay margin in seconds.
- Hopper's loop: crossover 6.07 rad/s, phase margin 55.5°, delay margin 0.160 s, lower gain margin −30 dB, with no upper limit in the model.
- The sensitivity peak satisfies , so a small margin means a high peak.
- Check the margins at every operating point, and prefer the delay margin as the measure of how much unmodelled lag the loop can take.
References and further reading
Each source is marked free or paid. Free to read does not mean free to reuse: the course resources page lists every source with its licence.
- K. J. Åström and R. M. Murray, Feedback Systems, 2nd edition, Princeton University Press, 2021 , the chapter on frequency domain analysis, with the Nyquist criterion and margins. Free to read as the authors' PDF; the book is copyrighted.
- B. Douglas, “Nyquist Stability Criterion” (video series) . A visual introduction to the criterion and the margins. Free to watch.
- J. How and E. Frazzoli, MIT 16.30 Feedback Control Systems (OpenCourseWare) , the lectures on the Nyquist criterion and margins. Free; licence CC BY-NC-SA 4.0.
- Python Control Systems Library documentation , the functions
nyquist_plotandstability_margins. Free; BSD licence.
Knowledge check
Three questions. Write an answer, then reveal the explanation. Your answers stay in your browser.
Question 1
Hopper's loop has a phase margin of 55.5° at a crossover of 6.07 rad/s. The sensing, computing and actuation delays total 30 ms. By what factor is the delay margin larger than the delay, and what does a 0.2 s delay do?
Explanation
The delay margin is 0.9686 rad / 6.07 rad/s = 0.160 s, which is 0.160 / 0.030 = 5.3 times the 30 ms delay: a comfortable ratio (a common aim is at least 2 to 3). A 0.2 s delay exceeds the margin, so the loop goes unstable: at the crossover the delay adds 6.07 × 0.2 = 1.21 rad = 69.6° of lag, more than the 55.5° available, and the curve passes through the critical point.
Question 2
The loop of the example is stable for gains from 0.030 times its design value upwards. A fault cuts the pitch authority to 3% of its design value. What happens, and why does a loss of gain destabilize a loop?
Explanation
At 3% the gain is at the lower limit and the loop is on the edge of instability; below it the loop is unstable. The reason is that the plant is unstable: the proportional gain must supply a restoring moment larger than the destabilizing aerodynamic moment (Kp b > λ²). If the gain falls below λ²/(Kp b) = 0.0297 of its design value, the divergence wins. This is the lower gain margin, and only loops with unstable open-loop poles have one.
Question 3
For a gain of 0.02 times the design value, the Nyquist plot makes no encirclement of −1 and the plant has one unstable pole. Is the closed loop stable, and what is the number of unstable closed-loop poles?
Explanation
It is unstable. By the criterion Z = N + P = 0 + 1 = 1, so there is one closed-loop pole in the right half-plane. The loop would need one counterclockwise encirclement (N = −1) to be stable, since the one unstable open-loop pole has to be balanced. The exact roots of the characteristic polynomial confirm it: for gains of 0.02 there is a real root in the right half-plane, which is the pitch divergence that the too-weak controller fails to overcome.
What’s next
Related content
Nothing below is required to finish this lesson.
- BeforeM3-T3: Frequency Response and Bode Plots
Sketch the Bode plot of a transfer function from its poles and zeros, and read bandwidth and steady-state error from it.
- LabM3-L1: Rescue the Phase Margin
Hopper's pitch loop rings after a heavier engine was fitted. Measure the margins from the open-loop response and add a lead compensator that restores 45 degrees and 6 dB.
Other courses on this site treat neighbouring topics from their own angle:
- Lab: Tune a PID Controller
- Lab: Fix the Oscillating Robot
- UAV M5-T6: PID controllers
- UAV M7-T6: End-to-end latency
This course leaves the following to the pages that already teach them:
Get notified when the next lesson and new labs are released.
One email per new lesson or lab.