5 PID Control Theory
More
Depth: Practitioner
Progress saves as you read. Mark sections complete as you go; your progress appears in the sidebar.
5.1 Start With the Error You Can Measure
This section: Start With the Error You Can Measure
5.1.1 Tune for the Disturbance, Not the Demo
Proportional-integral-derivative (PID) control changes an output from the gap between a target and a measured result. Each part responds to that gap in a different way.
Picture a heated tank that must hold a set temperature. A calm demo may look stable. Opening the lid, adding cold liquid, delaying the sensor, or limiting heater power can expose a slow response, a lasting error, or repeated overshoot.
Start with the physical safe range and a way to stop the heater. Record target, measured value, output limit, sample time, and each disturbance. Change one tuning term at a time. Check rise, overshoot, settling, steady error, noise response, and recovery after the output reaches its limit.
Read the plot as a story. Where did the test start? When did the target change? How far did the value move past it? How long did the value take to settle? Did the output hit a limit? Did noise make it hunt? These plain checks come before any claim that the tune is good.
These results apply only to the tested plant, sensor, timing, and limits. A good graph does not prove safety. The deeper sections derive the three terms, show their interactions, and explain how delay, noise, saturation, and changing process behaviour limit the simple model.
A PID controller does not begin with three magic constants. It begins with a gap between what you want and what you can measure: temperature below a setpoint, tank level above a limit, or motor speed drifting away from target.
The proportional, integral, and derivative terms are three different answers to that gap. For an IoT device, the useful story is not “use PID” but “measure error, choose the correction, and prove the loop settles safely.” Start with one measured error before tuning anything.
5.2 Learning Objectives
This section: Learning Objectives — The overview depth layer below carries the loop map that connects setpoint, error, PID action, bounded output, sensor feedback, and review evidence.
By the end of this chapter, you should be able to:
- Explain the PID control equation without treating it as a black box.
- Describe how proportional, integral, and derivative actions change loop behavior.
- Identify steady-state offset, overshoot, oscillation, windup, and derivative noise sensitivity.
- Choose P, PI, PD, or PID based on response data rather than habit.
- Create a control-loop decision record that connects theory to implementation risk.
The overview depth layer below carries the loop map that connects setpoint, error, PID action, bounded output, sensor feedback, and review evidence.
5.3 Where This Chapter Fits
This section: Where This Chapter Fits — This chapter focuses on the theory behind the PID controller.
This chapter focuses on the theory behind the PID controller. Later chapters can tune gains, implement code, and evaluate applications; this one explains what the terms mean and what teams must check before those implementation choices are trusted.
Inputs
Setpoint, measured process variable, actuator limits, sample interval, sensor noise, disturbance behavior, and loop-safety requirements.Outputs
Term roles, configuration choice, stability cautions, proof questions, and a reusable control-loop decision record.Loop-Fit Habit
Ask, "Which term is solving which observed loop problem, and what new risk does that term introduce?"5.4 PID Equation
This section: PID Equation — Error is the setpoint less the measured value.
The continuous-time PID idea can be written in implementation-friendly form:
error = setpoint - process_variable
output = Kp * error + Ki * error_sum + Kd * error_rate
In that expression:
Error is the setpoint less the measured value. The gains act on now, past, and trend. Check the output limit.
Theory-to-Implementation Check
The equation is not complete until the loop record also names sample interval, output limits, integral limit, derivative filtering, and what happens when the actuator cannot follow the requested output.5.5 Term Behavior
This section: Term Behavior — The three terms can be understood as three views of the same error signal.
The three terms can be understood as three views of the same error signal.
Use Figure 5.1 to determine how proportional, integral, and derivative paths turn the same error history into distinct contributions to one control output.
Trace the command forward. Follow the measurement back. Read Figure 5.1 from the shared error input into the three parallel paths. The proportional branch scales the present error, the integral branch accumulates past error to remove persistent offset, and the derivative branch responds to the rate of change to add damping. Their outputs meet at the summing point, so the actuator command combines present, past, and trend rather than selecting one term. A tuning record should preserve each gain, sample interval, output limit, filter, and observed response because identical error traces can produce very different commands when any one path changes.
| Term | Responds To | Primary Benefit | Main Risk |
|---|---|---|---|
| Proportional | Instantaneous error magnitude. | Fast correction that moves the process toward the setpoint. | Too much gain can overshoot or oscillate; too little gain can leave offset. |
| Integral | Error that persists over repeated samples. | Removes steady-state offset caused by load, bias, or disturbance. | Can wind up when the actuator saturates or the process cannot respond. |
| Derivative | Error trend or rate of change. | Adds damping and can reduce overshoot. | Amplifies measurement noise unless filtered and sampled carefully. |
5.6 Everyday Analogy: Changing Lanes in a Crosswind
This section: Everyday Analogy: Changing Lanes in a Crosswind
A driver changing lanes on a windy freeway runs the same loop as a PID controller: setpoint is the desired lane position, process variable is the car position the driver’s eyes report back, error is the gap between them, and the steering wheel is the actuator that a crosswind disturbance keeps pushing off course. The analogy is useful precisely because it is a closed loop with the driver’s eyes as sensor; steering with eyes closed is the open-loop case, and it fails for the same reason an open-loop controller fails.
P: Instances of Error
A small, gradual steering correction that shrinks as the car nears the lane center is proportional control: the correction is scaled to how far off the target the car currently is. Turn the wheel too far (large Kp) and the car overshoots into the next lane, requiring a correction back, which overshoots again -- the same oscillation a high-gain P-only loop produces.I: Accumulation of Error
A steady crosswind can cancel out a fixed steering angle entirely, so the car keeps drifting straight no matter how the driver preset Kp. The driver responds by gradually increasing the steering angle until the car actually starts moving toward the lane again. That is integral action: it accumulates error over time and keeps adding correction until the offset a disturbance caused is cancelled out.D: Present Error vs. Last Checked
At higher speed, the same steering input moves the car across lanes faster, so the correction needs to ease off sooner to avoid overshoot. Derivative action anticipates that by reacting to how fast the error is changing, not just its size, trimming the steering angle down as the car closes in on the target lane -- damping the overshoot that P and I alone would cause.A compact way to keep the three terms straight: proportional corrects instances of error, integral corrects the accumulation of error, and derivative corrects the present error against the error the last time it was checked. In practice PI is the most common configuration, because derivative gain is the hardest of the three to tune — if the PI response is already acceptable for the loop’s timing and disturbance profile, that is usually where the design should stop.
5.7 Signal and Term Selection Addendum
This section: Signal and Term Selection Addendum — Most PID selection mistakes start as signal or term-selection mistakes.
Most PID selection mistakes start as signal or term-selection mistakes. Define the loop signals before tuning, then enable only the terms that solve an observed control problem.
| Loop area | Proof to record |
|---|---|
| Signal names | Setpoint or target band, process variable, error sign convention, controller output, manipulated variable, and sample period. |
| Proportional baseline | P-only response, acceptable offset, overshoot or oscillation trace, and actuator output remaining inside limits. |
| Integral decision | Persistent offset, holding-command need, actuator saturation risk, accumulator limit, anti-windup policy, and recovery behavior. |
| Derivative decision | Overshoot or ringing trace, measurement quality, filter choice, setpoint-kick handling, and sample-rate justification. |
| Mode choice | P, PI, PD, or PID selected from observed symptoms rather than from controller feature availability. |
| Loop proof log | P/I/D contributions, saturation state, filtered derivative path, output clamp, outcome trace, owner, and recheck trigger. |
For example, a fan speed loop with a stable P-only response but persistent load offset justifies PI plus an accumulator limit. Derivative action should wait until overshoot or ringing is visible and the measurement can support a useful rate estimate.
5.8 Reading Response Shape
This section: Reading Response Shape — PID theory becomes practical when a team can look at a response shape and connect it to a term decision.
PID theory becomes practical when a team can look at a response shape and connect it to a term decision.
Use Figure 5.2 to map persistent offset, overshoot, oscillation, windup, and noisy output to the PID term or safeguard that should be investigated first.
Compare the target and response. Then inspect the error. Read Figure 5.2 from persistent offset to the integral question, then compare overshoot and oscillation with proportional gain and damping. Windup points beyond gain selection to saturation handling, while a noisy output makes derivative filtering and sensor quality the first checks. These are diagnostic routes, not automatic tuning instructions: one response shape can have several physical causes. Record the observed trace, operating condition, limit state, and proposed change, then repeat the same disturbance test. The before-and-after response is the evidence that the selected term or safeguard addressed the actual problem.
Persistent Offset
If the process settles away from the setpoint, proportional action may not be enough. Integral action can remove the offset, but only if windup is controlled.Overshoot
If the process crosses the target too aggressively, reduce excessive gain, check integral buildup, or add derivative damping when the measurement is clean enough.Oscillation
If the process cycles around the target, the loop may be too aggressive, delayed, undersampled, poorly filtered, or limited by actuator behavior.5.9 Configuration Choice
This section: Configuration Choice — Use the simplest controller that solves the observed loop problem with acceptable risk.
Use the simplest controller that solves the observed loop problem with acceptable risk.
The next choice is defensible only if the reader can see that “PID configuration choice map from P-only to PI, PD, and PID based on offset, overshoot, noise, and actuator limits” is explicit in the diagram. Inspect Figure 5.3 before moving from Configuration Choice to the operational decision.
Three labels organize Figure 5.3: offset OK, offset + damping, and sample delay. Follow their roles rather than the page geometry. They jointly show “PID configuration choice map from P-only to PI, PD, and PID based on offset, overshoot, noise, and actuator limits” is explicit in the diagram, which turns Configuration Choice into a checkable requirement for the rest of the chapter.
| Configuration | When It Fits | Proof Needed |
|---|---|---|
| P | The process tolerates some offset and needs a simple proportional response. | Stable response, acceptable offset, and actuator output inside limits. |
| PI | Offset must be removed and the process is slow enough that derivative damping is not needed. | Integral limit, anti-windup behavior, and disturbance recovery trace. |
| PD | Overshoot must be damped but persistent offset is acceptable or handled elsewhere. | Filtered derivative path, noise check, and sample-rate justification. |
| PID | Offset, overshoot, and disturbance response all need active control. | Term-by-term tuning record, saturation check, noise filter, and safety bounds. |
5.10 Windup and Derivative Filtering
This section: Windup and Derivative Filtering — Two PID theory mistakes show up repeatedly in IoT and process-control reviews.
Two PID theory mistakes show up repeatedly in IoT and process-control reviews.
Integral Windup
When an actuator is already at its limit, the integral term may keep accumulating error. When the process finally responds, the stored integral can drive a large overshoot. Check clamping, conditional integration, or reset behavior.Derivative Noise
Derivative action magnifies rapid measurement changes. A noisy sensor can make the controller output jitter unless derivative filtering, sensor filtering, and sample timing are checked together.5.11 Control-Loop Decision Record
This section: Control-Loop Decision Record — A PID loop record keeps theory, tuning, implementation, and proof connected.
A PID loop record keeps theory, tuning, implementation, and proof connected.
Use Figure 5.4 to check that a control-loop decision keeps its goal, term choice, tuning proof, saturation handling, filtering, safety limit, owner, and recheck trigger together.
Read Figure 5.4 from the loop goal and term choice into tuning evidence and failure controls. Saturation and anti-windup belong beside output limits; filtering belongs beside the sensor noise and delay it changes. The safety limit constrains what tuning may attempt, while the owner accepts residual behaviour and responds to faults. The final change trigger names when load, plant, actuator, sensor, firmware, sample interval, or limit changes invalidate the record. This layout prevents a gain set from travelling alone after the conditions and protections that made it acceptable have changed.
Record Template
- Loop goal: What setpoint and process variable define success?
- Controller choice: P, PI, PD, or PID, with the observed problem it addresses.
- Term proof: What response data justifies each enabled term?
- Limits: Output bounds, integral bounds, actuator saturation, and fail-safe state.
- Filtering: Sensor filtering, derivative filtering, and sample interval.
- Owner and trigger: Who rechecks the loop after sensor, actuator, load, or timing changes?
5.12 Process-System PID Addendum
This section: Process-System PID Addendum — PID is a system decision before it is a tuning exercise.
PID is a system decision before it is a tuning exercise. Keep the process boundary, placement, and output limits visible so the controller does not hide unsupported assumptions inside gain values.
| Loop item | Proof to keep |
|---|---|
| System placement | Local loop, edge coordination, or remote supervision, with proof that required correction is not stranded behind an unreliable path. |
| Loop signals | Setpoint, process variable, error sign, controller output, actuator command, sample period, and measurement validity. |
| Mode selection | P, PI, PD, or PID chosen from observed offset, overshoot, measurement quality, actuator limits, and recovery behavior. |
| Limits and protection | Output clamp, saturation flag, anti-windup rule, derivative filtering, manual mode, and fail-safe state. |
| Tuning proof | Baseline trace, changed term, disturbance check, command range, settling behavior, and the decision to keep, reject, or repeat. |
For a tank-level or ventilation loop, start with the simplest defensible mode. Add integral only when persistent offset matters and anti-windup is defined; add derivative only when damping is needed and the measurement can support a useful rate estimate.
5.13 Knowledge Check
This section: Knowledge Check
5.14 Match PID Theory to Loop Proof
This section: Match PID Theory to Loop Proof
5.15 Order a PID Theory Decision
This section: Order a PID Theory Decision
5.16 Common Pitfalls
This section: Common Pitfalls
Starting With Full PID
Enabling all three terms before proving which loop problem each term solves makes tuning harder and hides root causes.Treating the Equation as Enough
The equation does not document sample timing, actuator limits, filter choices, windup behavior, or safety fallback.Ignoring Saturation
A controller designed as if actuators can follow every requested output may fail badly when real devices hit limits.Unfiltered Derivative Action
Derivative gain can turn ordinary sensor noise into control chatter when the measurement path is not filtered.5.17 Overview: PID Terms Are Evidence Claims
This section: Overview: PID Terms Are Evidence Claims — A PID setting is not just a number.
A PID setting is not just a number. Each enabled term is a claim about the loop: proportional action claims the current error needs immediate correction, integral action claims persistent offset must be removed, and derivative action claims the trend needs damping.
The useful habit is to connect each term to an observed response shape and to the risk it introduces. A controller that reaches the setpoint once is not fully proved until saturation, noise, disturbance, sampling, and recovery behavior have also been checked.
Use Figure 5.5 to trace how setpoint error becomes an actuator command, changes the plant, and returns as a measurement that can support or reject the controller claim.
Follow the error forward. Then trace the measured result back. Read Figure 5.5 from the setpoint to the comparison that produces error, then through the controller and actuator into the plant. The returned measurement closes the loop only when it represents the controlled variable with known timing and sign. A command transported by MQTT or CoAP proves message exchange, not physical actuation, so actuator feedback and the next measurement remain separate evidence. The acceptance record should connect setpoint, error, command identifier, actuator state, measured response, disturbance, and safety outcome for the same trial before attributing the response to any PID term.
5.18 Term Proof Record
This section: Term Proof Record — Before keeping a PID configuration, record what each term is solving and what guardrail keeps that term from causing a new failure.
Before keeping a PID configuration, record what each term is solving and what guardrail keeps that term from causing a new failure.
| Term | Keep It When | Guardrail To Prove |
|---|---|---|
| P | The response moves toward the setpoint without unacceptable overshoot or cycling. | Gain, output clamp, acceptable offset, and response after a small disturbance. |
| I | Persistent offset matters and the actuator has enough authority to correct it. | Accumulator limit, anti-windup behavior, saturation flag, and recovery trace. |
| D | Overshoot or ringing needs damping and the measurement is clean enough. | Derivative filter, sample-rate reason, noise test, and setpoint-kick handling. |
5.19 Sampled and Limited Loops
This section: Sampled and Limited Loops — Real PID controllers run at a sample interval and drive a limited actuator.
Real PID controllers run at a sample interval and drive a limited actuator. That means the neat equation hides practical state: the previous error, accumulated error, filtered derivative estimate, output clamp, saturation flag, manual/auto mode, and sensor validity.
Those states explain why a gain set that works in one trace can fail later. A slower sample interval can make derivative action stale. A saturated actuator can make integral action store a command the process cannot follow. A noisy sensor can turn derivative gain into output chatter.
The under-the-hood check is to compare requested control action with what the actuator, sensor, and process can actually support over time.
-
Wrong idea: add derivative action to cure windup. It fails because stored error at an output limit causes windup, while derivative action adds noise.
5.20 Summary
This section: Summary — PID control theory explains how feedback action is built from proportional, integral, and derivative terms.
PID control theory explains how feedback action is built from proportional, integral, and derivative terms.
A PID record links each gain to the real response. Note actuator limits and the pass test.
5.21 Key Takeaway
This section: Key Takeaway — PID theory becomes useful when proportional, integral, and derivative choices are tied to field behavior, actuator limits, noise, sampling, and recovery proof.
PID theory becomes useful when proportional, integral, and derivative choices are tied to field behavior, actuator limits, noise, sampling, and recovery proof.
5.22 See Also
This section: See Also
5.23 What’s Next
This section: What’s Next
Continue with PID Feedback Fundamentals to connect PID terms back to feedback-loop behavior and loop stability concepts.
Find help
3 reviewed answers.
Where should I start in a module?
Open the module page from the sidebar to see its chapters in order. Use the module map to return to a topic you need.
Modules and pathsReviewed
What can I try when a project does not work?
Check the symptom, then work through the diagnostic steps. Keep the error message and the smallest example that reproduces it.
When you are stuckReviewed
How do interactive examples work?
Use the interactive guide to check how examples and simulations work before changing your project.
Interactive examples guideReviewed
