🦾 Robot Arm PID Lab: Gravity, Saturation and Integral Windup

What to do

A one-joint robot arm lifts a payload. Tune Kp, Ki, Kd and watch the step response. Press New setpoint or drag the Setpoint slider to move the target; Kick hits the arm with a torque pulse. Try the presets: each one shows a different regime (steady-state error, ringing, windup).

Presets

Controls

Live readouts

Numerical checks

The science

Plant. A uniform link (mass m, length L) plus payload mp at the tip, angle θ above horizontal: Jθ'' = τ − bθ' − (m/2+mp) g L cosθ, J = mL²/3 + mp L².

Controller (1 kHz). τ = Kp e + Ki ∫e dt − Kd θ', clipped to ±τmax. The derivative acts on the measurement (no kick on setpoint change). Anti-windup = conditional integration: the integrator freezes while the actuator is saturated and the error would push it further.

Linear theory. With g=0, Ki=0 and no saturation: ωn = √(Kp/J), ζ = (b+Kd)/(2√(Kp J)), overshoot Mp = exp(−πζ/√(1−ζ²)). With gravity and P only, the arm settles where Kp(r−θ) = (m/2+mp) g L cosθ: a permanent error that the I term removes.

Honest simplifications. Ideal torque source (no motor electrical dynamics, no gearbox backlash), viscous friction only, noise-free angle sensor, semi-implicit Euler at 1 ms. The torque limit and masses are illustrative, not from a specific robot.