TOOLS / LEAD–LAG DESIGN

Lead–lag compensator design

Size a lead or lag network on the Bode plot from an error constant and a phase margin, or place a lead network on the root locus from a target damping ratio and natural frequency. Then check the margins, the closed-loop poles and the step response.

Plant / G(s) = N(s) / D(s)
Design

Coefficients in descending powers (1 3 2) or an expression such as s(s+1)(s+2).

Empty: PMreq − PM₀ + δ rounded up to a whole degree, as in hand design.

G(s) =4s² + 2s + 4
  1. K = Kp,req / G(0) = 20 / 1 = 20
  2. Uncompensated K·G: ωc = 9.0512 rad/s, PM₀ = 13.078°
  3. φm = PMreq − PM₀ + δ = 45 − 13.078 + 12 = 43.922° → 44°
  4. α = (1 − sin φm)/(1 + sin φm) = 0.18018, 10 log10(1/α) = 7.443 dB
  5. New crossover: |KG(jωm)| = −7.443 dB at ωm = 13.8 rad/s
  6. 1/T = ωm√α = 5.8577 rad/s, 1/(αT) = ωm/√α = 32.51 rad/s
  7. C(s) = 20(1 + 0.17072s)/(1 + 0.030759s) = 111(s + 5.8577)/(s + 32.51); high-frequency gain K/α = 111 (+14.9 dB)
  8. Check: PM = 52.421° at 13.8 rad/s (meets 45°), GM = ∞ (no crossing)
QuantityBeforeAfter
Phase margin13.078°52.421°
Gain crossover ωc9.0512 rad/s13.8 rad/s
Gain margin∞∞
Kp2020
Peak overshoot70.8%24.7%
Settling time (2%)3.8463 s0.44954 s

Closed-loop poles (After): −12.04 ± 10.81j−10.43

Compensator: C(s) = 111(s + 5.8577)/(s + 32.51)

Same result in code

MATLAB
% G(s) = (4) / (s^2 + 2s + 4)
G = tf([4], [1 2 4]);
K = 20;
C = K*tf([0.170716 1], [0.0307593 1]);   % lead K(1 + Ts)/(1 + alpha*T*s)
L0 = K*G;  L1 = C*G;
[Gm, Pm, Wcg, Wcp] = margin(L1)   % Gm as a ratio
bode(L0, L1); grid on
step(feedback(L0, 1), feedback(L1, 1))
stepinfo(feedback(L1, 1))
Python (python-control)
import control as ct

# G(s) = (4) / (s^2 + 2s + 4)
G = ct.tf([4], [1, 2, 4])
K = 20
C = K * ct.tf([0.170716, 1], [0.0307593, 1])  # lead K(1 + Ts)/(1 + alpha*T*s)
L0, L1 = K * G, C * G
print(ct.margin(L1))  # gm (ratio), pm, wcg, wcp
ct.bode_plot([L0, L1], dB=True)
print(ct.step_info(ct.feedback(L1, 1)))

MATLAB uses the Control System Toolbox; Python uses python-control 0.10 or later (pip install control).

WHAT IT COMPUTES

What this calculator computes

The three procedures of the design lectures. Lead on the Bode plot: K from the error constant, φm from the missing phase margin plus an allowance δ, α = (1 − sin φm)/(1 + sin φm), and the new crossover where |KG| = −10 log10(1/α) dB. Lag on the Bode plot: the new crossover where the phase of KG is −180° + PM + δ, β = |KG| there, and the zero a decade below. Lead on the root locus: the angle deficiency at s_d, the zero by a stated rule, the pole from the angle condition and the gain from the magnitude condition, with an optional lag for the error constant.

For the frequency lecture's example 1/(s(0.5s + 1)(0.02s + 1)) with Kv = 20, PM ≥ 45° and a 12° allowance, the lead C(s) = 20(1 + 0.254s)/(1 + 0.0414s) raises the phase margin from 11.0° to 46.5° and cuts the step overshoot from 73.5% to 25.3%. For 1/(s(s + 3)(s + 10)) with ζ = 0.6 and ωn = 5, the root-locus lead is 406.25(s + 3)/(s + 12.25), and the lag (s + 0.05)/(s + 0.01) brings Kv to 16.6 s⁻¹.

READ THE RESULT

How to read the result

  • The procedure lists every intermediate value in the order the lectures use, so a hand design can be checked line by line.
  • Before is K·G alone; on the root locus it is the gain that puts the uncompensated poles on the same ζ ray. After is C·G. Both are unity-feedback loops, compared on margins, crossover, error constant, overshoot and 2% settling time.
  • A margin is not a step specification: the compensator's zero is also a closed-loop zero, so read the simulated step as well.
METHOD

Method and conventions

  • Crossover frequencies are bracketed on a logarithmic grid and refined by bisection on the exact magnitude and phase. Margins and closed-loop poles use the same routines as the Bode plot and root locus calculators, and the step response is exact at every sample.
  • φm is rounded up to a whole degree and the lag ratio z_l/p_l up to a whole number, as the lectures do by hand; either can be typed in instead. With these defaults the calculator reproduces the numbers of both lectures' worked examples, which the tests check.
LIMITS

One lead or lag stage in unity negative feedback, linear and in continuous time. The margin rules assume a minimum-phase loop that crosses 0 dB once; otherwise check the Nyquist plot. The lead raises the high-frequency gain to K/α, which amplifies sensor noise; the page reports it but does not simulate noise.