S9 · Lesson 15 · PID control
What the proportional, integral and derivative terms each do, the ideal and parallel forms, PID as a pair of zeros, filtering the derivative, avoiding derivative kick, and integrator windup with its cures
Somewhere around nine control loops in ten in industry run a PID controller: three terms, acting on the error now, on its accumulated past and on its trend. Thermostats, motor drives, power supplies, chemical plants and quadcopters all use it, because three knobs are enough to make most plants behave and because each knob has a clear physical meaning. This lesson takes the controller apart term by term and covers the practical details that separate a textbook PID from one that works on real hardware.
- PI control of a first-order plant (DC gain 1, time constant 1 s), , against proportional control alone (dashed).
- Proportional alone settles short of 1 by . The integral term removes that error, more quickly the smaller is.
- Too small a and the loop overshoots and rings: the integrator keeps pushing because it remembers the error that built up on the way.
Predict
A PI controller's integral term is . While the actuator is saturated, the error stays large for several seconds. What happens when the output finally reaches the setpoint?
That's integrator windup. While the actuator was pinned at its limit, the integral kept accumulating error that the actuator couldn't act on. At the setpoint the error is zero but the integral term is still large, holding the actuator at full drive, so the output sails past and stays past until enough negative error has accumulated to bring the integral back down. Every practical PID includes anti-windup.
Name it
The three terms
with and in the parallel form.
- P reacts to the present error. Alone, it leaves a steady error on type-0 plants.
- I reacts to accumulated error and removes steady error (lesson 10), at the cost of phase lag.
- D reacts to the error's slope, predicting it about ahead, which adds damping.
PID as zeros
a pole at the origin and two zeros, real when . A common design puts the zeros on the plant's slow poles.
Practical details
- Derivative filter: a pure derivative amplifies noise without limit. Use with N between 5 and 20; the filter pole is at , and the D term's gain stops rising at .
- Derivative on measurement: differentiate instead of , so a step in the setpoint doesn't produce an impulse ("derivative kick").
- Anti-windup: stop integrating while the actuator is saturated (clamping), or feed the difference between the commanded and actual actuator signal back into the integrator through a gain (back-calculation), with around .
- Bumpless transfer: when switching from manual to automatic, initialize the integrator so the output doesn't jump.
Worked example
The motor of lesson 2, , needs a speed loop with a 2 ms closed-loop time constant and no steady error. Design a PI controller.
Show the solution
- Put the integral zero on the plant pole.
- The loop. It becomes a pure integrator:
- The closed loop. It's with
- Gains for 2 ms.
- Check the response. The step response has no overshoot and settles within 2% in 7.8 ms (3.9τ).
- When cancelling is safe. Cancelling a stable, well-known plant pole like this is safe; lesson 4 explains why an unstable one must never be cancelled.
Answer = 0.4 and = 16 ms ( = 25 per second), which settles within 2% in 7.8 ms with no overshoot.
Worked example
A plant needs a 0.1 s closed-loop time constant. Design a PID that cancels both poles.
Show the solution
- Match the numerator to the plant's poles.
- Read off the times.
- The loop. giving .
- Gains for 0.1 s.
- The derivative filter. In practice the derivative needs a filter, say N = 10 (a pole at 60 rad/s), which slightly changes the result.
Answer = 12, = 1.2 s and = 0.167 s, so = 10 and = 2.
Worked example
A PID with = 2, = 0.1 s and a derivative filter with N = 10 acts on the error. The setpoint steps by 1. What does the derivative term do?
Show the solution
- High-frequency gain. The filtered derivative has high-frequency gain .
- The kick. A unit step in the error produces an instant kick of 20 in the output, decaying with time constant
- Why it matters. That spike can saturate the actuator and jolt the mechanism.
- The fix. Taking the derivative of the measurement instead of the error removes the kick, since the measurement can't step; disturbances still get the full derivative action.
Answer it kicks the output by 20 at the instant of the step, and the kick decays with a 10 ms time constant.
Check
A PID has = 2 and = 0.05 s. What's its integral gain ?
Check
A plant with τ = 50 ms gets PI control with = τ. What gives a closed-loop time constant of 5 ms?
Check
PI control with = τ = 100 ms and = 1 on a plant with DC gain 4. What's the closed-loop time constant?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
A PID has = 2 s and = 0.05 s. Where is its zero nearer the origin?
Write units the way you normally would: 1.5 rad/s and 1500 mrad/s are the same answer.
Check
A derivative term has = 0.1 s and N = 5. Where's the filter pole?
Write units the way you normally would: 1.5 rad/s and 1500 mrad/s are the same answer.
Check
A PI controller ( = 1, = 0.2 s) is saturated for 8 s with an error of 10 that it can't act on. Without anti-windup, how much does its integral term grow?
Check
A PID with = 2 and = 0.05 s has a derivative filter with N = 20, and its derivative acts on the error. The setpoint steps by 1.
(a)
How big is the derivative term's initial kick?
(b)
With what time constant does it decay?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
A PID in standard form has gain K, integral time T and derivative time D.
Step 1
What is ?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What is ?
Step 3
What is the product of its two zeros?
Explain why
Why does a PID's derivative term need a filter?
A pure derivative has gain proportional to frequency, so it amplifies fast changes without limit. Measurement noise and quantization steps are fast, so an unfiltered D term turns them into large, jittery actuator commands that waste energy, heat motors and can saturate the actuator. The useful part of the derivative action is at frequencies around the loop's crossover, where it adds phase lead and damping. A first-order low-pass on the derivative, with its pole N times above , keeps the lead where it's needed and caps the gain at high frequencies at N times the proportional gain.
Practice
Keep practicing
10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.