Home · Module 2 · Control Systems

PID Control — tune it live

A cart on a track wants to reach a setpoint. Tune the Proportional, Integral, and Derivative gains until it lands smoothly. Click the track to move the setpoint.

PID gains

8.0
0.5
2.0

Plant disturbance

1.0
0.5

Live state

Setpoint300
Position
Error
P term
I term
D term
Total force

What each term does

P — Proportional

Force ∝ current error. Pull harder when far away. High Kp → fast response but overshoot & oscillation. Low Kp → slow, often steady-state error.

I — Integral

Force ∝ accumulated error over time. Kills steady-state offset (e.g. friction holding the cart back). Too much Ki → wind-up & slow oscillation.

D — Derivative

Force ∝ rate of change of error. Acts like a brake when approaching the target. Damps overshoot & oscillation, but amplifies sensor noise.

u(t) = Kp·e(t) + Ki·∫e dt + Kd·(de/dt)
e(t) = setpoint − position

Tuning hint — Start with Kp only (set Ki = Kd = 0). Increase Kp until you see oscillation, then back off ~30%. Add Kd to damp the oscillation. Add a little Ki last to eliminate any remaining offset. This is the classic Ziegler-Nichols heuristic.