PID tuning calculator
Enter a first-order-plus-dead-time model K·e^(−Ls)/(Ts + 1), or the ultimate gain and period of a P-only loop, and get P, PI and PID settings from five tuning rules, each checked on a simulated closed-loop step.
- Ku
- 25.18
- Tu
- 15.05 s
- ωu (rad/s)
- 0.4176
- L/T
- 0.167
The derivative acts on the error and is filtered, Td s/(1 + Td s/10); the kick it gives at the step adds overshoot.
| Rule | Type | Standard form Kp(1 + 1/(Ti s) + Td s) | Parallel form Kp + Ki/s + Kd s | Overshoot | Settling (2%) | |||
|---|---|---|---|---|---|---|---|---|
| Kp | Ti (s) | Td (s) | Ki | Kd | ||||
| Ziegler–Nichols, step response | P | 15 | ∞ | 0 | 0 | 0 | 47.4% | 40.93 s |
| Ziegler–Nichols, step response | PI | 13.5 | 13.33 | 0 | 1.012 | 0 | 59.5% | 47.94 s |
| Ziegler–Nichols, step response | PID | 18 | 8 | 2 | 2.25 | 36 | 90.9% | 42.23 s |
| Ziegler–Nichols, ultimate cycle | P | 12.59 | ∞ | 0 | 0 | 0 | 33.3% | 33.8 s |
| Ziegler–Nichols, ultimate cycle | PI | 11.33 | 12.54 | 0 | 0.9036 | 0 | 47.6% | 42.83 s |
| Ziegler–Nichols, ultimate cycle | PID | 15.11 | 7.524 | 1.881 | 2.008 | 28.41 | 59.3% | 35.48 s |
| Cohen–Coon | P | 15.83 | ∞ | 0 | 0 | 0 | 52.3% | 48.08 s |
| Cohen–Coon | PI | 13.71 | 9.892 | 0 | 1.386 | 0 | 76.6% | 69.54 s |
| Cohen–Coon | PID | 20.63 | 9.209 | 1.412 | 2.24 | 29.12 | 96.9% | 47.78 s |
| SIMC (Skogestad) | PI | 7.5 | 24 | 0 | 0.3125 | 0 | 4.05% | 24.23 s |
| IMC (Rivera et al.) | PID | 10.83 | 26 | 1.846 | 0.4167 | 20 | 0.636% | 17.77 s |
Same result in code
% FOPDT model K·e^(-Ls)/(Ts+1), delay handled exactly
G = tf(0.4, [24 1], 'InputDelay', 4);
N = 10; % derivative filter Td·s/(1 + Td·s/N)
% rule, Kp, Ti, Td (standard form Kp(1 + 1/(Ti s) + Td s))
rules = {
'Ziegler-Nichols, step response PID', 18, 8, 2;
'Ziegler-Nichols, ultimate cycle PID', 15.1069, 7.52364, 1.88091;
'Cohen-Coon PID', 20.625, 9.2093, 1.41176;
'IMC (Rivera et al.) PID', 10.8333, 26, 1.84615;
};
for i = 1:size(rules, 1)
C = pidstd(rules{i, 2}, rules{i, 3}, rules{i, 4}, N);
CL = feedback(C*G, 1);
S = stepinfo(CL); % 2% settling band by default
fprintf('%s: overshoot %.1f%%, settling %.2f s\n', rules{i, 1}, S.Overshoot, S.SettlingTime);
endimport control as ct
K, L, T = 0.4, 4, 24
# python-control has no exact delay: a 10th-order Padé approximation (numbers differ slightly).
num, den = ct.pade(L, 10)
G = ct.tf(K, [T, 1]) * ct.tf(num, den)
s, N = ct.tf('s'), 10
rules = [
('Ziegler-Nichols, step response PID', 18, 8, 2),
('Ziegler-Nichols, ultimate cycle PID', 15.1069, 7.52364, 1.88091),
('Cohen-Coon PID', 20.625, 9.2093, 1.41176),
('IMC (Rivera et al.) PID', 10.8333, 26, 1.84615),
]
for name, Kp, Ti, Td in rules:
C = Kp * (1 + (1 / (Ti * s) if Ti else 0) + (Td * s / (1 + Td * s / N) if Td else 0))
info = ct.step_info(ct.feedback(C * G, 1))
print(name, info['Overshoot'], info['SettlingTime'])MATLAB uses the Control System Toolbox; Python uses python-control 0.10 or later (pip install control).
What this calculator computes
The settings of the Ziegler–Nichols step-response and ultimate-cycle rules, Cohen–Coon, SIMC (PI) and IMC (PID), in the standard form Kp(1 + 1/(Ti·s) + Td·s) that the tables use and in the parallel form Kp + Ki/s + Kd·s, with Ki = Kp/Ti and Kd = Kp·Td.
For the lecture's reaction-curve exercise, K = 0.4, L = 4 s and T = 24 s, the model's ultimate gain is 25.18 with a period of 15.05 s. Ziegler–Nichols PID (Kp = 18, Ti = 8 s, Td = 2 s) overshoots 90.9% and settles in 42.2 s; IMC PID with τc = L overshoots 0.6% and settles in 17.8 s.
How to read the result
- Ku and Tu: the gain at which a P-only loop around the model just sustains an oscillation, and its period. They come from the phase crossover −ωL − tan⁻¹(ωT) = −180°, with the delay exact.
- Overshoot and settling time are measured on each rule's closed-loop unit step: the largest excursion above the final value, and the last exit from the ±2% band. P control leaves an offset, so its final value is KKp/(1 + KKp).
- Ziegler–Nichols aims at a quarter-decay response to load disturbances, so its set-point steps overshoot heavily. SIMC and IMC let you trade speed for robustness through τc.
Method and conventions
- The closed loop is integrated by fourth-order Runge–Kutta on a step that divides L exactly, with the delayed controller output read from a cubic Hermite interpolant of its own history. The delay is exact, not a Padé approximation; the tests compare the result with an independent fine-step integration and with the exact Laplace transform of the closed loop.
- The derivative is filtered, Td·s/(1 + Td·s/N) with N = 10 as in MATLAB pidstd(Kp, Ti, Td, 10), and acts on the error. Stability is decided separately by the Nyquist criterion along the jω axis with the exact delay.
- In the ultimate-cycle mode, giving the process gain K fits the one FOPDT model with exactly that Ku and Tu: T = √((KKu)² − 1)/ωu and L = (π − tan⁻¹(ωuT))/ωu, with ωu = 2π/Tu.
A first-order-plus-dead-time model only approximates a real process, and every rule assumes it. The Ziegler–Nichols and Cohen–Coon tables were fitted for L/T between about 0.1 and 1. Actuator limits, sensor noise and load disturbances are not simulated; the linked lab shows where they matter.