Skip to content
Tutorials Center
My learning

Topics

Lesson 25 of 37 · PID and Compensators

Lead and Lag Compensators

Design lead and lag compensators from frequency-response specs: add phase margin with a lead, boost steady-state accuracy with a lag, and verify both in Python.

A pure gain is a blunt tool: raising it speeds the loop up but eats the phase margin. A compensator is a small filter placed in the loop that reshapes the frequency response where you need it. The two classic building blocks are the lead compensator, which adds phase near the crossover frequency (better damping and speed), and the lag compensator, which raises low-frequency gain (better steady-state accuracy) without disturbing the crossover.

Lead behaves like a filtered PD controller; lag behaves like a PI controller with finite DC gain. A PID is roughly "lag plus lead in one box", which is why PID tuning and compensator design describe the same ideas from two angles.

The two transfer functions

Both have one zero and one pole:

TEXT
C(s) = (1 + s/z) / (1 + s/p)
Type Pole/zero order Phase Effect
Lead z < p (zero first) positive, peaks between z and p adds phase margin, raises high-frequency gain
Lag p < z (pole first) negative boosts low-frequency gain by z/p, adds small phase lag

For a lead, define α = z/p (less than 1). The maximum phase and the frequency where it occurs are:

TEXT
sin φmax = (1 - α) / (1 + α)      ωm = √(z·p)

An α of 0.25 gives about 37° of lead; 0.1 gives 55°; one lead stage rarely exceeds 60° because the high-frequency gain rises as 1/α, amplifying noise. For more phase, cascade two stages.

flowchart LR
    A["Specs: PM, bandwidth, Kv"] --> B["Measure plain loop: PM0, wgc0"]
    B --> C{"Need phase or accuracy?"}
    C -->|"phase"| D["Lead: phi = PM_target - PM0 + margin"]
    C -->|"accuracy"| E["Lag: zero a decade below wgc"]
    D --> F["Check PM, overshoot, noise"]
    E --> F

Choose lead for transient performance, lag for steady-state accuracy.

Lead design step by step

Plant: G(s) = 10/(s(s+1)) with unity feedback. We want about 50° of phase margin.

  1. Measure the plain loop: crossover ω0 and phase margin PM0.
  2. Required extra phase: φ = PM_target - PM0 + 5° (the 5° safety cushion pays for the crossover moving to the right, where the plant has more lag).
  3. α = (1 - sin φ)/(1 + sin φ).
  4. The lead raises the gain at ωm by 1/√α, so put the new crossover where the plant gain is √α.
  5. Place the zero and pole at z = ωm√α, p = ωm/√α.
Python Design a lead compensator

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The phase margin rises from about 18° to about 50°, and the overshoot drops from about 60% to about 22%, with a faster crossover. The remaining overshoot comes from the closed-loop zero introduced by the lead. If you need a smoother response, add a prefilter on the reference (see practical PID for setpoint weighting, which is the same trick).

Lag design for steady-state accuracy

Sometimes the transient is fine and the loop just lacks low-frequency gain. For a type-1 loop (one integrator), the ramp-tracking error is 1/Kv, where Kv = lim s→0 s·L(s). A lag compensator multiplies the DC gain by β = z/p while leaving the high-frequency gain at 1. To avoid disturbing the phase at crossover, put the zero about a decade below ωgc.

Plant: G(s) = 2/(s(s+1)(s+4)), which has Kv = 0.5 and a ramp error of 2. We want Kv = 5, so β = 10.

Python Design a lag compensator

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Kv jumps tenfold, so the ramp error falls from 2 to 0.2, while the crossover barely moves and the phase margin drops only a few degrees (from about 59° to about 54°). The price is a slow "tail" in the step response: the closed-loop pole-zero pair near zc creates a slowly converging component with time constant about 1/pc.

A lag with p → 0 becomes a PI controller: (1 + s/z)/(s/p). That is why integral action is "an infinite-gain lag".

Lead-lag together

If you need both a fast transient and high accuracy, cascade a lag and a lead: design the lead first for the phase margin and crossover, then add a lag that lifts the low-frequency gain, with its zero well below the crossover. This is the frequency-domain equivalent of full PID.

Practical limits

  • A lead raises the high-frequency gain by 1/α; with sensor noise this can saturate the actuator. Keep α ≥ 0.1 per stage.
  • Compensators cannot cancel a right-half-plane pole or zero. Placing a zero on an unstable pole hides it from the output but leaves an unstable internal mode.
  • Model error moves the crossover. Check the margin at the largest plausible plant gain.
  • Implement as a discrete filter (see digital control).

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. Which compensator adds phase near the crossover frequency?

    A lead compensator (zero before pole) adds positive phase between its zero and pole frequencies.
  2. 2. A lead compensator has alpha = z/p = 0.25. What is the maximum phase it contributes?

    sin(phi) = (1 - 0.25)/(1 + 0.25) = 0.6, so phi is about 36.9 degrees.
  3. 3. Why is the zero of a lag compensator placed about a decade below the gain crossover?

    The lag's phase lag peaks between its pole and zero; keeping that region far below crossover leaves the phase margin nearly intact.
  4. 4. A type-1 loop has Kv = 0.5. A lag with beta = 10 is added. What is the new ramp error?

    Kv rises to 5, and the steady-state ramp error is 1/Kv = 0.2.

Summary

  • A compensator (1 + s/z)/(1 + s/p) reshapes the loop: lead (z < p) adds phase, lag (z > p) adds low-frequency gain.
  • Lead design: α = (1 - sin φ)/(1 + sin φ), crossover at ωm, zero and pole at ωm√α and ωm/√α.
  • Lag design: gain β at DC, zero a decade below crossover, pole at z/β.
  • Lead amplifies noise; lag slows the tail; combine them for lead-lag, the ancestor of PID.
  • Always re-measure margins and simulate after designing.

Next: Practical PID Implementation