Ziegler-Nichols tuning
About this lesson
Tune a PID controller with one experiment instead of a model. Switch off integral and derivative action, raise the gain until a servo swings with constant amplitude, time one swing, and read the three settings off Ziegler and Nichols' table. Then check the result with a simulated step response, see why the rule aims for quarter-amplitude decay, and refine it by hand.
Three knobs, no model
A PID controller has three knobs: the gain Kp, the integral time Ti and the derivative time Td. Tuning means choosing them. Ziegler and Nichols, in 1942, gave a recipe that needs one experiment on the loop, not a model.
controller u = Kp·(e + (1/Ti)∫e dt + Td·de/dt)
(see the lesson "The PID controller")
plant G(s) = 1 / (s(s + 1)(s + 5))
feedback unity: e = command - y
Kp how hard to push on the error now
Ti how fast to add up past error
Td how strongly to react to its trend
The question: which three numbers?Read the lesson step by step
Three knobs, no model
A PID controller has three knobs: the gain Kp, the integral time Ti and the derivative time Td. Tuning means choosing them. Ziegler and Nichols, in 1942, gave a recipe that needs one experiment on the loop, not a model.
controller u = Kp·(e + (1/Ti)∫e dt + Td·de/dt) (see the lesson "The PID controller") plant G(s) = 1 / (s(s + 1)(s + 5)) feedback unity: e = command - y Kp how hard to push on the error now Ti how fast to add up past error Td how strongly to react to its trend The question: which three numbers?Start with P only
Switch off the integral and derivative parts (Ti = ∞, Td = 0), so the controller is just a gain. With Kp = 10 the output overshoots by 49% and settles within 2% after 12.7 s.
Ti = ∞ no integral action Td = 0 no derivative action u = Kp·e (proportional only) Kp = 10 overshoot 49 % settling 12.7 s (2 % band) The plant has a pole at s = 0, so even P alone ends with zero error on a step.Turn the gain up
Raise Kp slowly. The swings grow and take longer to die away: at Kp = 20 the overshoot is 76% and settling takes 29 s. On the s-plane the complex pair of poles slides towards the imaginary axis.
P-only closed loop: s³ + 6s² + 5s + Kp = 0 Kp = 10 overshoot 49 % Kp = 20 overshoot 76 %, ζ of the pair 0.07 more gain, less damping: the pair moves along the root locus towards jωThe edge: ultimate gain
At Kp = 30 the output swings for ever with a constant size, between 0.06 and 1.94. The pair sits on the imaginary axis at ±2.24j. This gain is the ultimate gain, Ku = 30. Any higher and the swings grow.
# Routh array for s³ + 6s² + 5s + K # s³ | 1 5 # s² | 6 K # s¹ | (30-K)/6 # s⁰ | K # the s¹ row is zero at K = 30: the edge import math Ku = 6 * 5 # s¹ row: (6·5 - K)/6 = 0 w = math.sqrt(Ku / 6) # from 6s² + Ku = 0 print(Ku, round(w, 2)) # 30 2.24Time one swing: Pu
Time one full swing: peaks at 1.57 s and 4.37 s, so the ultimate period Pu = 2.81 s. It matches 2π/√5 = 2.81 s from the poles. Ku and Pu are the only two numbers the recipe needs.
# the period from the poles ±j√5 import math w = math.sqrt(5) # rad/s Pu = 2 * math.pi / w print(round(Pu, 2)) # 2.81 # on the plot: peaks at 1.57 s and 4.37 s # 4.37 - 1.57 = 2.81 sRead the table
The Ziegler-Nichols table turns Ku and Pu into settings. For a full PID: Kp = 0.6 Ku = 18, Ti = 0.5 Pu = 1.405 s and Td = 0.125 Pu = 0.351 s. Simpler P and PI rows exist too.
# Ziegler-Nichols, closed-loop method # Kp Ti Td # P 0.5 Ku - - # PI 0.45 Ku Pu / 1.2 - # PID 0.6 Ku 0.5 Pu 0.125 Pu import math Ku, Pu = 30, 2 * math.pi / math.sqrt(5) Kp, Ti, Td = 0.6 * Ku, 0.5 * Pu, 0.125 * Pu print(Kp, round(Ti, 3), round(Td, 3)) # 18.0 1.405 0.351Set the three knobs
Dial in Kp = 18, Ti = 1.40 s and Td = 0.35 s. The integral adds a pole, and the controller brings two zeros. Because Ti = 4·Td they land together at s = −1.42. The poles move back into the left half-plane.
C(s) = Kp(Ti·Td·s² + Ti·s + 1) / (Ti·s) = 6.322·(s + 1.4235)² / s zeros Td·s² + s + 1/Ti = 0 Ti = 4·Td → double zero at -1/(2·Td) = -1.42 closed loop s⁴ + 6s³ + 11.322s² + 18s + 12.812 = 0 pair -0.37 ± 1.62j (ζ 0.22), all four stableCheck the step response
Now the step, integrated from the tuned loop. The output peaks at 1.67 s with 62% overshoot and stays within 2% after 10.0 s. Stable and fast, but that first swing is large.
# step response of the Z-N tuned loop, RK4 import math Pu = 2 * math.pi / math.sqrt(5) Kp, Ti, Td = 18, 0.5 * Pu, 0.125 * Pu y, v, a, z = 0.0, 0.0, Kp * Td, 0.0 # kick from d/dt of the step def f(y, v, a, z): u = Kp * ((1 - y) + z / Ti - Td * v) return v, a, u - 6 * a - 5 * v, 1 - y dt, top = 0.001, 0.0 for n in range(20000): s = (y, v, a, z) k1 = f(*s) k2 = f(*[x + dt / 2 * d for x, d in zip(s, k1)]) k3 = f(*[x + dt / 2 * d for x, d in zip(s, k2)]) k4 = f(*[x + dt * d for x, d in zip(s, k3)]) y, v, a, z = [x + dt / 6 * (p + 2 * q + 2 * r + w) for x, p, q, r, w in zip(s, k1, k2, k3, k4)] top = max(top, y) print(round(100 * (top - 1))) # 62Quarter decay, by design
This is what the rule aims for. The first overshoot is 0.618, the next 0.147: each swing about a quarter of the one before (0.24). Ziegler and Nichols chose that for fast process plants. Most loops want calmer.
first overshoot 0.618 second overshoot 0.147 ratio 0.24 (about 1/4) "quarter-amplitude decay": the target the rule was built for. It gives a quick answer to disturbances but a lively step response and small safety margins. Treat Z-N settings as a starting point.Refine by hand
Keep Kp = 18 but lengthen Ti to 3.077 s and Td to 0.769 s. The double zero moves to −0.65 and the overshoot falls to 19%, settling in 5.1 s. Z-N got us close in one experiment; judgment finishes the job.
Z-N refined Kp 18 18 Ti 1.405 s 3.077 s Td 0.351 s 0.769 s zeros -1.42 (×2) -0.65 (×2) overshoot 62 % 19 % settling 10.0 s 5.1 s Z-N found the right neighbourhood without a model; small moves from there tune it.
5 quick questions
Choose one answer per question. You can change your choices before checking them.
01In the Ziegler-Nichols closed-loop method, how do you find the ultimate gain Ku?
Proportional control only (Ti = ∞, Td = 0), gain up until the swings neither grow nor shrink. That gain is Ku and the swing's period is Pu.
02For the plant 1/(s(s+1)(s+5)) with P control, the closed loop is s³ + 6s² + 5s + K = 0. What are Ku and Pu?
The Routh array's s¹ row is (30 − K)/6, zero at K = 30. Then 6s² + 30 = 0 gives s = ±j√5, so the period is 2π/√5 ≈ 2.81 s.
03With Ku = 30 and Pu = 2.81 s, what are the Ziegler-Nichols PID settings?
Kp = 0.6 Ku = 18, Ti = 0.5 Pu = 1.40 s, Td = 0.125 Pu = 0.35 s. The last option is the PI row (0.45 Ku, Pu/1.2); a P-only controller would use Kp = 0.5 Ku = 15.
04The Z-N tuned loop overshoots by about 62%. Why is that not a mistake?
Each overshoot is about a quarter of the one before (here 0.24). That was Ziegler and Nichols' target; most loops then need a calmer hand refinement.
05Why can't the other Ziegler-Nichols method (reading a delay and time constant off the open-loop step response) be used on this plant?
The open-loop method needs an S-shaped response that settles to a new level. An integrator in the plant makes the output ramp up for ever.
Glossary
- Ultimate gain (Ku)
- The proportional gain at which the loop oscillates with constant amplitude: the edge of stability. Also called the critical gain.
- Ultimate period (Pu)
- The period of that constant oscillation, in seconds. Here 2π/√5 ≈ 2.81 s.
- Ziegler-Nichols closed-loop method
- A tuning recipe from 1942: find Ku and Pu, then set Kp = 0.6 Ku, Ti = 0.5 Pu and Td = 0.125 Pu for a PID.
- Integral time (Ti)
- How quickly the integral term adds up past error; a shorter Ti means stronger integral action. Ti = ∞ switches it off.
- Derivative time (Td)
- How strongly the controller reacts to the error's rate of change; Td = 0 switches it off.
- Quarter-amplitude decay
- A response in which each overshoot is about a quarter of the one before. The original target of the Ziegler-Nichols rules.
- Controller zeros
- The roots of Td·s² + s + 1/Ti. Z-N settings put both at −1/(2·Td); moving them is how the settings are refined.
Notes and sources
- The plant 1/(s(s+1)(s+5)) is a textbook servo model with round numbers, not a measured machine. Every curve is integrated from the closed loop (RK4, 0.01 s steps for the plot, 0.001 s for the numbers); the poles are the exact roots of the characteristic polynomial; settling uses a 2% band.
- On a real plant you find Ku by experiment: raise the gain in small steps until the oscillation neither grows nor dies. Here the Routh array gives the same answer exactly. Running a real loop on the edge of stability can be risky, which is one reason the method is used with care.
- Ziegler and Nichols also gave an open-loop method that reads a delay and a time constant off the plant's S-shaped step response. It does not apply here: with a pole at s = 0 this plant's step response keeps rising and never levels off.
- Quarter-amplitude decay is the design target of the original rules; here the second overshoot is 0.24 of the first. The refined settings trade a slower integral for far less overshoot (61.8% down to about 19%).
- The Python uses only the standard library. With python-control installed, ct.step_info(ct.feedback(C * G)) reports the same overshoot and 2% settling time for these settings.
- K. Ogata, Modern Control Engineering, 5th ed., Pearson (ch. 8, §8-2 Ziegler-Nichols rules for tuning PID controllers)
- N. S. Nise, Control Systems Engineering, 8th ed., Wiley (ch. 6 stability and the Routh-Hurwitz test; ch. 9 PID design via the root locus)
- G. F. Franklin, J. D. Powell, A. Emami-Naeini, Feedback Control of Dynamic Systems, 8th ed., Pearson
- Ziegler-Nichols method (overview, gain table and the 1942 Trans. ASME citation)
- MIT OpenCourseWare 16.06 Principles of Automatic Control (S. Hall)
- MIT OpenCourseWare 6.302 Feedback Systems (Roberge, Dawson, Lundberg)
- python-control documentation: step_info (overshoot, 2% settling time)
Quiz Unlocks after the last step.