Control Systems
What is steady-state error, and how does the I term fix it?
Steady-state error is the gap that's left between a control loop's target and where the system settles. A proportional controller has one whenever its idea of the load is wrong: a drone told it needs 9.8 units of thrust to hover, but carrying a parcel that needs 10.8, settles a little below its target and stays there. Adding an integral term, the I in PID, removes it.
Where the gap comes from
The P controller's thrust is 9.8 + Kp × error. On target the error is zero, so the thrust is exactly 9.8, which is 1.0 short of what the loaded drone needs. It sinks until the error makes up the difference:
So it hangs at 9.75 m, for ever. That standing gap is the droop. Double the gain and it halves, to 0.125 m, but it never reaches zero: P can only push when there's error. Push the gain high enough to make the droop tiny and the overshoot comes back.
Add up the error
The fix is to keep a running total of the error, and push in proportion to that too:
integral = integral + error * 0.01; // 0.01 s per step
thrust = 9.8 + 4.0 * error + 1.0 * integral - 3.0 * v;
While the drone hangs 0.25 m low, every step adds a little to integral. The total grows, its push grows, and the drone creeps upward. The 0.01 is the step time, so the total is error × seconds.
Live experiment
Close the last quarter metre
The drone carries a parcel, so gravity pulls at 10.8 while the code adds 9.8 for hover: thrust = 9.8 + 4 × error − 3 × v. It hangs at 9.75 m. At 4 s the I term switches on. Ki 0.5 creeps up slowly; Ki 1 or 2 lifts it to 10 m; Ki 4 nudges past first.
“The last inch” is lesson 5 of 6 in Feedback Falls, Control Systems World 1. Free with an account. Lessons unlock in order, so you’ll do the 4 before it first.
Why it lands exactly
The total only stops changing when the error is zero. So the drone can't settle anywhere else: anywhere below 10 m and the total keeps growing; above, it shrinks. On target it holds still at just the value that makes up the parcel's missing 1.0. Nobody told the controller about the parcel. The integral learned it.
Where you'll meet it
Cruise control holds exactly the set speed up a long hill because of an integral term; with P alone it would settle a little slow on every climb. Ovens, incubators and 3D printer hot ends hold their temperature exactly the same way. The order for tuning a full PID loop follows from this: P to get there, D to stop the overshoot, and a small I last, for the error that remains.
Free lesson
Now build it yourself
Each lesson comes in three short parts: see the idea, try it on a live board, then build it yourself, with quick checks as you go.
“The last inch” is lesson 5 of 6 in Feedback Falls, Control Systems World 1. Free with an account. Lessons unlock in order, so you’ll do the 4 before it first.
Or start from the very first lesson, no account neededPractice questions
Three quick questions from the lessons. Pick an answer to check it.
Show the answer
Answer: About 0.25 m below the target, where 4 × error makes up the missing 1.0. It needs one extra unit of thrust, and the only place it can come from is Kp × error. 4 × 0.25 is 1, so it hangs a quarter of a metre low. That's the droop.
- Why not “Above the target”? Above the target the error is negative and P takes thrust away, so it would sink even faster.
- Why not “Exactly on target”? On target the error is zero, so P adds nothing and the thrust is 9.8, short of the 10.8 the parcel needs. It sinks.
- Why not “On the ground”? P still pushes harder the lower it is. It only needs a quarter metre of error to make up the missing 1.0, so it hangs just short.
Show the answer
Answer: Stays at the value that holds it there. The integral only changes while there's error. On target it stops changing, holding exactly the extra push the load needs.
- Why not “Keeps growing”? The total only grows while there's error. With the error at zero it stops changing.
- Why not “Falls to zero”? If the total fell to zero the extra push would vanish and the drone would droop again. It holds the value the parcel needs.
- Why not “Reverses”? It would only shrink if the error turned negative, above the target. Sitting exactly on target, it holds still.
Show the answer
Answer: integral = integral + error * 0.01;. The total has to grow each step by this step's slice of error. The other options replace it instead of adding, so it never accumulates.
- Why not “integral = error * 0.01;”? That's one step's slice of error, thrown away the next step. The total has to carry its old value forward.
- Why not “thrust = integral;”? That sets the thrust and throws away every other term, without ever keeping a total.
- Why not “integral = error;”? That replaces the total with this step's error every time, so nothing ever adds up.
“The last inch” is lesson 5 of 6 in Feedback Falls, Control Systems World 1. Free with an account. Lessons unlock in order, so you’ll do the 4 before it first.
Questions people ask
How do you calculate the steady-state error of a P controller?
Work out the push the controller is missing and divide by the gain. A drone that needs 1.0 more thrust than its code assumes, with Kp 4, settles where 4 × error = 1.0: 0.25 m low. With Kp 8 it settles 0.125 m low.
Why not just turn up the proportional gain?
A bigger gain shrinks the droop but never removes it: some error is always needed to make the extra push. And a big gain brings back overshoot and ringing. The integral term removes the error completely with a small gain.
Is droop the same as steady-state error?
Yes. Droop, offset and steady-state error all name the gap that's left once the response has settled. Control engineers say steady-state error; people tuning drones and heaters often say droop.
Can the integral term cause overshoot?
Yes. During a long climb the error is big for a while, and the total builds up. A large Ki turns that stored total into a push that carries the system past the target. That's integral windup; a small Ki and a cap on the total prevent it.
Related topics
- PID control explainedWhat the P, I and D terms each do, shown on a drone climbing to 10 m.
- What is integral windup, and how do you stop it?When the motors max out, the I term keeps counting, and pays it back as overshoot.
- What is proportional control?Push hard when far away and gently when close: thrust = 9.8 + Kp × error on a live drone.
- What is feedforward control?Put in what you already know the system needs, and let feedback fix the rest.