TExcelTAD
Home › Control Systems & Automation › PID Tuning: Ziegler–Nichols Methods

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

  1. Turn I and D off. Raise KpK_p until the loop oscillates steadily with constant amplitude.
  2. Record that gain, the ultimate gain KuK_u, and the oscillation period PuP_u.
  3. Read the gains from the table (standard form Kp(1+1Tis+Tds)K_p(1 + \frac{1}{T_i s} + T_d s), PID Structure).
Controller KpK_p TiT_i TdT_d
P 0.5 Ku0.5\,K_u — —
PI 0.45 Ku0.45\,K_u Pu/1.2P_u/1.2 —
PID 0.6 Ku0.6\,K_u Pu/2P_u/2 Pu/8P_u/8

KuK_u is the reciprocal of the plant's gain at the phase crossover, i.e. the gain margin of the P-loop with Kp=1K_p = 1, and Pu=2π/ωpcP_u = 2\pi/\omega_{pc} (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 dd, measure the limit-cycle amplitude aa and period, and estimate Ku≈4dπaK_u \approx \frac{4d}{\pi a} (the describing-function idea of Nonlinearities).

Method 2: the step response (reaction curve)

  1. With the loop open (manual mode), step the actuator by Δu\Delta u and record the output.
  2. Draw the tangent at the inflection point (steepest slope). Its intersection with the initial level gives the apparent dead time LL; the time it takes the tangent to climb by the final change KΔuK\Delta u gives the time constant TT. The process gain is K=Δy/ΔuK = \Delta y/\Delta u.
  3. The model is first order plus dead time (FOPDT), Ke−LsTs+1\frac{K e^{-Ls}}{Ts + 1}, and the table gives:
Controller KpK_p TiT_i TdT_d
P TKL\frac{T}{KL} — —
PI 0.9 TKL0.9\,\frac{T}{KL} 3.33 L3.33\,L —
PID 1.2 TKL1.2\,\frac{T}{KL} 2L2L 0.5 L0.5\,L

The ratio L/TL/T (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: G(s)=1(s+1)3G(s) = \frac{1}{(s + 1)^3} (time in seconds).

Find: ZN PID gains by both methods, and the closed-loop step overshoot.

Solve:

  • Ultimate gain: phase −180∘-180^\circ at ω=3=1.732 rad/s\omega = \sqrt{3} = 1.732\ \text{rad/s}, gain there 1/81/8: Ku=8K_u = 8, Pu=2π/1.732=3.628 sP_u = 2\pi/1.732 = 3.628\ \text{s}. PID: Kp=4.8K_p = 4.8, Ti=1.814 sT_i = 1.814\ \text{s}, Td=0.4534 sT_d = 0.4534\ \text{s}.
  • Step response: y(t)=1−e−t(1+t+t2/2)y(t) = 1 - e^{-t}(1 + t + t^2/2) has its inflection at t=2 st = 2\ \text{s} with y=0.3233y = 0.3233 and slope 2e−2=0.2707 s−12e^{-2} = 0.2707\ \text{s}^{-1}. Tangent: L=2−0.3233/0.2707=0.805 sL = 2 - 0.3233/0.2707 = 0.805\ \text{s}, T=1/0.2707=3.695 sT = 1/0.2707 = 3.695\ \text{s}, K=1K = 1, L/T=0.22L/T = 0.22. PID: Kp=1.2×3.695/0.805=5.50K_p = 1.2 \times 3.695/0.805 = 5.50, Ti=1.61 sT_i = 1.61\ \text{s}, Td=0.403 sT_d = 0.403\ \text{s}.

Check:

python · try it yourself
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 15∘15^\circ to 31∘31^\circ: 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 KpK_p (or use the "some overshoot" / "no overshoot" variants found in many tuning tables, which are not in the 1942 paper: Kp=0.33KuK_p = 0.33 K_u or 0.2Ku0.2 K_u with Ti=Pu/2T_i = P_u/2, Td=Pu/3T_d = P_u/3), 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 5(s+1)(0.5s+1)\frac{5}{(s + 1)(0.5 s + 1)} (K=5K = 5). Its step response has its inflection at t=ln⁡2=0.693 st = \ln 2 = 0.693\ \text{s}, where y/K=0.25y/K = 0.25 and the slope is 0.5 s−10.5\ \text{s}^{-1} (per unit of KK): L=0.193 sL = 0.193\ \text{s}, T=2.0 sT = 2.0\ \text{s}. The step-response PID is Kp=1.2×2.0/(5×0.193)=2.49K_p = 1.2 \times 2.0/(5 \times 0.193) = 2.49, Ti=0.386 sT_i = 0.386\ \text{s} (Ki=6.43 s−1K_i = 6.43\ \text{s}^{-1}), Td=0.0966 sT_d = 0.0966\ \text{s} (Kd=0.240 sK_d = 0.240\ \text{s}). On the lab's slider steps (Kp=2.5K_p = 2.5, Ki=6.45K_i = 6.45, Kd=0.25K_d = 0.25) the readouts are: overshoot 43.34 %43.34\,\%, rise time 0.244 s0.244\ \text{s}, settling time 3.055 s3.055\ \text{s}. The ZN PI (Kp=1.9K_p = 1.9, Ki=2.9K_i = 2.9) overshoots 59.77 %59.77\,\%. A hand-detuned PID (Kp=1.2K_p = 1.2, Ki=1.5K_i = 1.5, Kd=0.2K_d = 0.2) gives 18.14 %18.14\,\% and settles in 2.467 s2.467\ \text{s}.

r = 1+C(s): Kp 2.5, Ki 6.45, Kd 0.25P(s) = 5/((1s+1)(0.5s+1))y-T(s) = (1.250 s^2 + 12.500 s + 32.250) / (0.500 s^3 + 2.750 s^2 + 13.500 s + 32.250)closed-loop poles: -1.11+j4.30, -3.27, -1.11-j4.300.00.51.01.501 s2 s3 s4 sty(t)t_s 3.06 s+43.3 %y(t)setpoint10-90 % rise

Guided lab: tune the heater block by both methods

Hand calculation. From an open-loop step of the heater block (e.g. 0→5 W0 \to 5\ \text{W}), read KK (K/W), LL and TT from the tangent and compute the ZN PI gains. With a sensor delay of 10 s10\ \text{s} and τ=300 s\tau = 300\ \text{s}, expect LL around 10–20 s10\text{–}20\ \text{s} and L/T≈0.05L/T \approx 0.05: 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 12 V12\ \text{V} supply. Step test: expect K≈4 K/WK \approx 4\ \text{K/W} within 20 % (mounting and airflow change it). Ultimate-gain test (or a relay test with ±3 W\pm 3\ \text{W} around 5 W5\ \text{W}): expect an oscillation period of a few times LL, about 40–80 s40\text{–}80\ \text{s}. Then run both PID tunings for a 5 K5\ \text{K} 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 60 ∘C60\,^\circ\text{C} (oscillation tests overshoot), thermal fuse or software cut-off at 70 ∘C70\,^\circ\text{C}, current limit about 1.5 A1.5\ \text{A}, 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 30∘30^\circ phase margin.
  • Applying the KK, TT, LL 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 RR per unit step and LL (Kp=1.2/(RL)K_p = 1.2/(RL) for PID, the same as 1.2 T/(KL)1.2\,T/(KL) since R=K/TR = K/T), or use the ultimate-gain method or a model-based rule for integrating processes.

Practice

  1. A relay test with relay amplitude d=2 Wd = 2\ \text{W} gives a limit cycle of amplitude a=0.5 Ka = 0.5\ \text{K} and period 60 s60\ \text{s}. Estimate KuK_u, PuP_u and the ZN PI gains.
  2. A reaction curve gives K=2K = 2, L=3 sL = 3\ \text{s}, T=30 sT = 30\ \text{s}. Give the ZN PID in standard and parallel form.
  3. Why is a plant with L/T=2L/T = 2 a poor candidate for ZN tuning?
Answer
  1. Ku≈4×2/(π×0.5)=5.09 W/KK_u \approx 4 \times 2/(\pi \times 0.5) = 5.09\ \text{W/K}, Pu=60 sP_u = 60\ \text{s}; PI: Kp=2.29 W/KK_p = 2.29\ \text{W/K}, Ti=50 sT_i = 50\ \text{s}.
  2. Kp=1.2×30/(2×3)=6K_p = 1.2 \times 30/(2 \times 3) = 6, Ti=6 sT_i = 6\ \text{s}, Td=1.5 sT_d = 1.5\ \text{s}; parallel Ki=1 s−1K_i = 1\ \text{s}^{-1}, Kd=9 sK_d = 9\ \text{s}.
  3. Delay dominates: the ZN formulas (built for small L/TL/T) 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

  1. 0.5 Ku0.5\,K_u
  2. 0.6 Ku0.6\,K_u
  3. KuK_u
  4. 0.45 Ku0.45\,K_u

For G=1(s+1)3G = \frac{1}{(s+1)^3}, KuK_u and PuP_u are

  1. 88 and 3.63 s3.63\ \text{s}
  2. 33 and 6.28 s6.28\ \text{s}
  3. 11 and 1 s1\ \text{s}
  4. 88 and 1.73 s1.73\ \text{s}

What do Ziegler–Nichols tunings typically produce?

  1. no overshoot
  2. aggressive loops with roughly quarter-amplitude decay and large overshoot
  3. unstable loops
  4. slow but accurate loops

Why is relay auto-tuning preferred to driving a loop to sustained oscillation?

  1. it is more accurate
  2. the relay limits the amplitude of the controlled oscillation
  3. it needs no measurement
  4. it works without feedback