EN
ControlBasicPIDclosed loopservo

Closed-loop control (PID)

In 30 secondsA PID compares what you want with what you measure and corrects using three terms: P looks at the present, I at the past and D at the future.

Also available in: Català · Castellano

The idea

A closed loop adds a sensor: you compare what you wanted (setpoint) with what happened (measurement) and correct.

  • Error = setpoint − measurement
  • The controller turns the error into a command: u = Kp·e + Ki·∫e dt + Kd·de/dt

You don’t need to memorise the formula, just that there are three terms.

The three terms

  • P (present): pushes in proportion to the error. Under a constant load it leaves a steady-state error (load / Kp).
  • I (past): accumulates error until it is gone. Too much and it oscillates.
  • D (future): watches how fast the error changes and damps the overshoot.

Analogy: P is turning the steering wheel, I is noticing you’ve been drifting for a while, D is easing off the accelerator when you see the traffic light.

Tuning recipe

  1. Start with P only and raise it until it oscillates a little.
  2. Add D to calm it down.
  3. Add I only if a constant error remains.

In the demo, try the presets in order (small P, P only, P too large, PD, PID) and press “kick”.

Common questions

Why do we need I if P already corrects? Under a constant load P alone falls short: it needs some error to push. I accumulates that error and drives it to zero.

Interactive demo

Related concepts