RobotGuide
Labs/PID Tuning Lab

Lab 1 / 15 · Interactive · real-time

PID Tuning Lab

Drag three gains and watch one control curve go from sluggish to oscillating and back to stable.

Math: High school math is enoughNo coding neededNo hardware needed≈ 8 min

Controller parameters

Kp proportional12
Ki integral5
Kd derivative0.6

Readouts

Overshoot—
Rise time 90%—
Settling time ±3%—
Steady-state error—

The plant is first-order inertia plus 40 ms of pure delay, modeling a real joint (motor fast, gearbox and communication lag behind). Pure delay is the root of overshoot.

What problem this lab solves

PID is the one thing in robotics that every role touches — the algorithm engineer uses it for outer loops, the embedded engineer for current loops, the mechanical engineer to explain why a joint shakes. Textbooks teach three letters; real machines teach three gains fighting each other.

How to read the figure

The horizontal axis is time, the vertical axis is position. The gray line is the target, the red dot is the measured value. Watch four numbers: overshoot (how far past the target), rise time (how long to reach 90%), settling time (how long to stay within ±2%), and steady-state error (how far off it ends). Higher Kp → faster rise, more overshoot; higher Kd → damps overshoot but amplifies noise; Ki accumulates → kills steady-state error, but slows things down and causes low-frequency wobble.

Hands-on

Push Kp from 1 to 12 and note the critical value where overshoot first exceeds 20%. Then fix Kp and raise only Kd: can it push overshoot back down, and what does it cost (watch the spikes on the curve)? This is the real answer to «how do you tune PID» in interviews.

Related topics

Next labs (in play-learn order)