DriveLab
Account

Feedback and PID control

Open and closed loops, what the P, I and D terms each do, why loops go unstable, and how to tune one.

35 min

Show me

Open loop and closed loop

Open loop: you set the pump to 1180 rpm and hope the pressure is right. If the pipes are dirtier than expected, you never find out.

Closed loop: you measure the pressure, compare it with what you want, and correct the speed continuously. The controller does what a person would do by hand, faster and without getting tired.

  • SP, set-point (consigne): what you want, for example 25 m of head.
  • PV, process variable (mesure): what the sensor reads.
  • e = SP − PV, the error.
  • CV, control variable: what the controller commands, here the pump speed.
  • Disturbance: anything that pushes PV away, for example a valve closing downstream.

The three terms

CV(t)=Kp e(t)+Ki∫0te dτ+KddedtCV(t) = K_p\, e(t) + K_i \int_0^t e\, d\tau + K_d \frac{de}{dt}

P, proportional: how far off am I now? Push harder the bigger the error. More KpK_p reacts faster, but on its own it leaves a steady-state offset.

I, integral: how long have I been off? It adds up the error over time and keeps pushing while any error remains, so it removes the offset completely. Too much KiK_i overshoots and oscillates.

D, derivative: how fast is it changing? It brakes the response when PV approaches the set-point quickly, which damps overshoot. It amplifies sensor noise, so pump and fan loops usually leave it out and use a PI controller.

FoundationStart here if this is new to you

Think of steering a car to stay in the middle of the lane. P: the further you drift, the more you turn the wheel. I: if a steady crosswind keeps pushing you, you slowly hold a little extra turn until you are centred again. D: if you are swinging back towards the centre quickly, you ease off early so you do not overshoot.

Predict first

A P-only controller (Ki = 0) holds a pump's pressure. Demand changes and the pump must settle at a new speed. Where does the pressure end up?

Try it: a feedback loop
Overshoot
0.0 %
Settling time
does not settle
Error before disturbance
0.455
Open the full PID playground

Why loops go unstable

Every real loop has lag and delay: the motor takes time to change speed, the sensor filters its reading, the fieldbus adds a few scans. The controller always acts on slightly old news. With a small gain that is harmless. With a large gain it overcorrects on old information, overshoots, overcorrects the other way, and the oscillation grows. Raise KpK_p above about 9.5 in the widget and it never settles.

Tuning a loop

  1. Start with Ki=Kd=0K_i = K_d = 0 and a small KpK_p.
  2. Raise KpK_p until the response is quick with little overshoot.
  3. Add KiK_i slowly until the offset disappears in reasonable time.
  4. Add KdK_d only if overshoot is a problem and the signal is clean.

Ziegler-Nichols is the classic systematic method. With P only, raise KpK_p until the loop oscillates steadily. That gain is KuK_u and the period is PuP_u. Then use Kp=0.45KuK_p = 0.45 K_u and Ki=0.54Ku/PuK_i = 0.54 K_u / P_u for a PI controller. It is known to be aggressive.

The full playground has five real processes, all these effects as switches, and tested presets.

ExplorerGo deeper: derivations and open questions

Frequency view. For a plant G(s)G(s) and controller C(s)C(s), the loop is stable while the phase of C(jω)G(jω)C(j\omega)G(j\omega) stays above −180° where its gain crosses 1. A pure delay e−θse^{-\theta s} adds phase lag ωθ\omega\theta with no change in gain, which is why delay, more than anything else, limits how aggressive a loop can be.

Open question. Two first-order lags with a PI controller can never be made unstable by KpK_p alone. Why? What do you have to add before large KpK_p can destabilise the loop? (Lab II depends on the answer.)