Worked examples — PID tuning — Ziegler-Nichols, loop shaping
Before any symbol, let us pin down the characters we use everywhere.
The scenario matrix
| Cell | Case class | What is special | Example |
|---|---|---|---|
| A | Closed-loop ZN, well-behaved plant | full PID from | Ex 1 |
| B | Open-loop ZN (reaction curve) | dead-time , slope | Ex 2 |
| C | Loop-shaping, positive phase deficit | need lead (D) | Ex 3 |
| D | Loop-shaping, zero / negative phase deficit | plant already has enough PM → no lead, or need lag | Ex 4 |
| E | Degenerate: pure integrator plant | , ZN closed-loop fails | Ex 5 |
| F | Limiting value: and | reduces to P-only, sanity of formulas | Ex 6 |
| G | Real-world word problem | temperature oven, units, detune | Ex 7 |
| H | Exam twist: wrong form of table | vs trap | Ex 8 |
| I | Pathological plant: non-minimum-phase zero / unstable pole | RHP zero caps bandwidth; unstable pole needs minimum gain | Ex 9 |
Every cell A–I is worked below. Read the Forecast and guess before scrolling.
Ex 1 — Cell A: Closed-loop ZN on a clean plant
Step 1 — Write the phase condition. Why this step? At the stability edge the fed-back signal returns inverted and equal, i.e. total phase . That is the definition of the ultimate frequency (see Nyquist stability criterion).
Step 2 — Solve numerically. Why? Three different poles give no clean trick, so we root-find. The solution is rad/s (this is ; see Verify).
Figure below — what it shows: the purple curve is the plant's phase falling as frequency rises; the coral dashed line is the instability edge; the mint dot marks where they cross, which is . Read off that the curve only touches at one place — that single crossing is the number ZN's closed-loop test physically measures as the sustained-oscillation frequency.

Step 3 — Magnitude gives . Why? At the edge we need , so .
=\frac{2}{\sqrt{12}\sqrt{15}\sqrt{20}}=\frac{2}{60}=\frac{1}{30}.$$ So $K_u=30$. **Step 4 — Period. Why?** $T_u$ is one full oscillation, $2\pi$ radians at rate $\omega_u$: $$T_u=\frac{2\pi}{\omega_u}=\frac{2\pi}{3.3166}=1.895\text{ s}.$$ **Step 5 — ZN PID table.** $K_p=0.6K_u=18$, $T_i=T_u/2=0.9474$, $T_d=T_u/8=0.2368$. Convert: $K_i=K_p/T_i=19.0$, $K_d=K_p T_d=4.263$. > **Verify:** $\omega_u^2=11$ so $\omega_u^2+1,+4,+9 = 12,15,20$; product $=3600$, $\sqrt{}=60$, > magnitude $2/60=1/30$ ✓. Forecast check: $\omega_u=3.32>\sqrt3=1.73$ — the spread-out, faster > poles push the critical frequency **up**. Units: $K_i$ is [1/s]·gain, $K_d$ is [s]·gain — dimensionally > consistent with $C(s)=K_p+K_i/s+K_d s$ ✓. --- ## Ex 2 — Cell B: Open-loop ZN reaction curve > [!example] Statement > A step test on a plant gives an S-shaped response: apparent **dead time** $L=0.5$ s, and the > steepest slope corresponds to reaction rate $R=0.8$ per second (slope of output ÷ step height, > per second). Give the ZN open-loop PID gains. > > **Forecast:** dead time is small — do you expect an *aggressive* (large $K_p$) or *timid* controller? **Step 1 — Recall the reaction-curve table. Why?** We never drove the plant unstable; instead we fitted a first-order-plus-dead-time model and use the delay $L$ and slope $R$ (parent §3). $$K_p=\frac{1.2}{R L},\quad T_i=2L,\quad T_d=0.5L.$$ **Step 2 — Plug in.** $$K_p=\frac{1.2}{0.8\times0.5}=\frac{1.2}{0.4}=3.0.$$ $$T_i=2(0.5)=1.0\text{ s},\qquad T_d=0.5(0.5)=0.25\text{ s}.$$ **Step 3 — Convert to $K_i,K_d$. Why?** So the controller can be coded as $K_p+K_i/s+K_d s$. $$K_i=K_p/T_i=3.0/1.0=3.0,\qquad K_d=K_p T_d=3.0\times0.25=0.75.$$ > **Verify:** small $L$ → the fraction $1.2/(RL)$ is large → aggressive controller, matching the > forecast (short delay means we can push hard). Units: $R$ is [1/s], $L$ is [s], so $RL$ is > dimensionless and $K_p$ is a pure gain ✓; $T_i,T_d$ carry seconds ✓. --- ## Ex 3 — Cell C: Loop shaping with a **positive** phase deficit (need lead) > [!example] Statement > Plant $G(s)=\dfrac{4}{s(s+2)}$. Design a PD controller $C(s)=K_p(1+T_d s)$ to get gain crossover > $\omega_c=3$ rad/s with phase margin $\text{PM}=50°$. > > **Forecast:** the plant has an integrator ($1/s$) contributing $-90°$ plus a pole lag — will the > required lead be positive (add D) or would we need lag? **Step 1 — Plant phase at $\omega_c$. Why?** The controller must top up whatever phase the plant is missing at the crossover frequency (see [[Bode plot & frequency response]]). $$\angle G(j3)=-90°-\arctan\tfrac{3}{2}=-90°-56.31°=-146.31°.$$ **Step 2 — Required loop phase. Why?** $\text{PM}=180°+\angle L(j\omega_c)$, so for $\text{PM}=50°$ we need $\angle L=-130°$. The **phase deficit** (defined above) is $\phi_\text{deficit}=-130°-(-146.31°)=+16.31°$ — positive, so this is a Cell-C, "need lead" problem. **Step 3 — Lead needed = target − plant phase.** $$\phi_\text{lead}=-130°-(-146.31°)=+16.31°.$$ Positive → the derivative zero supplies it, confirming the forecast. **Step 4 — Solve for $T_d$. Why?** A PD zero contributes phase $\arctan(T_d\omega_c)$. $$\arctan(3T_d)=16.31°\Rightarrow 3T_d=\tan 16.31°=0.2926\Rightarrow T_d=0.09753.$$ **Step 5 — Force magnitude $=1$. Why?** By definition $\omega_c$ is where $|L|=1$. $$|G(j3)|=\frac{4}{3\sqrt{3^2+2^2}}=\frac{4}{3\sqrt{13}}=0.3698.$$ $$|1+T_d j3|=\sqrt{1+0.2926^2}=1.0420.$$ $$K_p=\frac{1}{0.3698\times1.0420}=2.595.$$ **Figure below — what it shows:** the purple curve is the *plant's* phase; the mint curve is the loop phase *after* the derivative lead is added. Look at $\omega_c=3$ (coral dashed vertical): the mint curve sits exactly on the $-130°$ butter dotted line, i.e. the $+16.31°$ arrow closes the phase deficit precisely where we need it. Away from $\omega_c$ the lead does little — that is why we place the zero to bite right at crossover. ![[deepdives/dd-physics-3.5.39-d3-s02.png]] > **Verify:** at $\omega_c=3$, $\angle L=-146.31°+16.31°=-130°$ → $\text{PM}=180-130=50°$ ✓. > $|L(j3)|=K_p\cdot0.3698\cdot1.0420=2.595\times0.3853=1.000$ ✓. --- ## Ex 4 — Cell D: **Zero/negative** phase deficit (no lead; a lag may be wanted) > [!example] Statement > Plant $G(s)=\dfrac{10}{s+1}$. We want $\omega_c=3$ rad/s and $\text{PM}=60°$. Show that a *lead* > controller is **not** needed, and instead a pure gain (or gain + lag for low-frequency accuracy) > suffices. > > **Forecast:** a single lag pole only gives up to $-90°$ of phase — can PM ever be a *problem* here? **Step 1 — Plant phase at $\omega_c$.** $$\angle G(j3)=-\arctan 3=-71.57°.$$ **Step 2 — Loop phase with pure gain $C=K_p$. Why?** A constant $K_p$ adds $0°$ phase, so $\angle L=\angle G=-71.57°$, giving $\text{PM}=180-71.57=108.4°$. **Step 3 — Interpret. Why this matters:** the target loop phase for $\text{PM}=60°$ is $-120°$, so the phase deficit is $\phi_\text{deficit}=-120°-(-71.57°)=-48.4°$ — **negative**. We have surplus phase. Adding derivative lead would be pointless; if anything we'd add a **lag** compensator to boost low-frequency gain for steady-state accuracy without disturbing the ample margin. **Step 4 — Just set the gain for crossover. Why?** Pick $K_p$ so $|L(j3)|=1$. $$|G(j3)|=\frac{10}{\sqrt{3^2+1}}=\frac{10}{\sqrt{10}}=3.1623.$$ $$K_p=\frac{1}{3.1623}=0.3162.$$ > **Verify:** with $K_p=0.3162$, $|L(j3)|=0.3162\times3.1623=1.000$ ✓, and PM $=108.4°\ge60°$ ✓. > Degenerate-case lesson: a first-order plant can **never** reach $-180°$, so it has *infinite* > gain margin — closed-loop ZN would never oscillate here (link to Ex 5). --- ## Ex 5 — Cell E: Degenerate plant — pure integrator (ZN closed-loop fails) > [!example] Statement > Plant $G(s)=\dfrac{1}{s}$. Attempt the closed-loop ZN method. What happens to $\omega_u,K_u,T_u$? > Explain the degeneracy and give a working alternative. > > **Forecast:** an integrator gives exactly $-90°$ at *every* frequency. Can it ever hit $-180°$? **Step 1 — Phase everywhere. Why?** $G(j\omega)=1/(j\omega)$ has phase $\angle=-90°$ for **all** $\omega>0$ — flat. **Step 2 — The ZN condition $\angle G=-180°$ has no solution. Why it fails:** there is *no* $\omega_u$ where the phase reaches $-180°$, so cranking $K_p$ only scales magnitude, never phase, and the loop **never** sustains oscillation — it is stable for *all* $K_p>0$. Hence $K_u=\infty$, $\omega_u$ undefined, $T_u$ undefined. **Figure below — what it shows:** the purple line is the integrator's phase, dead flat at $-90°$ for every frequency; the coral dashed line is the $-180°$ edge; the butter shaded band between them is the phase gap that **never closes**. Because the two lines are parallel and never meet, there is no crossing frequency — visually confirming $K_u=\infty$ and why the closed-loop ZN recipe has nothing to measure. ![[deepdives/dd-physics-3.5.39-d3-s03.png]] **Step 3 — Working alternative. Why?** Since ZN closed-loop can't measure timing, use **direct loop shaping**. For $C=K_p$, $L=K_p/s$, so $|L(j\omega_c)|=1$ gives $\omega_c=K_p$ directly, and $\angle L=-90°$ everywhere → constant $\text{PM}=90°$. Choose $K_p$ to set the bandwidth you want, e.g. $K_p=5$ gives $\omega_c=5$ rad/s. > **Verify:** $\angle(1/(j\omega))=-90°$ independent of $\omega$ ✓ (never $-180°$). With $K_p=5$, > $|L(j5)|=5/5=1$ ✓ and PM $=180-90=90°$ ✓. Lesson: **degenerate = flat phase → closed-loop ZN > undefined**; you must fall back to loop shaping or open-loop methods. --- ## Ex 6 — Cell F: Limiting behaviour — collapse PID to P-only > [!example] Statement > Take the ZN PID gains from **Ex 1** ($K_p=18, K_i=19.0, K_d=4.263$). Show algebraically that as > $K_i\to0$ and $K_d\to0$ the controller reduces to pure proportional, and confirm the ZN P-only > value $K_p=0.5K_u$ is *less* aggressive than the PID value. > > **Forecast:** should P-only gain be higher or lower than PID's $K_p$? Why? **Step 1 — Take the limit. Why this step?** The controller is $C(s)=K_p+K_i/s+K_d s$. Letting $K_i\to0$ removes the $1/s$ branch; letting $K_d\to0$ removes the $s$ branch: $$\lim_{K_i,K_d\to0}C(s)=K_p.$$ No integral lag, no derivative lead — just a constant gain, as expected. **Step 2 — Compare ZN rows. Why?** ZN P-only uses $K_p=0.5K_u=0.5(30)=15$, whereas ZN PID uses $0.6K_u=18$. **Step 3 — Interpret the ordering. Why P is smaller:** without derivative lead there is *no phase margin help*, so you must back off the gain (0.5 vs 0.6) to keep the same stability edge. The D term "buys" you the extra $0.1K_u$. > **Verify:** $0.5\times30=15$ and $0.6\times30=18$ so P-gain $15<18=$ PID-gain ✓, matching the > reasoning that D lets you push harder. Limit is exact: with $K_i=K_d=0$, $C(s)=K_p$ identically ✓. --- ## Ex 7 — Cell G: Real-world word problem (oven, units, detune) > [!example] Statement > A resistive oven's step test (heater power → temperature) shows dead time $L=20$ s and reaction > rate $R=0.5\,°\text{C·s}^{-1}$ per unit power (slope/step-height). Design a ZN reaction-curve PI > controller (ovens hate derivative noise), then **detune** $K_p$ by 30\% because ZN's 25\% > overshoot would scorch the product. > > **Forecast:** long dead time — will $K_p$ come out large or tiny? **Step 1 — ZN reaction-curve PI table. Why PI not PID?** Temperature sensors are noisy and D amplifies noise; ovens are slow so D adds little. The PI row is $$K_p=\frac{0.9}{RL},\qquad T_i=\frac{L}{0.3}=3.333\,L.$$ **Step 2 — Plug in.** $$K_p=\frac{0.9}{0.5\times20}=\frac{0.9}{10}=0.09,\qquad T_i=3.333\times20=66.67\text{ s}.$$ $$K_i=K_p/T_i=0.09/66.67=1.35\times10^{-3}\ \text{s}^{-1}.$$ **Step 3 — Detune. Why?** ZN targets quarter-amplitude decay (~25\% overshoot). Reduce $K_p$ by 30\%: $$K_p^\text{tuned}=0.7\times0.09=0.063.$$ Keep $T_i$ (integral time) fixed so steady-state behaviour is preserved; recompute $K_i$: $$K_i^\text{tuned}=0.063/66.67=9.45\times10^{-4}\ \text{s}^{-1}.$$ > **Verify:** long $L=20$ s makes $RL=10$, so $K_p=0.9/10=0.09$ — **tiny**, matching the forecast > (big delay ⇒ timid controller) ✓. Detune: $0.7\times0.09=0.063$ ✓. Units check on the *detuned* > gains: detuning $K_p$ is multiplying by a dimensionless $0.7$, so $K_p^\text{tuned}$ still carries > the same units as $K_p$ (power/°C); since $T_i$ is unchanged in seconds, $K_i^\text{tuned}=K_p^\text{tuned}/T_i$ > is still [power/°C · s$^{-1}$] — the detune preserves dimensional consistency ✓. --- ## Ex 8 — Cell H: Exam twist — the $T_i,T_d$ vs $K_i,K_d$ trap > [!example] Statement > An exam gives $K_u=8,\ T_u=3.63$ s (the parent's $1/(s+1)^3$ plant) and asks: > "*Report the PID gains $K_p,K_i,K_d$.*" A student writes $K_p=4.8,\ K_i=T_u/2=1.815,\ K_d=T_u/8=0.454$. > Find and fix the error. > > **Forecast:** which quantities did the student confuse — times or gains? **Step 1 — Spot the confusion. Why?** ZN tables list **$T_i,T_d$** (integral/derivative *times*, units of seconds), **not** $K_i,K_d$ (gains). The student copied $T_u/2$ and $T_u/8$ straight into $K_i,K_d$. Wrong units: $K_i$ should be [1/s]·gain, $K_d$ [s]·gain. **Step 2 — Correct conversion. Why?** From the standard form $C(s)=K_p(1+1/(T_i s)+T_d s)$ we have $K_i=K_p/T_i$ and $K_d=K_p T_d$. $$T_i=T_u/2=1.815\text{ s},\quad T_d=T_u/8=0.4538\text{ s}.$$ $$K_i=\frac{K_p}{T_i}=\frac{4.8}{1.815}=2.645,\qquad K_d=K_p T_d=4.8\times0.4538=2.178.$$ **Step 3 — Sanity gap. Why it matters:** the student's $K_i=1.815$ vs correct $2.645$ — a 30\% error that would leave visible steady-state offset; $K_d=0.454$ vs correct $2.178$ — nearly $5\times$ too weak, so overshoot would be far worse than intended. > **Verify:** $K_i=4.8/1.815=2.645$ ✓ and $K_d=4.8\times0.4538=2.178$ ✓ — matching the parent's > §2 example exactly. The student's values fail unit analysis: you cannot set $K_i$ (per-second > gain) equal to a *time* $T_u/2$ ✓. --- ## Ex 9 — Cell I: Pathological plant — non-minimum-phase zero & unstable pole > [!example] Statement > Two short scenarios. > **(a)** Plant $G_a(s)=\dfrac{1-s}{(s+1)^2}$ has a **right-half-plane (RHP) zero** at $s=+1$ > (called *non-minimum-phase*). Show its phase is *extra-negative* and explain why this **caps** > the achievable crossover $\omega_c$. > **(b)** Plant $G_b(s)=\dfrac{1}{s-1}$ has an **unstable pole** at $s=+1$. Show that with pure > proportional control there is a *minimum* gain needed just to stabilise it. > > **Forecast:** for (a), does the RHP zero add lead or extra lag? For (b), is small $K_p$ safe? **Step 1 (a) — Phase of the RHP zero. Why?** A normal (left-half-plane) zero $1+s/z$ adds *positive* phase (lead). A RHP zero factor $1-s$ instead **subtracts** phase: $$\angle(1-j\omega)=-\arctan\omega.$$ So $G_a$'s phase is $\angle G_a(j\omega)=-\arctan\omega-2\arctan\omega=-3\arctan\omega$ — the zero behaves like an *extra pole* for phase, dragging it toward $-270°$. **Step 2 (a) — Why this caps bandwidth. Why it matters:** the loop phase races down to $-180°$ at a low frequency. Concretely $\angle G_a=-180°$ when $3\arctan\omega=180°\Rightarrow\arctan\omega=60° \Rightarrow\omega=\sqrt3$. You **cannot** put your crossover $\omega_c$ near or above $\sqrt3$ and still keep phase margin — the RHP zero hard-limits speed. (Rule of thumb: $\omega_c\lesssim$ half the RHP-zero location.) No amount of D-term lead cures a RHP zero, because the deficit only worsens as you push $\omega_c$ up. See [[Root locus method]] for how the RHP zero attracts closed-loop poles rightward. **Step 3 (b) — Unstable pole needs minimum gain. Why?** Closed loop with $C=K_p$: characteristic equation $1+K_p\,G_b=0\Rightarrow s-1+K_p=0\Rightarrow s=1-K_p$. For stability we need the pole in the left half-plane, $s<0$: $$1-K_p<0\Rightarrow K_p>1.$$ So *small* gain is **unsafe** here — the opposite of the usual intuition. Below $K_p=1$ the plant stays unstable; you must apply *enough* gain to drag the pole across into the left half-plane. > **Verify:** (a) $\angle G_a(j\omega)=-3\arctan\omega$ hits $-180°$ at $\omega=\sqrt3\approx1.732$ > ✓; the RHP zero subtracts phase (extra lag) not lead ✓. (b) closed-loop pole $s=1-K_p$; stable iff > $K_p>1$, so $K_p=0.5$ leaves $s=+0.5>0$ (unstable) while $K_p=2$ gives $s=-1<0$ (stable) ✓. > Lesson: minimum-phase intuition ("more gain = less stable", "any gain stabilises a first-order > plant") **reverses** for RHP zeros and RHP poles. --- > [!mnemonic] Never lose a case > **"CLOD-PILEX"** — **C**losed-loop ZN, **L**oop-shape lead, **O**pen-loop ZN, **D**egenerate > (flat-phase/integrator), **P**hase-surplus (no lead), **I**ntegrator limits, **L**iteral word > problem, **E**xam unit trap, **X** = pathological (RHP zero / unstable pole). If your problem > doesn't fit one of these nine, re-read it. > [!recall]- Self-test across the matrix > Define "phase deficit" in one line. ::: The gap between the target loop phase $(-180°+\text{PM})$ and the plant phase at $\omega_c$; positive means we must add lead. > Why can't closed-loop ZN tune a pure integrator? ::: Its phase is $-90°$ for all $\omega$, never reaching $-180°$, so it never sustains oscillation ($K_u=\infty$). > A first-order plant $10/(s+1)$: does it need lead for PM $=60°$ at any $\omega_c$? ::: No — max lag is $90°$, so PM is always $>90°$; use gain (± lag), not lead. > ZN table lists $T_u/2$ under the PID column. Is that $K_i$? ::: No, it is $T_i$ (integral *time*); convert $K_i=K_p/T_i$. > Long dead time $L$ in reaction-curve ZN pushes $K_p$ which way? ::: Down — $K_p=1.2/(RL)$, so bigger $L$ means smaller, timider gain. > How does a RHP zero change tuning? ::: It subtracts phase and caps $\omega_c$ (≈ half the zero location); no lead can fix it. > Is small proportional gain safe for an unstable plant $1/(s-1)$? ::: No — you need $K_p>1$ (a *minimum* gain) just to stabilise it.