Closed-Loop Control · PID live step-response simulation

The PID Tuning Bench

Tune a PID loop by feel — drag the three gains and watch the step response settle, oscillate, or run away in real time. Rise time, overshoot, settling time and steady-state error update live, so you can see exactly what each term does to a second-order plant like a servo axis.

1 Controller gains

Push harder on bigger error. More = faster, but too much overshoots and oscillates.

Accumulate past error to kill the steady-state gap. Too much adds overshoot and slow oscillation.

React to how fast error is changing — anticipation that damps overshoot. Too much amplifies noise.

2 Plant (the thing you're controlling)

Natural friction. Low damping = a springy, oscillation-prone plant that's hard to tune.

Transport lag before the plant responds. Even a little makes a loop far harder to stabilize.

Saturation — with integral, causes windup.

% — shows why high Kd hurts.

Step response

Blue = the setpoint (target). Brass = the plant output tracking it. The dashed band is ±2% settling tolerance. Watch overshoot, ringing, and how long it takes to settle as you drag the gains.

Response metrics

Rise time
s (10→90%)
Overshoot
% past target
Settling time
s (±2%)
Steady-state error
% offset
Peak time
s to max
Stability
loop behaviour
Method & assumptions

The loop. Each timestep the controller sees the error e = setpoint − output and commands u = Kp·e + Ki·∫e·dt + Kd·de/dt. That drives a second-order plant mass·ÿ + damping·ẏ = u — the same form as a servo axis (rotor inertia + friction), a mass on a spring, or an RLC circuit — integrated numerically with a small timestep.

What each term does. P pushes proportional to current error: raises speed and cuts steady-state error, but alone leaves an offset and, pushed too far, causes overshoot then oscillation. I integrates accumulated error to drive that offset to exactly zero — at the cost of added overshoot and slow oscillation. D responds to the rate of error, acting like anticipation that damps overshoot and settles faster — but it amplifies sensor noise, so it's the first term to back off on a noisy loop.

Metrics. Rise time (10→90% of setpoint), overshoot (% above setpoint at the peak), settling time (last entry into a ±2% band), steady-state error (residual offset), and peak time. Good tuning trades these against each other — you rarely minimize all at once.

Real-world traps modelled. Actuator saturation clips the command and, with integral action, causes windup — the integral keeps accumulating while the actuator is maxed out, then massively overshoots (a simple anti-windup clamp is applied). Dead time (transport delay) erodes stability margin fast. Sensor noise shows why aggressive derivative gain backfires.

Idealized single-loop, linear second-order plant. Real systems add nonlinearities, resonances, and discrete sampling — but the tuning intuition transfers directly.

The PID Tuning Bench · an intuition-builder for loop tuning — validate final gains on the real system, and consider model-based methods (IMC, pole placement) for critical loops.