TOOLS / PID TUNING

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.

Process / G(s) = K·e^(−Ls)/(Ts + 1)
Start from

Desired closed-loop time constant. Empty means τc = L = 4 s, Skogestad's "tight control".

Model: G(s) = 0.4·e^(−4s)/(24s + 1)
Ku
25.18
Tu
15.05 s
ωu (rad/s)
0.4176
L/T
0.167
Compare

The derivative acts on the error and is filtered, Td s/(1 + Td s/10); the kick it gives at the step adds overshoot.

Settings for every rule
RuleTypeStandard form Kp(1 + 1/(Ti s) + Td s)Parallel form Kp + Ki/s + Kd sOvershootSettling (2%)
KpTi (s)Td (s)KiKd
Ziegler–Nichols, step responseP15∞00047.4%40.93 s
Ziegler–Nichols, step responsePI13.513.3301.012059.5%47.94 s
Ziegler–Nichols, step responsePID18822.253690.9%42.23 s
Ziegler–Nichols, ultimate cycleP12.59∞00033.3%33.8 s
Ziegler–Nichols, ultimate cyclePI11.3312.5400.9036047.6%42.83 s
Ziegler–Nichols, ultimate cyclePID15.117.5241.8812.00828.4159.3%35.48 s
Cohen–CoonP15.83∞00052.3%48.08 s
Cohen–CoonPI13.719.89201.386076.6%69.54 s
Cohen–CoonPID20.639.2091.4122.2429.1296.9%47.78 s
SIMC (Skogestad)PI7.52400.312504.05%24.23 s
IMC (Rivera et al.)PID10.83261.8460.4167200.636%17.77 s

Same result in code

MATLAB
% 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);
end
Python (python-control)
import 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 IT COMPUTES

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.

READ THE RESULT

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

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.
LIMITS

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.