One Sampled Update, With Anti-Windup
One Sampled Update, With Anti-Windup
Ada re-derives this chapter’s own numbers step by step, at full precision
ADA · CALCULATION AUDIT
One Sampled Update, With Anti-Windup
A pump controller leaves manual mode and returns to automatic mode after the actuator was saturated for several minutes, and the first automatic command overshoots badly. The chapter’s implementation trace calls for exactly the fields that failure needs — the integral accumulator, the saturation flag, and the manual-to-automatic reset rule — but never runs those fields through one sampled update. This audit asks the question that trace requirement invites: does holding the integral term while the actuator is pinned at its limit actually prevent the overshoot, or does the stored error keep climbing every saturated tick?
Companion to the chapter Lab: PID Implementation — every number here comes from that chapter.
See the relationship before changing it
The figure reads from left to right. The blue card is measured process value. The middle card applies this page's rule. The green card is control error. Walk the arrows once: set the input, apply the rule, then read the result with its unit.
The retained audit below checks several chapter fixtures. This model keeps those stated values fixed and changes only measured process value, so the numeric fixture does not switch without explanation.
Derive the baseline in four named moves
- 1
Name the input. The chapter baseline is 62 units.
- 2
Name the relationship. error = 80 setpoint - measured value
- 3
Substitute with units. 80 - 62 = 18.0 units
- 4
Read the result. Keep the unit beside the value. Use it only inside the technical boundary on this page.
Predict, then change measured process value
Try Predict the direction of error = 80 setpoint - measured value. Test another measured process value, then compare control error.
Observe The error shrinks toward zero as the measured process approaches its setpoint. Reset measured process value to 62 and compare control error.
Explain The error shrinks toward zero as the measured process approaches its setpoint.
Check yourself
What should you do before trusting a moved-control result?
What does this small model leave out?
Ready: use the stated baseline inputs, then compare each displayed result.
Ada: This chapter gives the PID recurrence symbolically and no universal gains, which is correct — a book cannot tune your loop. But the arithmetic of a single sample tick is worth pinning down, so here is one pass with clearly illustrative values (not tuning advice): Kp = 5.0, Ki = 0.8, Kd = 0.2, sample_period = 0.1 s, setpoint = 80, measured = 62, previous_error = 15, prior integral = 20, and actuator range 0 to 100.
- Error:
error = 80 - 62 = 18. - Proportional:
proportional = 5.0 x 18 = 90.0. - Integral candidate:
integral_candidate = 20 + 18 x 0.1 = 21.8. - Derivative (raw):
derivative = (18 - 15) / 0.1 = 30.0. - Unconstrained output:
90.0 + 0.8 x 21.8 + 0.2 x 30.0 = 90.0 + 17.44 + 6.0 = 113.44. - Clamp to the actuator range:
clamp(113.44, 0, 100) = 100.0, sosaturation = true. - Anti-windup: because the output is pinned at the maximum and the error would push it higher, the guarded update rejects the
21.8candidate and holdsintegral = 20.
The audit conclusion is what the chapter’s structure protects: without that last step the integral would climb to 21.8 this tick and keep climbing every saturated tick, so when the process finally caught up the stored term would command a large overshoot. Freezing accumulation while the actuator is saturated is the difference between a bounded recovery and a wind-up spike — and none of these numbers is a recommended gain, only a demonstration of the bookkeeping.
Every number above is taken from the chapter’s own material and re-derived step by step.