Lag compensation
About this lesson
A servo with a good transient still trails a moving target by 1.93 rad. Ten times the gain would fix the error but makes the loop unstable. A lag compensator, (s + 0.05)/(s + 0.005), raises only the low-frequency gain: Kv goes from 0.519 to 5.04 while the damping ratio stays 0.5. Design it on the root locus, read it on the Bode plot, and see its price: a slow tail.
A servo with good damping
This servo, G(s) = 1/(s(s+1)(s+2)), was tuned in the lesson "Choosing the gain for a target damping ratio". K = 1.037 puts the closed-loop pair at −0.333 ± 0.577j, damping ratio 0.5. The transient is good.
plant G(s) = 1 / (s(s + 1)(s + 2)) gain K = 28/27 = 1.037 closed-loop poles -0.333 ± 0.577j, -2.333 damping ratio ζ = 0.5 The step response is fine. This lesson asks a different question: how well does the arm follow a command that keeps moving?
Read the lesson step by step
A servo with good damping
This servo, G(s) = 1/(s(s+1)(s+2)), was tuned in the lesson "Choosing the gain for a target damping ratio". K = 1.037 puts the closed-loop pair at −0.333 ± 0.577j, damping ratio 0.5. The transient is good.
plant G(s) = 1 / (s(s + 1)(s + 2)) gain K = 28/27 = 1.037 closed-loop poles -0.333 ± 0.577j, -2.333 damping ratio ζ = 0.5 The step response is fine. This lesson asks a different question: how well does the arm follow a command that keeps moving?Follow a ramp
Now ask the arm to follow a ramp: the camera pans at a steady 1 rad/s. The arm matches the speed but trails behind. The error settles at 1.93 rad, almost two radians late. Far too much.
# unit ramp r = t into the loop, RK4, K = 28/27 K, dt = 28 / 27, 0.01 x = [0.0, 0.0, 0.0] # y, y', y'' f = lambda t, x: [x[1], x[2], K * (t - x[0]) - 2 * x[1] - 3 * x[2]] t = 0.0 for i in range(12000): # 120 s k1 = f(t, x) k2 = f(t + dt / 2, [a + dt / 2 * b for a, b in zip(x, k1)]) k3 = f(t + dt / 2, [a + dt / 2 * b for a, b in zip(x, k2)]) k4 = f(t + dt, [a + dt * b for a, b in zip(x, k3)]) x = [a + dt / 6 * (p + 2 * q + 2 * r + s) for a, p, q, r, s in zip(x, k1, k2, k3, k4)] t += dt print(round(t - x[0], 2)) # 1.93The error is 1/Kv
For this loop the ramp error is 1/Kv. The velocity constant Kv = lim s→0 of s·K·G(s) = K/2 = 0.519. It is the low-frequency gain on the Bode plot. Ten times less error needs Kv ten times bigger, about 5.
Kv = lim (s→0) s · K · G(s) = lim K / ((s + 1)(s + 2)) = K / 2 = 0.519 ramp error e(∞) = 1 / Kv = 1.93 rad wanted e(∞) ≈ 0.2 rad → Kv ≈ 5 On the Bode plot |K·G(jω)| ≈ Kv / ω at low frequency: Kv is the height of that line. (Error constants and system type are taught in the lesson "System type and error constants".)Just turn K up?
The obvious fix is ten times the gain, K = 10.37. Watch the poles: the pair slides across the imaginary axis to +0.167 ± 1.756j. The loop is unstable, as it is for any K above 6. Gain alone cannot do both jobs.
K = 10 × 28/27 = 10.37 s³ + 3s² + 2s + 10.37 = 0 poles +0.167 ± 1.756j, -3.333 A pole with a positive real part grows like e^(+0.167t): the arm swings wider and wider. The pair crosses the jω axis at K = 6 (±1.41j). Kv would be 5.19, but the loop is useless.Add a lag compensator
Instead, add a lag compensator: Gc(s) = (s + 0.05)/(s + 0.005). It is one zero and one pole, the pole ten times closer to the origin. At s = 0 its gain is 0.05/0.005 = 10; at high frequency it is 1.
Gc(s) = (s + zc) / (s + pc), zc = 0.05, pc = 0.005 Gc(0) = zc / pc = 10 (low frequency) Gc(∞) = 1 (high frequency) The pole is nearer the origin than the zero, so Gc's phase is negative at every frequency: it makes the output lag. Hence the name. Kv with the lag = K · Gc(0) / 2 = 5·KWhy near the origin?
Both sit very close to the origin, far from the pair we care about. Seen from the old design point, they look almost the same distance and direction: together they scale the loop by 0.968 and turn it just −3.5°. The locus barely moves.
# what the lag does at the old design point s* import cmath, math s = complex(-1/3, 3 ** -0.5) Gc = (s + 0.05) / (s + 0.005) print(round(abs(Gc), 3), round(math.degrees(cmath.phase(Gc)), 1)) # 0.968 -3.5 # a factor near 1 and an angle under 5°: the # locus near s* hardly changes (the usual # lag-design rule of thumb).Re-tune on the root locus
Find where the ζ = 0.5 ray crosses the new locus: s = −0.314 ± 0.544j, with K = 1.008. Now Kv = K × 10 / 2 = 5.04, 9.7 times bigger. The damping ratio is still 0.5; the far pole sits at −2.32.
# walk out along the ζ = 0.5 ray until ∠(Gc·G) = -180° import cmath, math G = lambda s: 1 / (s * (s + 1) * (s + 2)) Gc = lambda s: (s + 0.05) / (s + 0.005) ray = cmath.exp(1j * math.radians(120)) def angle(r): a = math.degrees(cmath.phase(Gc(r * ray) * G(r * ray))) return a - 360 if a > 0 else a lo, hi = 0.05, 1.4 for _ in range(60): mid = (lo + hi) / 2 lo, hi = (mid, hi) if angle(mid) > -180 else (lo, mid) s = lo * ray K = 1 / abs(Gc(s) * G(s)) Kv = K * Gc(0) / 2 print(round(K, 3), round(Kv, 2)) # 1.008 5.04The same design on Bode
On the Bode plot the lag lifts the low-frequency gain by 20 dB: the factor of 10 in Kv. Its zero sits about a decade below crossover, so crossover barely moves (0.459 to 0.451 rad/s) and phase margin drops only from 52° to 47°.
without lag with lag K 1.037 1.008 low-freq gain Kv/ω 10× higher (+20 dB) crossover ωc 0.459 rad/s 0.451 rad/s phase margin 52.4° 47.3° lag corners 0.005 (pole) and 0.05 (zero), the zero about ωc / 9 Bode recipe: keep the crossover, put the lag's zero a decade below it, let the pole set the low-frequency boost.Run the ramp again
Run the ramp again. At first the error follows the old curve, because the lag acts only at low frequency. Then it drains away and settles at 0.198 rad, about ten times smaller than before.
ramp error e(t) = t - y(t), integrated (RK4) without lag with lag Kv 0.519 5.04 e(∞) = 1/Kv 1.93 rad 0.198 rad within 2 % of the final error after about 113 s with the lag.The price: a slow tail
The price is a slow tail. The lag leaves a closed-loop pole at −0.055, right beside its zero, so part of the error fades like e^(−0.055t): an 18 s time constant. Lag buys accuracy; lead buys speed.
closed-loop poles with the lag (K = 1.008): -0.314 ± 0.544j the dominant pair, ζ = 0.5 -2.32 far left -0.055 slow, next to the zero -0.05 1 / 0.055 ≈ 18 s time constant lag raises low-frequency gain: accuracy lead adds phase near crossover: speed (see the lesson "Lead compensation")
5 quick questions
Choose one answer per question. You can change your choices before checking them.
01The servo K/(s(s+1)(s+2)) has K = 1.037. What is its velocity constant Kv, and its error following a unit ramp?
Kv = lim s→0 s·K·G(s) = K/((0+1)(0+2)) = K/2 = 0.519, and a type 1 loop follows a unit ramp with error 1/Kv = 1.93.
02Why not simply multiply K by 10 to cut the ramp error tenfold?
At K = 10.37 the pair sits at +0.167 ± 1.756j. The jω-axis crossing is at K = 6, so the loop oscillates with growing amplitude.
03A lag compensator Gc(s) = (s + 0.05)/(s + 0.005) is put in front of the gain. By what factor does it multiply Kv?
Kv uses the loop gain as s → 0, and Gc(0) = 0.05/0.005 = 10. At high frequency Gc tends to 1, so the fast dynamics are almost untouched.
04Why are the lag's pole and zero placed close to the origin, far from the dominant closed-loop poles?
From the old design point the zero and pole are almost the same distance and direction away, so together they scale the loop by 0.968 and turn it by only −3.5°. The transient design survives; only the low-frequency gain changes.
05What is the typical price of lag compensation, as seen in this design?
The pole at −0.055 gives a time constant of about 18 s; the ramp error takes about 113 s to come within 2% of 0.198 rad. Lag buys accuracy, not speed.
Glossary
- Lag compensator
- A controller block (s + zc)/(s + pc) with its pole nearer the origin than its zero (pc < zc). It raises the low-frequency gain by zc/pc and adds a little negative phase, so the output lags.
- Velocity constant Kv
- lim s→0 of s·L(s) for a type 1 loop. The steady-state error when following a unit ramp is 1/Kv.
- Ramp error
- The steady gap between a command rising at a constant rate and the output that follows it.
- Dominant poles
- The closed-loop poles nearest the imaginary axis that set the shape of the transient, here the pair at damping ratio 0.5.
- Crossover frequency
- The frequency where the open-loop gain |L(jω)| is 1 (0 dB). The phase there sets the phase margin.
- Phase margin
- How far the open-loop phase at crossover is above −180°. Less margin means more overshoot.
- Pole-zero pair near the origin
- A lag's pole and zero, placed close together and close to s = 0 so that they change the gain at s = 0 but almost nothing near the dominant poles.
Notes and sources
- The plant 1/(s(s+1)(s+2)) is a standard textbook servo model with round numbers. The loci are the exact roots of the closed-loop polynomial for many values of K, the Bode curves are |K·Gc(jω)·G(jω)| point by point, and the ramp errors are integrated from the closed loop (RK4, 0.01 s steps).
- Ogata's Modern Control Engineering (§6-7, Example 6-7) designs a lag for this same plant with the same zero 0.05 and pole 0.005; its numbers differ slightly because it starts from K = 1.06 rather than 28/27.
- The slow pole at −0.055 nearly cancels the lag zero at −0.05, so its share of a step response is small; it shows mostly in the error, which creeps to its final value over about 113 s.
- Rule of thumb: put the lag zero about a decade below the crossover frequency (or about ten times closer to the origin than the dominant poles), and make the zero-to-pole ratio the factor you need in the error constant.
- The Python uses only the standard library. With python-control installed, ct.bode_plot and ct.root_locus_plot on ct.tf([1, 0.05], [1, 3.005, 2.015, 0.01, 0]) draw the compensated loop.
- N. S. Nise, Control Systems Engineering, 8th ed., Wiley (ch. 7 steady-state error; ch. 9 design via root locus, lag compensation; ch. 11 design via frequency response)
- K. Ogata, Modern Control Engineering, 5th ed., Pearson (ch. 6 root-locus design: lag compensation; ch. 7 frequency-response design: lag compensation)
- G. F. Franklin, J. D. Powell, A. Emami-Naeini, Feedback Control of Dynamic Systems, 8th ed., Pearson (ch. 5 root-locus design; ch. 6 frequency-response design)
- MIT OpenCourseWare 16.06 Principles of Automatic Control (S. Hall), lecture notes 14 and 26: lag compensation
- MIT OpenCourseWare 6.302 Feedback Systems (Roberge, Dawson, Lundberg)
- python-control documentation: control.root_locus_plot
Quiz Unlocks after the last step.