SimuVeda/ Engineering

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.

CollegeCollege control engineering

Experiments 0 of 0 Challenge not tried

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.

Related simulators

Worked example

Plant: a 1 kg mass on a spring k = 1 N/m with damping c = 1 N·s/m. With a PD controller the closed loop is s² + (1 + Kd)s + (1 + Kp).

P only, Kp = 10: ωn = √11 ≈ 3.32 rad/s and ζ = 1 / (2 × 3.32) ≈ 0.15. Overshoot e−πζ/√(1−ζ²) ≈ 62%. It settles at 10/11 ≈ 0.91, a 9% error.

Add Kd = 4: ζ = 5 / (2 × 3.32) ≈ 0.75, overshoot ≈ 3%, settling time about 4 / (ζωn) = 4 / 2.5 ≈ 1.6 s. The 9% error is still there.

A −5 N push with PD only shifts the mass by −5 / 11 ≈ −0.45 m, to about 0.45. Only integral action removes such an offset.

Load P only, then PD, and read the overshoot.

Common questions

What does each term in a PID controller do?

P pushes in proportion to the current error. I adds up past error and removes steady offsets. D reacts to how fast the error is changing and damps overshoot.

What is integral windup?

When the actuator is at its limit, the integral keeps growing even though it cannot push harder. When the error finally changes sign, the large stored integral causes a big overshoot. Anti-windup stops it from growing while saturated.

How do you tune a PID controller?

A common way is to raise P until the response is fast with some ringing, add D to damp it, then add I slowly to remove the offset. Methods like Ziegler–Nichols give starting values.

Keyboard shortcuts

Space
Play or pause
S
Step
R
Reset
F
Full screen
?
Show this list