← Back to Autonomy

The Compensator Design Studio

An interactive study of classical linear controllers — P, PI, PD, PID, lead, lag, and lead-lag — applied to first-order and second-order plants, with live Bode analysis and step response.

By Majid Mazouchi

Classical Control Frequency Domain Interactive
Plant G(s) ◆
§ 00

Foundations & Feedback Architecture

Every controller in this study sits in the same closed loop: a reference $r$ enters, an error $e = r - y$ is formed, a compensator $C(s)$ operates on that error, and the plant $G(s)$ produces the output $y$.

The open-loop transfer function is $L(s) = C(s)G(s)$. The closed-loop from reference to output is $$T(s) = \frac{C(s)G(s)}{1+C(s)G(s)}.$$ Every question we ask — is it stable? how fast? how damped? how accurate? — can be answered from $L(j\omega)$ on a Bode diagram and from the step response of $T(s)$. Both are plotted live for every controller below, updating as you drag the sliders.

The design targets you will use repeatedly are crossover frequency $\omega_c$ (sets closed-loop bandwidth and speed), phase margin PM (sets damping — aim for 45°–70°), gain margin GM (stability robustness to plant gain variation), and low-frequency gain (sets steady-state tracking and disturbance rejection).

Term · Kp

Proportional

Acts on the present error. Raises open-loop gain at all frequencies — speeds response, reduces steady-state error, but pushes toward instability.

Term · Ki

Integral

Acts on the accumulated error. Adds a pole at the origin, driving steady-state error to zero for step inputs. Costs 90° of phase at low frequency.

Term · Kd

Derivative

Acts on the rate of error change. Adds phase lead — damps oscillations, improves transient — but amplifies measurement noise. Always filter it in practice.

Compensator · Lead

Phase Lead

A finite-frequency version of PD. Injects positive phase near crossover to raise PM without the infinite DC roll-off of derivative action.

Compensator · Lag

Phase Lag

A finite-frequency version of PI. Adds low-frequency gain for accuracy without the marginal stability of a pure integrator.

Compensator · Lead–Lag

Lead · Lag

Cascade of both. The practical PID equivalent with bounded gain at DC and high frequency — the workhorse of real embedded implementations.

§ 01

Performance Specifications

The vocabulary every controls engineer shares — time- and frequency-domain metrics that translate a vague "fast and stable" into numbers you can specify, measure, and hand to a tuning algorithm.

A compensator design begins and ends here. Before picking P or PID or lead–lag, you state what the closed loop must achieve: a rise time, an overshoot ceiling, a bandwidth floor, a phase margin target. After tuning, you verify against the same list. Almost every term below is derivable from the second-order prototype $$T(s) = \frac{\omega_n^2}{s^2 + 2\zeta\omega_n s + \omega_n^2},$$ which is why a controls engineer will try to reshape any closed loop into an equivalent second-order form near its dominant poles.

Time-Domain Specifications from step response

Annotated Step Response

2nd-order · ζ = 0.35 · ωₙ = 2.2 rad/s · Mₚ ≈ 31%
0 0.5 1.0 1.5 0 1 2 3 4 5 6 time t (seconds) output y(t) 0.1 0.9 tᵣ (rise) Mₚ (overshoot) = (yₚ − y_∞) / y_∞ tₚ t_s enters ±2% band permanently y_∞ = 1 ±2% band
SpecificationSymbolDefinitionFormula / Typical value
Natural frequency ωₙ The frequency at which the system would oscillate if undamped. Sets the overall speed of response. From poles of $s^2 + 2\zeta\omega_n s + \omega_n^2$. Units: rad/s.
Damping ratio ζ (zeta) How oscillatory the response is. ζ=0 pure oscillation, ζ=1 critically damped, ζ>1 overdamped. ζ < 1 underdamped (rings), ζ = 0.707 flattest closed-loop, ζ ≥ 1 no overshoot.
Damped natural frequency ω_d The actual oscillation frequency seen in the underdamped time response. $\omega_d = \omega_n\sqrt{1-\zeta^2}$
Time constant (1st order) τ Time for a first-order response to reach 63.2% of its final value. Fundamental clock of the system. $G(s) = K/(\tau s + 1)$. Response at $t = \tau$ is $1 - e^{-1} ≈ 0.632$.
Rise time t_r Time for the output to climb from 10% to 90% of its final value. Primary speed metric. 2nd-order, ζ≈0.5: $t_r \approx 1.8/\omega_n$. Ramp form: $t_r = (\pi - \beta)/\omega_d$ with $\beta = \arctan(\sqrt{1-\zeta^2}/\zeta)$.
Peak time t_p Time at which the first (largest) overshoot peak occurs. Half a damped period past the step. $t_p = \pi/\omega_d$
Overshoot M_p Peak response minus the steady-state value, usually as a percentage of steady state. Damping indicator. $M_p = \exp\!\left(-\dfrac{\pi\zeta}{\sqrt{1-\zeta^2}}\right)$ — ζ=0.3→37%, ζ=0.5→16%, ζ=0.7→4.6%.
Settling time (2%) t_s Time after which the output stays within ±2% of steady state. The "how fast until I can trust it" metric. $t_s \approx 4/(\zeta\omega_n)$. (Some texts use ±5%: $t_s \approx 3/(\zeta\omega_n)$.)
Delay time t_d Time to reach 50% of the final value. Less commonly used than rise time. 2nd-order, ζ≈0.5: $t_d \approx 1.1/\omega_n$.
Steady-state error e_ss The tracking error that persists after transients die. Depends on input type and system type. Step: $e_{ss} = 1/(1+K_p)$ for Type 0, 0 for Type ≥1. See system-type table below.
Frequency-Domain Specifications from Bode plot

Annotated Bode Plot

L(s) = 10 / [s(s+1)(s+10)] · PM ≈ 47° · GM ≈ 21 dB
−40 −20 0 +20 |L(jω)| (dB) ω_c (gain crossover) GM −90° −180° −270° ∠L(jω) (deg) 0.1 1 10 100 ω_pc PM ω_c −3 dB (approx ω_BW line) frequency ω (rad/s) — log scale
SpecificationSymbolDefinitionFormula / Typical value
Gain crossover freq. ω_c, ω_gc Frequency where the open-loop magnitude |L(jω)| crosses 0 dB (unity). Primary handle for closed-loop speed. $\omega_{BW} \approx \omega_c$ for well-damped designs; rule of thumb $\omega_c \approx \omega_n$.
Phase crossover freq. ω_pc Frequency where the open-loop phase reaches −180°. The location where stability is measured. Must occur above $\omega_c$ for stability.
Phase margin PM Additional phase lag that would drive the system to marginal stability at ω_c. Primary damping proxy. $\text{PM} = 180° + \angle L(j\omega_c)$. Target 45°–70°. $\text{PM} \approx 100\zeta$ for ζ < 0.7.
Gain margin GM Additional open-loop gain that would drive instability at ω_pc. Robustness to plant gain variation. $\text{GM} = -20\log_{10}|L(j\omega_{pc})|$. Target > 6 dB (factor of 2).
Bandwidth ω_BW Frequency at which the closed-loop |T(jω)| drops to −3 dB (70.7%) of its DC value. Defines what the loop can track. $\omega_{BW} = \omega_n\sqrt{(1-2\zeta^2) + \sqrt{4\zeta^4 - 4\zeta^2 + 2}}$. For ζ=0.7, $\omega_{BW} \approx \omega_n$.
Resonant peak M_r Maximum of |T(jω)|. Closed-loop analog of overshoot. Exists only for lightly-damped systems. $M_r = 1/(2\zeta\sqrt{1-\zeta^2})$, valid for ζ < 0.707.
Resonant frequency ω_r Frequency at which M_r occurs. Slightly below ω_n. $\omega_r = \omega_n\sqrt{1-2\zeta^2}$, valid for ζ < 0.707.
Sensitivity peak M_s Maximum of |S(jω)| = |1/(1+L)|. Disturbance-rejection stability indicator. Target $M_s < 2$ (6 dB). Relates to PM: $M_s \approx 1/\sin(\text{PM}/2)$.

Cross-domain rules of thumb — the connections you will use every day

  • Damping ↔ Phase margin: $\zeta \approx \text{PM}/100$ (PM in degrees, for PM < 70°). So 50° PM gives ζ ≈ 0.5 which gives ~16% overshoot.
  • Bandwidth ↔ Rise time: $t_r \cdot \omega_{BW} \approx 2.2$. Doubling bandwidth halves rise time — within physical limits.
  • Bandwidth ↔ Crossover: $\omega_{BW} \approx \omega_c$ for well-damped designs (ζ ≈ 0.5–0.7). Closed-loop bandwidth is set by open-loop crossover — the single most important design knob.
  • Settling ↔ Damping: $t_s \cdot \omega_n \approx 4/\zeta$ (2% criterion). To settle twice as fast, either double ω_n or double ζ.
  • Overshoot ↔ Damping: $M_p = e^{-\pi\zeta/\sqrt{1-\zeta^2}}$. Memorize three points: ζ=0.3→37%, ζ=0.5→16%, ζ=0.7→4.6%.
  • Peak time ↔ Damped frequency: $t_p \cdot \omega_d = \pi$. Exactly half a damped period.
  • Noise trade-off: bandwidth above sensor noise corner → measurement noise dominates output. Rule: $\omega_{BW}$ should be 5×–10× below the highest frequency of valid measurement.

System type → steady-state error (unity feedback)

"System type" = number of pure integrators in $L(s) = C(s)G(s)$. Each integrator kills one power of error to one input class. Position / velocity / acceleration error constants:

TypeStep input (pos.)Ramp input (vel.)Parabolic input (acc.)
01 / (1 + K_p)
101 / K_v
2001 / K_a

Where the error constants are

  • $K_p = \lim_{s\to 0} L(s)$ — position error constant (Type 0)
  • $K_v = \lim_{s\to 0} s\,L(s)$ — velocity error constant (Type 1)
  • $K_a = \lim_{s\to 0} s^2 L(s)$ — acceleration error constant (Type 2)

Practical takeaway: a PI controller adds one integrator, promoting a Type-0 plant to Type 1 → zero steady-state error to step inputs. Add a second integrator (rarely done — stability becomes painful) for zero ramp error.

Pole location in the s-plane — the geometric view

For a complex pole pair $s = -\sigma \pm j\omega_d$ of a dominant 2nd-order mode:

  • Distance from origin = $\omega_n$ (natural frequency)
  • Angle from negative real axis = $\arccos(\zeta)$ — so ζ = cos(angle). Lines of constant ζ are radial rays from origin.
  • Horizontal distance from imaginary axis = $\sigma = \zeta\omega_n$ — governs settling time ($t_s \approx 4/\sigma$).
  • Vertical distance from real axis = $\omega_d = \omega_n\sqrt{1-\zeta^2}$ — governs oscillation frequency.

When tuning, a common mental model: "pull the pole further left" (more damping and faster settling) and "bring it closer to the real axis" (less ringing). Root locus is the tool that shows exactly how controller parameters move these poles.

§ 01

Proportional Control

The simplest compensator — a single gain. It is the starting point for understanding what raising loop gain buys you, and what it costs.

Open-Loop Bode of L(s) = C(s)G(s)

frequency response

Closed-Loop Step Response

time domain
Phase Margin
Gain Margin
Crossover ωc
Overshoot
Rise Time
Settling 2%
Steady-state err
Stable?

Controller Transfer Function

C(s)
§ 09

Tuning Reference · Ziegler–Nichols & Friends

Fast starting points when you don't have a model. Always treat them as opening moves — expect 20–50 % adjustment afterward.

Ziegler–Nichols Closed-Loop (Ultimate Cycle) Method

Most common

Disable I and D. Slowly raise $K_p$ until the output just begins to oscillate with sustained amplitude — that gain is $K_u$ (ultimate gain) and the oscillation period is $T_u$. Then:

ControllerKpTiTdKi = Kp/TiKd = Kp·Td
P0.5 Ku
PI0.45 Ku0.83 Tu0.54 Ku/Tu
PID0.6 Ku0.5 Tu0.125 Tu1.2 Ku/Tu0.075 Ku·Tu
PID (less overshoot)0.33 Ku0.5 Tu0.33 Tu0.66 Ku/Tu0.11 Ku·Tu
PID (no overshoot)0.2 Ku0.5 Tu0.33 Tu0.4 Ku/Tu0.066 Ku·Tu

Cohen–Coon (for plants with dead time)

Identify a FOPDT model $K_p e^{-Ls}/(\tau s + 1)$ from an open-loop step test, then apply tabulated formulas. Handles delay better than Z–N.

IMC / Lambda Tuning

Pick a desired closed-loop time constant $\lambda$ (often 1–3× the plant τ). Analytically cancel the plant and impose first-order closed-loop response. Very common in process control.