Control Track · Hands-on

The PID Tuning Trainer

You can read about P, I and D forever, but tuning only clicks when you feel the loop fight back. This is a live closed loop: a simulated first-order process with deadtime, controlled by a PID you tune with three sliders. Step the setpoint, kick it with a disturbance, and watch overshoot, settling and steady-state error move as you turn each knob. Break it on purpose first. Then tune it until it behaves.

📈 live loop🎚️ tune Kp·Ki·Kd💥 disturbance📐 Z–N method
01 · The three terms, fast

What each knob actually does

The controller looks at error = setpoint − process value, and sums three responses. Each has one job, and one failure mode if you overdo it.

🟦 P · Proportional (Kp): push in proportion to the present error. More Kp = faster & stronger, but too much = oscillation. P alone leaves a permanent offset.

🟩 I · Integral (Ki): accumulate past error until it's gone. This is the term that kills the offset. Too much = more overshoot, slower settling and worse windup.

🟨 D · Derivative (Kd): react to the rate of change, so the controller anticipates and damps. Calms overshoot, but amplifies noise, so it's used sparingly (often zero).

➕ Output = Kp·e + Ki·∫e + Kd·(de/dt), clamped to 0–100%. The art is balancing the three so the process reaches setpoint fast, flat and stable.

02 · The trainer

🎛️ Tune a live loop

The grey line is your setpoint; the orange line is the process value chasing it; the faint blue is the controller output. Drag the knobs and watch the response redraw live. Try a preset, then hit Step setpoint or Disturbance to test it.

present error → strength
past error → kills offset
rate → damps overshoot
target value
Overshoot
–
Settling
–
SS error
–
Verdict
–
Drag a knob or pick a preset. Watching how the orange line misbehaves teaches you more than any rule of thumb.
03 · The method

How to tune it on purpose

Don't twiddle randomly. The classic manual recipe gets you 90% there in minutes:

  1. Set Ki = 0, Kd = 0. Raise Kp until the loop just starts to oscillate steadily, and note that gain.
  2. Back Kp off to about half that value. Now it's responsive but stable.
  3. Add Ki slowly until the steady-state offset disappears, but stop before overshoot grows.
  4. Add a little Kd only if you need to damp overshoot, and only if the signal isn't noisy.
  5. Test with a disturbance, not just a setpoint step. A loop tuned only for steps can be terrible at rejecting upsets.
  6. Re-check after any process change (load, temperature, product). Tuning is not "set once."

📐 Ziegler–Nichols formalises step 1: find the ultimate gain Ku (where it oscillates) and period Tu, then for a classic PID set Kp = 0.6·Ku, Ki = 1.2·Ku/Tu, Kd = 0.075·Ku·Tu. The result is aggressive: a good starting point, and rarely the final answer.

04 · The traps

Three gotchas that bite everyone

📈 Integral windup

When the output saturates (100%), the integral keeps piling up, so when you finally reach setpoint it overshoots badly. Fix: clamp the integral (anti-windup) when the output is maxed.

⚡ Derivative kick

A step change in setpoint makes de/dt spike, slamming the output. Fix: compute D on the process value, not the error ("derivative on measurement").

📻 Noise amplification

D multiplies high-frequency noise into a jittery output that wears valves. Fix: filter the input or keep Kd small/zero on noisy signals.

05 · Field kit

PID in one screen

  1. error = SP − PV · out = Kp·e + Ki·∫e + Kd·(de/dt)
  2. P = speed/strength · I = removes offset · D = damps (anticipates)
  3. Tune order: Kp first, then Ki, then a little Kd.
  4. P-only always leaves an offset; that's the I term's job.
  5. Clamp the integral (anti-windup) when output saturates.
  6. Take the derivative on PV, not error, to avoid set-point kick.
  7. Keep Kd small or zero on noisy signals; filter the input.
  8. Always test disturbance rejection, not just setpoint steps.