PID Tuning: Ziegler–Nichols Methods
You are commissioning a loop on a plant nobody has modelled: a furnace, a pump, a conveyor. You need working PID gains this afternoon. In 1942 John G. Ziegler and Nathaniel B. Nichols of Taylor Instrument published two recipes that need only one simple experiment each: the ultimate-gain (closed-loop) method and the step-response (open-loop, reaction-curve) method. Both are still in every controller manual and in many auto-tuners. Both are also known to give aggressive loops with roughly quarter-amplitude decay (each overshoot about a quarter of the previous one), so the modern use is: tune with Ziegler–Nichols, then detune. This lesson does both on models you can check, which is how the roadmap project "tune a PID controller and compare tuning methods" starts; Model-Based Tuning continues it.
Method 1: the ultimate gain
- Turn I and D off. Raise until the loop oscillates steadily with constant amplitude.
- Record that gain, the ultimate gain , and the oscillation period .
- Read the gains from the table (standard form , PID Structure).
| Controller | |||
|---|---|---|---|
| P | — | — | |
| PI | — | ||
| PID |
is the reciprocal of the plant's gain at the phase crossover, i.e. the gain margin of the P-loop with , and (Stability Margins). On a real plant, driving a loop to sustained oscillation is risky; relay auto-tuning (Åström and Hägglund, 1984) gets the same two numbers safely: replace the controller by an on/off relay of amplitude , measure the limit-cycle amplitude and period, and estimate (the describing-function idea of Nonlinearities).
Method 2: the step response (reaction curve)
- With the loop open (manual mode), step the actuator by and record the output.
- Draw the tangent at the inflection point (steepest slope). Its intersection with the initial level gives the apparent dead time ; the time it takes the tangent to climb by the final change gives the time constant . The process gain is .
- The model is first order plus dead time (FOPDT), , and the table gives:
| Controller | |||
|---|---|---|---|
| P | — | — | |
| PI | — | ||
| PID |
The ratio (the controllability ratio) predicts how hard the loop is: below 0.1 easy, above 1 dominated by delay (use model-based tuning or a Smith predictor instead).
Worked example: a third-order plant, both methods
Given: (time in seconds).
Find: ZN PID gains by both methods, and the closed-loop step overshoot.
Solve:
- Ultimate gain: phase at , gain there : , . PID: , , .
- Step response: has its inflection at with and slope . Tangent: , , , . PID: , , .
Check:
import numpy as np
import control as ct
G = ct.tf([1], [1, 3, 3, 1])
gm, pm, wpc, wgc = ct.margin(G)
Ku, Pu = gm, 2 * np.pi / wpc
print(f"ultimate gain Ku = {Ku:.3f}, period Pu = {Pu:.3f} s")
t = np.linspace(0, 30, 300001)
_, y = ct.step_response(G, T=t)
dy = np.gradient(y, t)
i = np.argmax(dy) # inflection = steepest point
L = t[i] - y[i] / dy[i]
T = (y[-1]) / dy[i]
print(f"reaction curve: inflection at {t[i]:.3f} s, L = {L:.3f} s, T = {T:.3f} s, K = {y[-1]:.3f}")
def pid(Kp, Ti, Td):
return ct.tf([Kp * Td, Kp, Kp / Ti], [1, 0])
tunings = {"ZN ultimate PID": (0.6 * Ku, Pu / 2, Pu / 8),
"ZN step PID": (1.2 * T / L, 2 * L, 0.5 * L),
"ZN ultimate PI": (0.45 * Ku, Pu / 1.2, 0.0)}
for name, (Kp, Ti, Td) in tunings.items():
C = pid(Kp, Ti, Td)
Tcl = ct.feedback(C * G, 1)
info = ct.step_info(Tcl, T=np.linspace(0, 40, 40001))
_, yd = ct.step_response(ct.feedback(G, C), T=np.linspace(0, 40, 40001)) # unit load step at the plant input
gm, pm, _, _ = ct.margin(C * G)
print(f"{name:16s}: Kp {Kp:5.2f}, Ti {Ti:5.3f} s, Td {Td:5.3f} s | overshoot {info['Overshoot']:5.1f} %, "
f"settling {info['SettlingTime']:5.2f} s, PM {pm:4.1f} deg, peak load error {yd.max():.3f}")ultimate gain Ku = 8.000, period Pu = 3.628 s
reaction curve: inflection at 2.000 s, L = 0.805 s, T = 3.695 s, K = 1.000
ZN ultimate PID : Kp 4.80, Ti 1.814 s, Td 0.453 s | overshoot 40.6 %, settling 9.37 s, PM 30.6 deg, peak load error 0.188
ZN step PID : Kp 5.50, Ti 1.611 s, Td 0.403 s | overshoot 51.8 %, settling 12.98 s, PM 22.4 deg, peak load error 0.173
ZN ultimate PI : Kp 3.60, Ti 3.023 s, Td 0.000 s | overshoot 56.1 %, settling 30.77 s, PM 14.8 deg, peak load error 0.299
The recipes give overshoots of 41 to 56 % and phase margins of only to : fast rejection of load disturbances (the peak error after a unit load step is small), but a poor setpoint response. That is what Ziegler and Nichols optimised for (process plants where load disturbances matter more than setpoint changes). The usual practical fixes: halve (or use the "some overshoot" / "no overshoot" variants found in many tuning tables, which are not in the 1942 paper: or with , ), use setpoint weighting (Practical PID), or move to model-based tuning.
Lab: Ziegler–Nichols on the PID lab plant
Set the lab's plant to (). Its step response has its inflection at , where and the slope is (per unit of ): , . The step-response PID is , (), (). On the lab's slider steps (, , ) the readouts are: overshoot , rise time , settling time . The ZN PI (, ) overshoots . A hand-detuned PID (, , ) gives and settles in .
Guided lab: tune the heater block by both methods
Hand calculation. From an open-loop step of the heater block (e.g. ), read (K/W), and from the tangent and compute the ZN PI gains. With a sensor delay of and , expect around and : an easy loop.
Simulation. Fit an FOPDT model to your logged data (the program's tangent method works on any array of samples) and simulate the closed loop.
What you would measure. The heater on a current-limited supply. Step test: expect within 20 % (mounting and airflow change it). Ultimate-gain test (or a relay test with around ): expect an oscillation period of a few times , about . Then run both PID tunings for a setpoint step and a disturbance (a small fan switched on): record overshoot, settling time and the peak dip. Expect the ZN tunings to overshoot 30–60 % on setpoint steps and the step and ultimate methods to disagree by 10–30 % in gains: they fit different features of the same plant.
Hazards and safe setup. Keep the whole test below (oscillation tests overshoot), thermal fuse or software cut-off at , current limit about , never unattended. Never run the ultimate-gain test on equipment where an oscillation is dangerous; use the relay method or a model.
Pitfalls
- Using the tables with the wrong PID form (they are for the standard form).
- Tangent drawn on noisy data: filter or fit a model instead.
- Treating ZN gains as final: they are a starting point with about phase margin.
- Applying the , , form of the step method to an integrating plant (level, position): it has no final value. Ziegler and Nichols' original form needs only the steepest slope per unit step and ( for PID, the same as since ), or use the ultimate-gain method or a model-based rule for integrating processes.
Practice
- A relay test with relay amplitude gives a limit cycle of amplitude and period . Estimate , and the ZN PI gains.
- A reaction curve gives , , . Give the ZN PID in standard and parallel form.
- Why is a plant with a poor candidate for ZN tuning?
Answer
- , ; PI: , .
- , , ; parallel , .
- Delay dominates: the ZN formulas (built for small ) give gains that are far too aggressive or poorly balanced; dead-time-dominant plants need model-based tuning.
Test yourself
For the ultimate-gain Ziegler–Nichols PID, the proportional gain is
For , and are
- and
- and
- and
- and
What do Ziegler–Nichols tunings typically produce?
- no overshoot
- aggressive loops with roughly quarter-amplitude decay and large overshoot
- unstable loops
- slow but accurate loops
Why is relay auto-tuning preferred to driving a loop to sustained oscillation?
- it is more accurate
- the relay limits the amplitude of the controlled oscillation
- it needs no measurement
- it works without feedback