SimuVeda

Engineering · Simulator 091

PID Control

A controller pushes a mass on a spring to a target position. Tune the three PID gains, then knock the system with a disturbance or limit how hard the motor can push. Watch how each gain changes the response, and find settings that are fast, stable and accurate.

How the model works

The plant is a mass on a spring with friction: m x'' + c x' + k x = u + d with m = c = k = 1. The controller measures the position x, compares it with the setpoint r, and sets the force

u = K_p e + K_i ∫e dt − K_d dx/dt, e = r − x

Proportional action pushes harder the further away the mass is. Alone it leaves a steady-state error, because the spring needs a constant force to hold the mass away from its rest point: with a P controller the mass settles at K_p / (k + K_p) of the target. Higher K_p shrinks the error but makes the response more oscillatory.

Integral action accumulates past error and keeps pushing until the error is zero, removing steady-state error, at the cost of more overshoot. Derivative action opposes motion, adding damping. Here it acts on the measured velocity rather than the error, so a sudden setpoint change does not cause a "derivative kick".

Real actuators have limits. When the force saturates, the integral keeps growing (windup) and causes extra overshoot; anti-windup stops integrating while the output is saturated.

Linear plant, continuous control simulated with 1 ms steps, ideal sensor apart from the optional noise (which is smoothed by a 5 ms filter). Overshoot is measured relative to the final value; settling uses a ±2% band. The disturbance force is applied at t = 10 s.

Guided experiments

  1. Proportional only. K_p = 10. Prediction: a fast but very oscillatory response with about 62% overshoot, settling at 0.91 instead of 1: a 9.1% steady-state error, 1/(1 + 10).
  2. Add derivative. K_p = 10, K_d = 4. Prediction: the extra damping cuts overshoot to about 3% and settling time to under 2 s, but the 9.1% error remains.
  3. Add integral. K_p = 10, K_i = 5, K_d = 4, then push the mass with a −5 N disturbance at 10 s. Prediction: the error goes to zero, with about 14% overshoot. The disturbance knocks the mass down to about 0.6, and the integral brings it back to 1. With PD alone the same push would leave it at about 0.45.
  4. Integral windup. PID with the force limited to ±3 N, without and with anti-windup. Prediction: without anti-windup the stored integral causes about 21% overshoot; with anti-windup it drops to about 4%.

Challenge

With P control only on this plant (k = 1), what gain K_p keeps the steady-state error below 2%? What happens to the oscillation as you raise K_p that far?

Reveal the explanation

The error is k / (k + K_p) = 1 / (1 + K_p) < 0.02, so K_p > 49. The natural frequency √(1 + K_p) rises to about 7 rad/s while the damping c = 1 stays the same, so the damping ratio falls to about 0.07 and the response rings for many cycles with about 80% overshoot. That is why integral action, not a huge K_p, is used to remove steady-state error.

References

  • Åström, K. J. and Murray, R. M., Feedback Systems: An Introduction for Scientists and Engineers, 2nd ed. (2021), ch. 11.
  • Åström, K. J. and Hägglund, T., Advanced PID Control (2006), ch. 3.
  • Ogata, K., Modern Control Engineering, 5th ed. (2010), ch. 5 and 8.