Engineering · Simulator 091
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
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.
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?
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.
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.
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.
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.
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.