A PID controller is a rule that computes a control input u(t) (motor voltage, heater power, valve angle) so that a measured output y(t) (speed, temperature, pressure) tracks a desired value r(t) (the setpoint).
1. The One Equation You Start With
Define the tracking error:
A continuous-time PID controller is:
The controller is the sum of three actions:
- Proportional action uses the current error.
- Integral action uses the accumulated past error.
- Derivative action uses how fast the error is changing.
2. Why Each Term Exists
Proportional Term
Intuition: if you are far from the target, push harder. If you are close, push gently.
For many plants, proportional control reduces error quickly but may not drive the steady-state error to exactly zero. Consider a simple first-order plant (common in thermal and many mechanical systems):
With proportional control , the closed-loop transfer function is:
For a unit step input , the steady-state output is:
So the steady-state error is:
For this first-order plant under stable unity negative feedback, increasing reduces the step error, but finite proportional gain does not eliminate it. This conclusion does not apply to every plant; a plant with an integrator behaves differently.
Practical limit
Too large a often causes overshoot, oscillation, or actuator saturation.
Integral Term
Intuition: if you are slightly below the target for a long time, keep increasing the effort until the bias is removed.
Integral action drives steady-state error to zero for many common plants, because if a constant error persists, the integral keeps growing, forcing the control input to change until the error vanishes. In Laplace form:
Integral action introduces a pole at the origin. It can remove constant tracking error when the closed loop is stable and the requested output is attainable; actuator limits and windup still matter.
Practical limit
Integral can cause "windup" when actuators saturate: the integral keeps accumulating even though the actuator cannot apply more force. Anti-windup is commonly added in real systems.
Derivative Term
Intuition: if you are approaching the target very fast, start reducing effort early to avoid overshoot. It behaves like damping.
Derivative adds phase lead and can improve transient response (less overshoot, better settling), but it is sensitive to noise because differentiation amplifies high-frequency content. In Laplace form (ideal derivative):
At high frequency, is large, so noise gets amplified. This leads to the dirty derivative.
3. The Dirty Derivative and Why It Matters
Because sensors are noisy and sampled, a real controller almost never uses the ideal . Instead, it uses a derivative with a low-pass filter:
Here is a small filter time constant. This has two important properties:
- At low frequency (), , so you still get derivative behavior where it helps control.
- At high frequency (), , so it stops growing without bound and noise amplification is limited.
Another common parameterization uses (the derivative filter coefficient):
In this convention, is the filter cutoff in radians per second. Other PID forms use different conventions for N; check the implementation before transferring gains.
Practical guideline
Make derivative filtering strong enough to avoid noise-driven control chatter, but not so strong that the derivative becomes useless. In real tuning, you often start with derivative off, tune and , then add a small with filtering.
4. Units of , ,
Let the output unit be , setpoint has unit , so error has unit . Let the control input have unit . Then:
This is a quick dimensional check to confirm your math is consistent.
5. Designing PID Through Intuition
A practical design sequence that works in many systems:
Step 1: Start with Proportional Only
Set , . Increase from small values until the response is fast enough but still stable with acceptable overshoot.
- Rise time becomes shorter as increases.
- Overshoot and oscillation appear if is too large.
Step 2: Add Integral to Remove Steady-State Error
Increase slowly until steady-state error is removed quickly enough.
- Offset disappears.
- Too much causes slow oscillations and overshoot.
- Windup can appear if actuators saturate.
Step 3: Add Derivative Only If Needed
Add a small with filtering to reduce overshoot and improve settling.
- Overshoot can decrease, depending on the plant and gains.
- Settling can improve; check the complete response.
- If noise is present, too much derivative causes jitter in the control.
This sequence is simple because each term has a clear job.
6. Common PID Tuning Methods
A) Ziegler-Nichols
The closed-loop "ultimate gain" method, considered here in simulation or a controlled test that permits sustained oscillation: set , , increase until sustained oscillation occurs. Record (ultimate gain) and (oscillation period), then use the ZN formulas to set , , . This is fast but can be aggressive and may produce overshoot.
The open-loop step response method: apply a step to the plant input, fit an approximate model (often first-order plus dead time), and compute gains from the identified parameters. This is safer for some processes but needs a clean step test.
B) Root Locus Based Tuning
Root locus shows how closed-loop poles move as you change a gain. For a plant and controller , closed-loop poles satisfy:
Choose a controller structure (P, PI, PID), plot the root locus as you vary a gain, and pick gains so dominant poles have desired damping and natural frequency. More damping typically means less overshoot; further-left poles typically mean faster response.
C) Bode Plot and Frequency Response Tuning
Frequency response tuning focuses on stability margins and bandwidth. Key quantities: gain crossover frequency (where , with ), phase margin, and gain margin from the Bode plot.
- Choose a target bandwidth (how fast you want the loop).
- Select a phase-margin target for the plant and its uncertainty; 45–70 degrees is a common heuristic, not a performance guarantee.
- Use integral action to raise low-frequency gain (better tracking and disturbance rejection).
- Use derivative (phase lead) to increase phase margin near crossover.
This method is widely used in industry because it connects directly to robustness.