PID loop simulator: setpoint and disturbance response
Simulate a PID loop on a process with K, τ and θ: overshoot, rise and settling time, IAE and disturbance response while you move Kp, Ti and Td.
Before touching a controller's settings on the plant it is worth seeing what will happen. The simulator closes a PID loop on a first order plus dead time process (the model you get from the reaction curve: gain K, time constant τ and dead time θ), gives it a setpoint step and, once it has settled, a disturbance on the output. Move Kp, Ti and Td with the sliders in the drawing and watch the curve, the overshoot and the times change. The other way round, enter the overshoot you want and it finds the Kp that gives it.
The model
e is the error (setpoint − measurement). The derivative acts on the measurement, not the error, with a Td/10 filter, as in almost every PLC: that way a setpoint change does not kick the output. If you choose the limited output (0 to 100 %), the integral stops while the output is saturated (anti-windup). K, τ and θ come from identifying the process, and a first tuning from PID tuning.
What it measures
- Overshoot (Mp): how far the measurement goes past the final value, in %. Process loops aim for 0 to 10 %; servos accept more.
- Rise time: from 10 to 90 % of the change.
- Settling time (ts): from the step until the measurement enters the ±2 % band and stays there.
- Remaining error: without integral, proportional action leaves an error of setpoint / (1 + K·Kp).
- IAE: the integral of the absolute error, a number to compare tunings (the smaller, the better).
- Disturbance: how far the measurement moves when a load comes in and how long it takes to get back within ±2 %.
Example
Process with K = 2, τ = 60 s and θ = 10 s; PI controller with Kp = 1.5 and Ti = 60 s, 50 % step. The measurement rises from 10 to 90 % in about 18 s, overshoots by around 4 % and stays within ±2 % from about 60 s. A −10 % disturbance on the output moves it about 5 points and it comes back in just over two minutes. Raising Kp to 2.6 takes the overshoot to 10 %; with Kp = 20 the loop becomes unstable.
Several ways to get each value
- With Kp, Ti and Td: you get the full response and its times.
- With the overshoot you want: leave Kp empty, enter for example 10 % and the calculator finds the Kp that gives it with your Ti and Td.
- Moving the drawing: the Kp, Ti and Td sliders recalculate instantly.
- By hand, the error without integral: e = setpoint / (1 + K·Kp). With K = 2 and Kp = 1.5, e = 50 / 4 = 12.5 %.
- By hand, without dead time: with P only the loop is another first order with time constant τ / (1 + K·Kp); the rise time is that constant times ln 9 (2.2 times).
How to tune with the simulator
- Start with Ti = τ and Td = 0 (a PI) and a small Kp.
- Raise Kp until the overshoot is what you accept (10 % is a good point) or the disturbance response is fast enough.
- If it takes too long to reach the setpoint, lower Ti little by little; if it oscillates, raise it.
- Only on slow, noise-free processes, try Td between θ/4 and θ/2: it lets you raise Kp a little more.
- Look at the controller output in the chart: if it spends a long time at 0 or 100 %, the actuator is too small and no tuning will fix it.
The model is an approximation: the real process has noise, friction, backlash and non-linearities. Apply on the plant a slightly gentler tuning than the best you see here.
Frequently asked questions
What happens if I raise Kp?
The loop responds faster and the error with disturbances is smaller, but it overshoots more and, past a point (the ultimate gain), it oscillates without stopping. With a lot of dead time that point comes sooner.
What is the integral time Ti for?
For the measurement to reach the setpoint: without integral there is always an error left. The smaller Ti, the stronger the integral action and the faster it corrects, but it also overshoots more. A good starting point is Ti equal to the process time constant.
When should I use derivative?
On slow, noise-free processes (temperatures) it anticipates the correction and lets you raise Kp. On flow, pressure or noisy measurements leave it at 0, because it amplifies noise. Here it acts on the measurement, not the error, so changing the setpoint does not kick the output.
What is anti-windup?
When the output reaches 100 % (or 0 %) the integral keeps adding error and then takes a long time to unwind, which gives big overshoots. Anti-windup stops the integral while the output is saturated; this simulator does it if you choose the limited output.
