Designing a lead-lag compensator
About this lesson
One plant, two specs that fight: a ramp error of 0.1 (Kv = 10) and a phase margin of at least 45°. Gain alone gives the accuracy but makes the loop unstable, and lead alone falls short too. Design the lead and the lag by hand on the Bode plot, watch their decibels and degrees add, then close the loop and check the step and the ramp.
One plant, two specs
The plant is G(s) = 1/(s(s + 1)(s + 2)). We want two things at once: follow a ramp with an error of only 0.1, so Kv = 10, and a phase margin of at least 45°, so the step response stays calm.
plant G(s) = 1 / ( s (s + 1)(s + 2) )
spec 1 Kv = lim s·L(s) = 10 (s → 0)
ramp error = 1/Kv = 0.1
spec 2 phase margin ≥ 45°
Kv is set by the LOW end of the Bode plot,
the phase margin by the MIDDLE (crossover).Read the lesson step by step
One plant, two specs
The plant is G(s) = 1/(s(s + 1)(s + 2)). We want two things at once: follow a ramp with an error of only 0.1, so Kv = 10, and a phase margin of at least 45°, so the step response stays calm.
plant G(s) = 1 / ( s (s + 1)(s + 2) ) spec 1 Kv = lim s·L(s) = 10 (s → 0) ramp error = 1/Kv = 0.1 spec 2 phase margin ≥ 45° Kv is set by the LOW end of the Bode plot, the phase margin by the MIDDLE (crossover).Gain buys accuracy
Kv = lim s·K·G(s) = K/2, so K = 20 gives Kv = 10. On the Bode plot the whole gain curve lifts, and its low-frequency line K/(2ω) meets 0 dB at ω = 10. The phase curve does not move.
s·K·G(s) = K / ((s + 1)(s + 2)) → K/2 Kv = 20/2 = 10 ramp error = 0.1 ✓ low end |L| ≈ Kv/ω (−20 dB/decade) meets 0 dB at ω = Kv = 10 A pure gain lifts |L| and leaves ∠L alone.…and loses the margin
But the curve now crosses 0 dB at 2.43 rad/s, where the phase is already −208.1°. That is 28.1° past −180°: a phase margin of −28.1°. The loop would feed itself.
K·G at the crossover ωc = 2.43 rad/s |L| = 1 (0 dB) ∠L = −208.1° phase margin = 180° + ∠L = −28.1° ✗ Routh test (reads stability straight from the coefficients of s³ + 3s² + 2s + K): stable only for K < 6. We need K = 20.Close it: it runs away
Close the loop and send a unit step. The output shoots to 2.57, falls to −1.82, then climbs to 6.06: every swing is wider. Gain alone cannot meet both specs. We must reshape the middle of the curve and keep the low end.
closed loop T(s) = 20 / (s³ + 3s² + 2s + 20) turning points of y(t) t = 1.6 s y = 2.57 t = 3.0 s y = −1.82 t = 4.4 s y = 6.06 Unstable: a growing oscillation. Routh test (stability from the coefficients): stable only for K < 6.Lead: phase where needed
New crossover: 1 rad/s, where ∠G = −161.6°, a margin of only 18.4°. Want 50° after the lag, plus about 5° the lag will cost: 55 − 18.4 ≈ 37°. A lead (1 + s/0.5)/(1 + s/2) peaks at 1 rad/s with 36.9°, +6.0 dB.
lead (1 + s/0.5) / (1 + s/2) zero below pole ratio α = 0.5/2 = 0.25 centre ω = √(0.5·2) = 1 rad/s max sin φ = (1 − α)/(1 + α) = 0.6 φ = 36.9° gain ×√(1/α) = ×2 (+6.0 dB) there, +12.0 dB far aboveLead alone falls short
Add the lead to K·G: the decibels add, and so do the degrees. The lead's extra gain drags crossover right, to 3.96 rad/s, where the plant has lost even more phase. Margin: −29.5°. Still unstable.
|L| (dB) = |K·G| (dB) + |lead| (dB) ∠L = ∠K·G + ∠lead new crossover 3.96 rad/s phase margin −29.5° ✗ The lead's phase arrived at 1 rad/s, but crossover ran away from it.Lag: pull the gain down
At 1 rad/s, K·G plus lead is 16.0 + 6.0 = 22.0 dB too high. A lag removes exactly that above its corners: zero at 0.1, a decade below, pole at 0.1/12.65 = 0.0079. Its cost at 1 rad/s: −5.3°.
lag (1 + s/0.1) / (1 + s/0.0079) pole below zero needed cut at 1 rad/s 22.0 dB (×12.65) zero ωc/10 = 0.1 rad/s pole 0.1/12.65 = 0.0079 rad/s high −22.0 dB low 0 dB (Kv untouched) phase at 1 rad/s −5.3°Add them: the design
With both in the loop, |L| crosses 0 dB at 1.00 rad/s, where ∠L = −130.2°. Phase margin 49.8°, comfortably over 45°, and gain margin 11.4 dB. The low end is K·G's, so Kv is still 10.
import math deg = math.degrees def mag(w): # |L(jw)|, L = 20 lead lag G h = lambda c: math.hypot(1, w / c) return 20*h(0.5)*h(0.1)/(h(2)*h(0.007906)*w*h(1)*math.hypot(2, w)) def ph(w): # angle of L(jw), degrees a = lambda c: deg(math.atan(w / c)) return -90 - a(1) - a(2) + a(0.5) - a(2) + a(0.1) - a(0.007906) lo, hi = 0.01, 100.0 for _ in range(60): mid = math.sqrt(lo * hi) lo, hi = (mid, hi) if mag(mid) > 1 else (lo, mid) print(f"{lo:.2f} {180 + ph(lo):.1f}") # 1.00 49.8Close the loop: a step
Close the loop and send the step. It is stable now: a peak of 1.21 at 2.78 s (21% overshoot). Then a slow creep, 1.05 at 10 s, inside 2% only by 19.6 s: the lag's slow pole and zero leave a long tail.
peak 1.21 at 2.78 s overshoot 21 % settles (2%) 19.6 s The lag's pole-zero pair near the origin puts a closed-loop pole near s = −0.1: a small, slow tail. Moving the lag zero higher shortens it but costs phase.Accuracy kept
Now send a ramp, r = t. After a minute the output trails it by 0.10, just as Kv = 10 promised: the lead and the lag both have a gain of 1 at ω = 0, so the low end of |L| never moved.
ramp test, r(t) = t error at 60 s 0.10 1/Kv 0.10 Gc(s) = 20 · (1 + s/0.5)/(1 + s/2) · (1 + s/0.1)/(1 + s/0.0079) Gc(0) = 20: lead and lag are 1 at DC. lead → phase at crossover (speed, calm) lag → gain at the low end (accuracy)
5 quick questions
Choose one answer per question. You can change your choices before checking them.
01The plant is G(s) = 1/(s(s + 1)(s + 2)) with a gain K in front. Which K gives Kv = 10?
Kv = lim s·K·G(s) as s → 0 = K/((0 + 1)(0 + 2)) = K/2, so K = 20.
02Adding the lead alone moved the crossover from 2.43 to 3.96 rad/s, and the phase margin stayed negative. Why?
The lead adds phase around 1 rad/s, but it also raises the gain there. The loop then crosses 0 dB further right, where the plant's phase is lower still, so the margin stays negative.
03A lead has its zero at 0.5 rad/s and its pole at 2 rad/s. Where does it add the most phase, and how much?
The peak is at the geometric mean √(0.5 × 2) = 1 rad/s. With α = 0.5/2 = 0.25, sin φ = (1 − α)/(1 + α) = 0.6, so φ = 36.9°.
04Why does adding the lag not spoil the ramp accuracy?
Written as (1 + s/0.1)/(1 + s/0.0079), the lag is 1 at s = 0. It only lowers the gain above its corners, so Kv stays 10 and the ramp error stays 0.10.
05The finished loop has a phase margin of 49.8° but its step response takes 19.6 s to settle within 2%. What causes the long tail?
A lag puts a pole and a zero at low frequency. In closed loop they leave a slow pole near the lag zero, nearly cancelled by it, so the output creeps the last few percent slowly.
Glossary
- Lead compensator
- A block (1 + s/z)/(1 + s/p) with its zero below its pole. It adds phase between the two corners, most at √(z·p), and raises the high-frequency gain.
- Lag compensator
- A block (1 + s/z)/(1 + s/p) with its pole below its zero. It lowers the gain above its corners by p/z and costs a little phase there, with no change at ω = 0.
- Lead-lag (lag-lead) compensator
- A lead and a lag in series. The lead buys phase margin at crossover, the lag buys low-frequency gain (accuracy).
- Velocity constant Kv
- lim s·L(s) as s → 0 for a type 1 loop. The steady error when following a unit ramp is 1/Kv.
- Gain crossover ωc
- The frequency where |L(jω)| = 1 (0 dB).
- Phase margin
- 180° plus the phase of L at the gain crossover. A negative margin means the closed loop is unstable.
- Routh test
- A quick check, done on the coefficients of the closed-loop polynomial, that tells whether every pole is in the left half-plane (stable) without solving for the poles.
- Gain margin
- How many dB the gain could rise before |L| = 1 at the frequency where the phase is −180°.
Notes and sources
- The plant G(s) = 1/(s(s + 1)(s + 2)) is a textbook-style example with illustrative numbers. Every curve in the figure is computed from it: the Bode plots from L(jω), the step and ramp responses by integrating the closed-loop equation (RK4, 2 ms steps).
- This lesson designs the lead first and the lag second, both on the Bode plot. Nise (§11.5) and Ogata (§7-13) teach the same lag-lead idea; on the root locus the lag fixes steady-state error and the lead moves the dominant poles (Nise §9.4).
- Placing the lag zero a decade below the new crossover keeps its phase cost small (here 5.3°). The lead was sized for 55°: its extra 5° or so pays for the lag's 5.3°, and the 50° that is left gives 5° over the 45° spec. A first design rarely lands on the spec, so you always check the margins afterwards.
- The Python is plain Python 3 with the math module. python-control gives the same margins: control.margin(L) returns the gain margin, phase margin and both crossover frequencies.
- N. S. Nise, Control Systems Engineering, 8th ed., Wiley (ch. 11, Design via Frequency Response: §11.3 lag, §11.4 lead, §11.5 lag-lead compensation; ch. 9 §9.4 on the root locus)
- K. Ogata, Modern Control Engineering, 5th ed., Pearson (ch. 7: §7-11 lead, §7-12 lag, §7-13 lag-lead compensation)
- G. F. Franklin, J. D. Powell, A. Emami-Naeini, Feedback Control of Dynamic Systems, 8th ed., Pearson (ch. 6, The Frequency-Response Design Method)
- MIT OpenCourseWare 16.06 Principles of Automatic Control (S. Hall), lecture notes 13–14 (lead and lag on the root locus) and 24–26 (Bode compensation, lead, lag)
- MIT OpenCourseWare 6.302 Feedback Systems (Roberge, Dawson, Lundberg)
- python-control documentation: control.margin (returns gm, pm, wcg, wcp)
- Python documentation: cmath, mathematical functions for complex numbers
Quiz Unlocks after the last step.