PID Control
Move Kp, Ki and Kd and see how overshoot, settling time and steady-state error of the step response change.
ANGLE0°Target 75°
Target angleErrorA weight is hung on the arm at 2 s
Loading the 3D scene
Gains
Step response Target 1 = 75°
The yellow dot is the arm position. The weight is hung at the dashed vertical line.
Performance
- Overshoot
- Settling time (2%)
- Error left after the weight
Try this
- Press P only and raise Kp slowly. The arm reaches the target faster, but swings past it and back more and more.
- At 2 seconds a weight is hung on the arm. With P control alone the arm stops a little below the target. The red arc is the remaining error.
- Press PI. The integral term pushes the remaining error out bit by bit and lifts the arm back to the target, at the cost of more oscillation.
- Raise Kd. It brakes the arm's speed and the oscillation shrinks.
- Lower Kp and raise only Ki, and the arm swings wider and wider until it diverges. Gains have limits.
What is modelled
The plant is a servo that positions an arm with a motor. As a transfer function:
G(s) = K / ( s (τs + 1) ), K = 8, τ = 0.15 s
The target is 1, a constant load is applied at 2 s, and the control period is 1 ms. The derivative acts on the measurement, not the error, so the output does not spike when the target changes suddenly.
What each gain does
| Gain | Reacts to | Improves | Worsens |
|---|---|---|---|
| Kp | present error | response speed | overshoot |
| Ki | accumulated error | steady-state error | overshoot, stability |
| Kd | rate of change | overshoot | noise sensitivity |
In real motor control the output hits a voltage limit, so anti-windup is also needed to stop the integral growing without bound.
This lab is also available in Korean. More labs: all 3D labs.