Ground Embedded KO Subscribe

3D Labs

PID Control

Move Kp, Ki and Kd and see how overshoot, settling time and steady-state error of the step response change.

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

  1. Press P only and raise Kp slowly. The arm reaches the target faster, but swings past it and back more and more.
  2. 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.
  3. 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.
  4. Raise Kd. It brakes the arm's speed and the oscillation shrinks.
  5. 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.

FREE PDFGet the 3 free ebooksIf you want what you just ran written down: BLDC motor control, serial communication and sensors at book length. PDFs are in Korean.Get them free →

This lab is also available in Korean. More labs: all 3D labs.