Why trade time for frequency
Push a child on a swing and you already know the deepest fact in control theory: timing is everything. Push in rhythm with the swing's natural motion and tiny shoves build huge arcs; push a beat late and you fight the child to a stop. The swing does not care how *hard* you push so much as *when* — the phase of your push relative to the swing's own oscillation. A feedback loop is exactly that swing, and instability is exactly the case where the loop's own delayed correction arrives at the worst possible moment and reinforces the very wobble it was meant to kill.
In rung 3 you watched a stable loop settle and an unstable one blow up by reading its step response — kick it once, watch the wiggle. That view is honest but blunt: a step crams every frequency in at once, so the answer is a tangle. The frequency domain unpicks the tangle by asking a cleaner question. Instead of one kick, feed the loop a *pure sine* of frequency ω, wait for the transient to die, and measure two numbers: by what factor did the amplitude grow or shrink (the gain), and by how many degrees did the output lag the input (the phase). Sweep ω from slow to fast and you have the system's complete fingerprint — its frequency response.
Reading a Bode plot
Hendrik Bode, working at Bell Labs in the 1930s on the feedback amplifiers that made long-distance telephony possible, faced a practical nightmare: gains spanning a millionfold and frequencies spanning a billionfold, impossible to graph on ordinary paper. His fix was two clever choices that we still use untouched. Plot gain in decibels — 20·log₁₀|G| — so a thousandfold range collapses to a readable 60 dB. And plot frequency on a logarithmic axis so each decade (×10) takes equal space. On those axes a miracle happens: the curves become nearly straight lines, and you can *sketch* a Bode plot by hand from the poles and zeros alone.
The whole sketching trick rests on one rule: each pole bends the gain slope down by 20 dB/decade at its corner frequency, and each zero bends it up by 20 dB/decade. Phase moves too, but spread over two decades around the corner: a pole drags phase toward −90°, a zero pushes it toward +90°. Memorise the asymptotes below and you never need a computer to know the shape.
Bode asymptotes for G(s) = 100 / [ s (1 + s/10) ]
(an integrator + one pole at omega = 10 rad/s)
GAIN (dB) slope
40 |*** .
| *** .
20 | *** (integrator: -20 dB/dec) . -20
| *** .
0 |--------------***---- 0 dB crossing ---.------ <- wgc ~ 31 rad/s
| **** .
-20 | pole at 10 -> **** (-40 dB/dec). -40
|__________________________****________.________ w (log)
1 10 100 1000
PHASE (deg)
-90 |******** (integrator alone)
| *****
-135 | **** <- here at wgc
| *****
-180 | ******** (pole fully kicked in)
|__________________________________________ w (log)
1 10 100 1000Gain margin and phase margin: how close to the edge
Now the payoff. The catastrophe a feedback loop must avoid is the loop gain hitting exactly 1 in magnitude and exactly −180° in phase at the same frequency. At that point the fed-back correction comes around perfectly inverted and perfectly sized — it adds to the error instead of cancelling it, and the loop sings a self-sustaining oscillation forever. Stability margins simply measure your *distance* from that fatal point, along each axis separately.
Phase margin (PM) asks: at the gain crossover ω_gc — where gain is already 1 — how many degrees of *extra* phase lag could I add before phase reaches −180°? It is literally 180° plus the actual phase at ω_gc. Gain margin (GM) asks the dual question: at the phase crossover ω_pc — where phase is already −180° — how many more decibels could I crank the gain before it reaches 0 dB? Both are buffers. A loop with PM = 45° and GM = 12 dB can tolerate a surprising amount of unmodelled delay or component drift before it goes unstable. These two numbers, gain margin and phase margin, are the single most-quoted figures in a control review.
Same example: G(s) = 100 / [ s (1 + s/10) ]
Gain crossover wgc ~ 31 rad/s (|G| = 0 dB here)
phase at wgc = -90 (integrator) - 72 (pole) = -162 deg
PHASE MARGIN = 180 - 162 = +18 deg <- thin!
Phase crossover wpc : phase = -180 deg
for this 2nd-order-ish loop, |G| -> 0 only as w -> inf
so GAIN MARGIN is technically infinite here.
Healthy targets for a servo / power loop:
Phase margin : 45 deg to 60 deg
Gain margin : 6 dB to 12 dB (a factor of 2x to 4x)
PM = 18 deg means: ringy, oscillatory, fragile.
Add a compensator to push PM up to ~50 deg.When Bode lies: the Nyquist criterion
Margins read off a Bode plot work beautifully for the well-behaved loops you meet most days — but they quietly assume the open loop is itself stable and that the gain crosses 0 dB exactly once. Break either assumption and Bode can hand you a confident, *wrong* answer. The cure is Harry Nyquist's 1932 criterion, a rigorous test that never lies because it counts something topological rather than eyeballing a curve. The Nyquist criterion is the bedrock the whole field stands on.
The idea is startlingly geometric. Take the open-loop transfer function L(s) and evaluate it as s travels once around the entire right half of the complex plane — effectively up the whole jω axis and back. As s makes that loop, the value L(s) traces its own closed curve in the complex plane: the Nyquist plot. The decisive question is how many times that curve encircles the point −1 (the fatal gain-1, phase-180° point). The counting rule is exact and unforgiving:
Nyquist stability criterion
Z = N + P
P = number of OPEN-loop poles in the right half-plane
(unstable poles you start with)
N = number of CLOCKWISE encirclements of the -1 point
by the Nyquist plot of L(s)
Z = number of CLOSED-loop poles in the right half-plane
*** The closed loop is STABLE if and only if Z = 0 ***
So you need: N = -P
(anticlockwise encirclements must cancel the unstable
open-loop poles exactly).
Special easy case: if the open loop is stable (P = 0),
the loop is stable <=> the curve does NOT encircle -1.Here is the worked case that shows why Nyquist outranks Bode. Suppose your open loop is *already unstable* — it has P = 1 pole in the right half-plane, perhaps an inverted pendulum or a magnetic-levitation rig you are trying to balance. A naive Bode reading sees gain crossing 0 dB with some positive phase margin and pronounces it stable — dead wrong. Nyquist demands Z = N + P = 0, so you need N = −1: the plot must encircle −1 *once anticlockwise*. If it does, the unstable open-loop pole is tamed and the closed loop is stable; if the curve instead misses −1 entirely, Z = 1 and your levitating magnet slams into the rail. Bode simply cannot see this; Nyquist makes it obvious.
Reshaping the curve: lead and lag compensators
Suppose your analysis returns the verdict we dreaded: phase margin only 18°, ringy and fragile. You do not throw the design away — you *reshape* the frequency response with a small filter inserted into the loop, a compensator. Think of it as a tailor taking in the curve right where it matters, lifting phase here, cutting gain there, leaving the rest alone. Two classic shapes cover most needs, and they are duals of each other.
- Lead compensator — a zero placed below a pole, C(s) = (1 + s/ω_z)/(1 + s/ω_p) with ω_z < ω_p. It injects a *bump of positive phase* (up to ~+60°) in a chosen band. Park that bump right at the gain crossover and the phase margin jumps — directly cutting overshoot. The cost: it also lifts high-frequency gain, so it amplifies sensor noise. It is the speed-and-stability tool.
- Lag compensator — a pole placed below a zero, the mirror image. It *cuts gain* at low-to-mid frequencies, which slides the gain crossover ω_gc down to a frequency where the loop's own phase is already healthier, buying back phase margin indirectly. Bonus: the extra low-frequency gain crushes steady-state error. The cost: it slows the loop down. It is the accuracy-and-smoothness tool.
- Lead-lag — bolt both together when you need it all: the lag section nails low-frequency accuracy, the lead section restores phase margin at crossover. This is, in spirit, exactly what a tuned PID controller does — its derivative term is a lead, its integral term a lag.
Fixing the PM = 18 deg loop with a LEAD compensator
Before: L(s) = 100 / [ s (1 + s/10) ]
wgc ~ 31 rad/s, phase = -162 deg, PM = 18 deg
Lead: C(s) = (1 + s/15) / (1 + s/60)
peak phase boost ~ +37 deg, centred near 30 rad/s
After: L'(s) = C(s) * L(s)
phase at wgc lifted by ~+32 deg
NEW PM ~ 18 + 32 = ~50 deg <- healthy
Time-domain payoff (rung-3 link):
overshoot ~45% -> ~16%
settling much faster, far less ringingThis is the loop-shaping mindset that defines the professional designer. You no longer hunt for poles one at a time; you stand back, read the Bode plot as a *shape*, decide where it needs more phase and where it needs less gain, and drop in the compensator that bends the curve there — all while watching gain and phase margin like a pilot watches altitude. The same logic scales up to the modern robust-control methods (H-infinity, μ-synthesis) that fly aircraft and stabilise hard-disk read heads: every one of them is, underneath, a disciplined way of keeping the loop a safe distance from the point −1.