Exercises — PID control — proportional, integral, derivative terms
Before we start, the four quantities we will use over and over (from the parent note, restated so this page stands alone):

Level 1 — Recognition
Problem 1.1
Match each symptom to the term whose job it is to cure it. (a) The system reacts too slowly. (b) It settles but always a little off-target. (c) It overshoots and rings.
Recall Solution
Each term has one signature disease-and-cure:
- (a) Too slow → boost ==== (Proportional). P is the present-error push; a bigger push means a faster response.
- (b) Steady offset → boost ==== (Integral). Only the integral remembers a persistent error and keeps ramping until the offset dies.
- (c) Overshoot / ringing → boost ==== (Derivative). D reacts to the rate , braking before you shoot past.
Answer: (a) P, (b) I, (c) D.
Problem 1.2
Write the error signal and evaluate it when and .
Recall Solution
. Plug in: The sign is negative, meaning we have overshot the target (we are above it). The controller will command in the direction that pulls back down.
Level 2 — Application
Problem 2.1
A reaction wheel holds a satellite's pitch at . A constant solar torque acts as a disturbance (output units). Using pure P with , find the steady-state error .
Recall Solution
WHAT we need: the resting error once everything stops changing. WHY this formula: at rest the control output must exactly cancel the disturbance, otherwise something would still be moving. With pure P the only output is , so at equilibrium A pure-P loop can shrink this but never zero it — zero error would give zero output, and then nothing fights the torque. This is exactly the steady-state error the integral is invented to kill.
Problem 2.2
Same satellite, now P + I. In steady state, what is , and what value does the integral output settle to?
Recall Solution
WHAT: find the resting error and resting integral value. WHY: the integrator changes its output at rate . For the whole system to stop changing, this rate must be zero: So the only resting state has zero error — the integral quietly climbs until it does. Its final value must supply the whole cancellation on its own: P contributes nothing at rest (because ), so the integrator alone holds off the disturbance.
Problem 2.3
Convert the continuous integral into the running sum a flight computer uses, with s and samples . Compute the running integral value after three samples (rectangle rule).
Recall Solution
WHY a sum: the computer only sees snapshots every . Each snapshot contributes a thin rectangle of area ; the integral is the total area, i.e. the sum of rectangles. This is what gets multiplied by to become . (See Laplace transforms & transfer functions for the continuous view.)
Level 3 — Analysis
Problem 3.1 (one discrete control update)
Given . The previous error , the current error , and the stored integral before this step . Compute .
Recall Solution
Build the three pieces, each answering its own question. Integral (past): add the newest rectangle, then scale. Proportional (present): react to the error right now. Derivative (future): the backward difference estimates ; error is falling, so this is negative — a brake. Total: Interpretation: even though the error is positive (still below target), the error is dropping so fast that D dominates and commands a slight reversal — this is the anti-overshoot instinct in action.
Problem 3.2 (sign census — cover every case)
For each situation give the sign of (take ) and say in words what D is doing: (a) rushing up toward from below; (b) overshot and coming back down; (c) frozen (steady); (d) drifting away from .
Recall Solution
D watches the rate of error, . Recall , so if rises, falls.
- (a) rising toward target ⇒ falling ⇒ ⇒ : brakes the approach to prevent overshoot.
- (b) overshot, now falling back ⇒ rising back toward 0 ⇒ ⇒ : helps the recovery.
- (c) steady ⇒ ⇒ : D says nothing at rest — which is why D alone can never fix a steady offset.
- (d) drifting away ⇒ growing ⇒ has the same sign as ⇒ reinforces the correction: fights the runaway early. The zero case (c) is the key insight: D contributes exactly nothing in steady state, so it can neither cause nor cure offset.
Level 4 — Synthesis
Problem 4.1 (diagnose and prescribe)
A drone altitude loop shows three faults across three test flights:
- Flight A: reaches target but ~4% below it, forever.
- Flight B: fast, but overshoots 30% and rings for several seconds.
- Flight C: after adding heavy D, the motors buzz/chatter even when hovering still.
For each, name the term to change and the direction of change, and explain the mechanism.
Recall Solution
- Flight A — persistent offset. Increase ====. A constant residual error means the loop rests where , which is nonzero only if . Adding/boosting integral action forces the resting condition , so the accumulator ramps the offset to zero. (This is type elevation — the integrator raises the system type by one.)
- Flight B — overshoot & ringing. Increase ====. Ringing means the approach is under-damped. D reacts to , subtracting command exactly when the error is collapsing fastest, adding damping without slowing the initial response.
- Flight C — motor chatter. Decrease ==== and/or filter it. Differentiation multiplies high-frequency sensor noise: tiny fast wiggles have huge slope, so explodes and D commands violent, useless twitches. Fix: small plus a low-pass filtered derivative.
Problem 4.2 (windup budget)
An actuator saturates at . During a large maneuver the error sits at for s while the output is already pinned at . With , how much extra integral output accumulates during saturation, and why is this dangerous?
Recall Solution
While saturated, the integrator keeps eating error even though the actuator can do no more. Over s at constant : This is stored on top of whatever was already there — a phantom command the actuator never actually delivered. When finally reaches target, the integrator must first unwind all before its output drops, so sails far past the target. This is integrator windup. Fix: anti-windup — freeze (or clamp) the integrator whenever the actuator is saturated, so no phantom charge builds. (Related tuning wisdom: Ziegler–Nichols tuning keeps modest partly for this reason.)
Level 5 — Mastery
Problem 5.1 (design from a spec)
You must control a slow thermal plant. Requirements: (i) zero steady-state error under a constant heat-loss disturbance; (ii) no more than mild overshoot; (iii) the sensor is noisy. Starting from a working P controller with , decide which terms to add, in what order, and justify each choice against the requirements. Then compute the steady-state integral output if the constant disturbance is .
Recall Solution
Reason term-by-term against the spec:
- Requirement (i) zero steady-state error ⇒ we must add I. Only the integral gives the resting condition . Keep modest to avoid windup on this slow plant.
- Requirement (ii) mild overshoot ⇒ add a small D for damping — but requirement (iii) noisy sensor means heavy D would amplify noise, so use a small, filtered derivative. If overshoot is already acceptable with P+I, you may even skip D (a PI controller is common on slow, noisy thermal systems).
- Keep for baseline speed. So the design is PI (optionally a filtered D), chosen because each requirement maps to exactly one term's job.
Steady-state integral output: at rest , so P contributes and D contributes . The integral must therefore supply the entire cancellation of the disturbance: The integrator's stored value settles to whatever makes ; the exact depends on , but the output is fixed by the physics.
Problem 5.2 (predict the full command)
A satellite pitch loop uses . At one instant: , previous error , stored integral (already updated), sample time . Compute , , , and the total . Then state which term dominates and what it physically means.
Recall Solution
Dominant term: D, and strongly negative. Even though there is still a positive error and a positive stored history, the error is collapsing very fast ( per second), so the derivative slams the brakes — the loop is aggressively preventing an overshoot. This is the "start un-turning early" instinct from the parent note, quantified.
Recall Self-test checklist (click to reveal)
Can you, without looking:
- State and why the sign matters (P1.2)?
- Compute for pure P and explain why I zeroes it (P2.1, 2.2)?
- Run one discrete PID update by hand (P3.1, 5.2)?
- Give the sign of in all four motion cases including the frozen case (P3.2)?
- Explain windup with a number and its fix (P4.2)?
- Design a PI/PID from a spec and find the resting integral output (P5.1)? If any is shaky, reopen that problem before moving on.