Lite / Textbooks / Feedback and Control / Chapter 7
7. PID control
Introduction
Feedback with gain does two things to a first-order plant: it shrinks the steady error and it speeds the response, dividing the time constant by one plus the loop gain. On plants with more dynamics, though, gain also strips away damping. Integral action keeps pushing until the error is truly zero; derivative action looks at how fast the error changes and adds damping, while amplifying noise. Together they make PID.
Figure 7.1. τcl = τ / (1 + K·G) (described in words)
Two step responses: the open-loop plant with time constant 10 s, dashed, and the closed loop with K·G = 4, which responds with time constant 10 / (1 + 4) = 2 s and settles at 80% of the setpoint.
Explanation
Built from 5 School lessons. Each part is the lesson's own explanation.
7.1 Why P control never quite arrives
A cruise control set to 100 km/h settles at 96 km/h on a hill and stays there. Is it broken?
Error is the fuel
A P controller's command is proportional to the error. To hold a heater on, or a motor pushing uphill, it needs a steady command, so it needs a steady error. The loop settles at the point where the error is just big enough to produce the command that balances the plant.
The formula
For a plant with static gain K: e∞ = r/(1 + K·Kp). Loop gain KKp = 9 leaves 10 % error; 99 leaves 1 %. Raising the gain helps, but in real systems high gain amplifies noise, saturates actuators and, with any delay, threatens stability.
Disturbances too
A constant load (a hill, a heavier passenger, a draught) acts like an extra input. P control fights it but only by holding an error: the load's effect is divided by 1 + KKp, not removed. That is the lift's levelling error with a full cabin under P control.
Derivation: Steady-state error of P control
Plant τ·dy/dt + y = K·u. Controller u = Kp·e with e = r − y.
At steady state nothing changes, so dy/dt = 0 and y∞ = K·u∞ = K·Kp·(r − y∞).
Solve for y∞: y∞·(1 + K·Kp) = K·Kp·r, so y∞ = r·K·Kp/(1 + K·Kp).
Error e∞ = r − y∞ = r/(1 + K·Kp). It shrinks as K·Kp grows but is never zero for finite gain.
With a constant input disturbance d (u + d enters the plant), y∞ = (K·Kp·r + K·d)/(1 + K·Kp): the disturbance also leaves an error of −K·d/(1 + K·Kp).
Common mix-ups
A steady-state error means the controller is badly tuned.
✓ It is a structural property of P control on a plant without an integrator. Only very high gain shrinks it; integral action removes it.
Open the Lite lesson: Why P control never quite arrives
7.2 Feedback makes it faster
The heater is slow: τ = 10 minutes. A P controller makes the room reach its (slightly low) target in 1 minute. Where did the speed come from?
Same shape, faster clock
A P loop around a first-order plant is first-order again, but with τcl = τ/(1 + KKp). Loop gain 9 makes it ten times faster. The shape is the same exponential; only the timescale and the final value change.
Speed is bought with effort
At the instant of a step, the error is the whole step, so u(0) = Kp·r. Making the loop ten times faster means asking for roughly ten times the steady effort at the start. Real heaters, motors and valves have limits.
When the actuator saturates
If Kp·r exceeds the actuator's limit, the command is clipped and the plant just runs flat out: the response is set by the limit, not by τcl. The formula only applies while the loop stays linear. Check u(0) against the limit before trusting it.
Derivation: Closed-loop time constant with P control
Plant τ·dy/dt + y = K·u with u = Kp·(r − y).
Substitute: τ·dy/dt + y = K·Kp·r − K·Kp·y.
Collect y: τ·dy/dt + (1 + K·Kp)·y = K·Kp·r.
Divide by (1 + K·Kp): (τ/(1 + KKp))·dy/dt + y = (KKp/(1 + KKp))·r.
This is first-order again, with τcl = τ/(1 + K·Kp) and gain KKp/(1 + KKp) (giving the steady error from the last lesson).
Effort at t = 0: u(0) = Kp·r. Ten times faster with KKp = 9 needs an initial command Kp·r, roughly ten times the final effort. If the actuator saturates, the formula no longer holds.
Common mix-ups
Feedback can make any plant arbitrarily fast.
✓ Only up to the actuator's limits, the sensor's noise and the loop's delays. Past those, the formula fails.
Open the Lite lesson: Feedback makes it faster
7.3 More gain, less damping
On a first-order plant, cranking up P gain only helps. On a robot joint with inertia, it makes it shake. What's different?
The algebra
Plant τ²ÿ + 2ζτẏ + y = K·u with u = Kp·(r − y) gives τ²ÿ + 2ζτẏ + (1 + KKp)·y = KKp·r. Matching to the standard form: ωn,cl = √(1 + KKp)/τ and ζcl = ζ/√(1 + KKp). The stiffness went up; the damping didn't.
What it feels like
Raising Kp is like fitting a stiffer spring to the joint: it springs back faster and harder, so it overshoots. The steady error still falls as 1/(1 + KKp). You trade accuracy against wobble.
Derivative action is extra damping
A D term adds a force proportional to velocity: exactly what a physical damper does. With u = Kp·e − Kd·ẏ, the ẏ coefficient grows from 2ζτ to 2ζτ + K·Kd, raising ζcl back up. That's why motion controllers are almost always PD or PID.
Common mix-ups
If P control overshoots, the gain is too high, full stop.
✓ Lowering gain is one fix; adding damping (D) keeps the speed and accuracy while removing the overshoot.
Open the Lite lesson: More gain, less damping
7.4 I removes the error, D adds the damping
P gets you close. Which two extra terms get you exactly there, smoothly, and what does each cost?
Integral: memory of past error
u = Kp·e + Ki·∫e dt. The integral keeps adding up error, so the command keeps changing until e = 0. At steady state the integral alone supplies the command the plant needs. That is why PI removes steady-state error for steps and constant loads.
Derivative: brakes before the target
Kd·de/dt reacts to how fast the error is shrinking. As the output races towards the set point, D pushes back, like a damper. Many implementations differentiate the measurement, not the error, to avoid a 'kick' when the set point jumps.
The costs
Too much I: slow wobbles and overshoot, and windup when the actuator saturates (next lesson). Too much D: it amplifies sensor noise, because noise changes fast. Real D terms include a low-pass filter. P sets the basic stiffness; I and D trim accuracy and damping.
Common mix-ups
PID always needs all three terms.
✓ Many loops work best as PI (noisy, slow processes) or PD (when a plant already integrates, like position from velocity).
Open the Lite lesson: I removes the error, D adds the damping
7.5 What I and D buy, and what they cost
Integral action wipes out the lift's levelling error. So why do engineers sometimes switch it off while the lift is moving?
Integral: memory of past error
The integral term adds up error over time. As long as any error remains, it keeps growing and keeps pushing, so it can supply the steady push P needed error for. Result: zero steady-state error to a step or a constant load. Cost: stored push takes time to unwind, so it tends to add overshoot and slow oscillation.
Derivative: a brake on fast change
The derivative term reacts to how fast the output is changing and pushes against rapid movement, like a shock absorber. It adds damping, reducing overshoot and ringing. Cost: differentiating a noisy signal amplifies the noise, so real controllers filter the derivative and often take it from the measurement rather than the error.
Windup
When the actuator saturates (full power), the error stays large and an unprotected integral grows far beyond anything useful. On arrival it overshoots badly. Anti-windup (for example, stopping integration while saturated) prevents this. Always check integral control with realistic actuator limits.
Common mix-ups
PID is always better than P.
✓ Each extra term adds tuning effort and risks (overshoot, noise, windup). P is fine when its steady-state error is within spec.
Open the Lite lesson: What I and D buy, and what they cost
Worked examples
Why P control never quite arrives: example 1
A heater loop has K = 0.5 °C per % power and Kp = 18 %/°C. Set point 60 °C above ambient. Steady error?
Solution
KKp = 9. e∞ = 60/10 = 6 °C. It settles at 54 °C above ambient.
Feedback makes it faster: example 1
τ = 20 s, K = 2. Required τcl = 2 s. What Kp, and what initial command for a step of r = 5 if the actuator limit is ±40?
Solution
1 + 2Kp = 10 → Kp = 4.5. u(0) = 4.5 × 5 = 22.5, within ±40, so the formula holds.
More gain, less damping: example 1
Plant ζ = 0.8, K = 1. Which Kp gives ζcl = 0.4?
Solution
0.8/√(1 + Kp) = 0.4 → √(1 + Kp) = 2 → Kp = 3. Expected overshoot 25 %.
I removes the error, D adds the damping: example 1
PI controller, Kp = 2, Ki = 1, plant K = 1. At steady state with set point 1, what is the integral value?
Solution
e = 0, so u = Ki·∫e = 1 × ∫e. The plant needs u = y/K = 1, so ∫e = 1. The integral has stored exactly the command the plant needs.
What I and D buy, and what they cost: example 1
A P-only lift stops 12 mm short at 450 kg. With PI it reaches the floor but overshoots by 6 mm before settling. Which term caused each behaviour?
Solution
The 12 mm shortfall is P's steady-state error from the constant load. PI removes it, but the integral's stored push causes the overshoot; anti-windup or a little derivative action can reduce it.
Interactive figures, in words
Figure 7.2 from Why P control never quite arrives
Set K = 1 and Kp = 3, then read the steady-state error. Increase Kp to 9, then 29. Write e∞ each time and check it against r/(1 + KKp). What would it take to make the error zero?
The P-control explorer shows the closed-loop response settling below the set point. With loop gain 3 it settles at 0.75 (25 % error); with 9 at 0.9; with 29 at about 0.97. The error shrinks with gain but never reaches zero.
Figure 7.3 from More gain, less damping
Choose P, actuator limit None. Raise Kp from 1 to 15 and note the overshoot. The plant has ζ = 0.7 and K = 1: predict each overshoot from ζ/√(1 + Kp) before reading it.
In the PID tuner with P control and no actuator limit, Kp = 1 gives a small overshoot. As Kp rises to 15, the response rises faster, settles closer to the set point and overshoots more, with visible ringing.
Laboratory
These run in a browser on the full site (they need a faster connection). Simulations are simplified educational models.
- Simulation OS: PID step response (Simulation OS experiment)
Add integral action to a P controller and show the steady-state error disappear; then add derivative action and measure the overshoot.
Open on the full site - Simulation OS: One robot joint (Simulation OS experiment)
Compare P, PD and PID on the same joint step and tabulate overshoot and settling time.
Open on the full site
Practice
Each question links to its Lite lesson, where your answer is checked on our server and a wrong answer gets a hint. Answers are never sent to your device.
- K = 2, Kp = 4, r = 10. What is the steady-state error?
Answer it in “Why P control never quite arrives” - K = 1. What is the smallest Kp that keeps the P-only steady-state error at or below 1 % of the set point?
Answer it in “Why P control never quite arrives” - τ = 6 s, K = 0.5, Kp = 10. What is τcl in seconds?
Answer it in “Feedback makes it faster” - τ = 12 s, K = 1. What Kp gives τcl = 1.5 s?
Answer it in “Feedback makes it faster” - A second-order plant has ζ = 0.9 and K = 1. With Kp = 8, what is ζcl?
Answer it in “More gain, less damping” - What does integral action remove that P alone cannot?
Answer it in “I removes the error, D adds the damping” - Why do many PID implementations differentiate the measurement instead of the error?
Answer it in “I removes the error, D adds the damping” - Why is derivative action often filtered?
Answer it in “What I and D buy, and what they cost”
Engineering applications
Drones
A quadcopter's attitude loops are PID controllers running hundreds of times a second. Derivative action damps the wobble, and integral action trims out an off-centre battery or a steady breeze.
Derivative on measurement
Taking the derivative of the error makes the controller kick violently when the setpoint jumps. Taking the derivative of the measurement instead gives the same damping without the kick.
Watch (optional)
Streaming video uses a lot of data. Everything you need is in the text.
- “What Is PID Control? | Understanding PID Control, Part 1” by MATLAB
- “Simple Examples of PID Control” by Brian Douglas
- “A PID Tuning Guide | Understanding PID Control, Part 4” by MATLAB
Summary
- P control on a first-order plant gives τcl = τ / (1 + K·G) and steady error 1 / (1 + K·G).
- On second-order plants more gain lowers damping, so overshoot grows.
- Integral action drives the steady error to zero; derivative action adds damping but amplifies noise.
- Use derivative on the measurement to avoid kicks when the setpoint changes.
Glossary
- PID controller
- A PID controller adds proportional, integral and derivative actions: present error, accumulated past error and predicted future error. Field Guide
- Integral action
- Integral action adds a term proportional to the error accumulated over time, so any persistent error keeps growing the command until the error is gone. Field Guide
- Derivative action
- Derivative action adds a term proportional to how fast the error (or measurement) is changing, braking the response before it overshoots. Field Guide
- Proportional control
- A proportional controller sets the command to a gain times the error: u = Kp × e. Bigger errors get bigger corrections. Field Guide
- Steady-state error
- Steady-state error is the error that remains after the response has settled and stopped changing. Field Guide
Project: P, PI, PID on one plant
Simulate a first-order plant with τ = 10 s and a small delay. Design a P, a PI and a PID controller, run the same step and the same load disturbance for each, and tabulate steady error, overshoot and settling time. Explain each difference using the ideas in this chapter.
Deliverables
- The simulation with all three controllers
- A table of metrics for step and disturbance
- An explanation of every trade-off you observed
Write it up on paper or in your own notes. Lite never stores what you write.
References
- Karl Johan Åström and Tore Hägglund (2006). Advanced PID Control. ISA – The Instrumentation, Systems, and Automation Society.
- Karl Johan Åström and Richard M. Murray (2008). Feedback Systems: An Introduction for Scientists and Engineers. Princeton University Press.
- J. G. Ziegler and N. B. Nichols (1942). "Optimum Settings for Automatic Controllers". Transactions of the American Society of Mechanical Engineers 64, 759–768.