Back to Life & Technical
March 2, 202618 min read

PID Control: From Intuition to Implementation

A complete walkthrough of PID control, built from physical intuition and simple math. Covers continuous-time PID, the dirty derivative, tuning methods, and practical design.

Control SystemsPIDTutorialAerospaceEngineering

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:

e(t)=r(t)y(t)e(t) = r(t) - y(t)

A continuous-time PID controller is:

u(t)=Kpe(t)+Ki0te(τ)dτ+Kdde(t)dtu(t) = K_p \, e(t) + K_i \int_0^{t} e(\tau) \, d\tau + K_d \frac{d\,e(t)}{dt}

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):

G(s)=Y(s)U(s)=Kτs+1G(s) = \frac{Y(s)}{U(s)} = \frac{K}{\tau s + 1}

With proportional control C(s)=KpC(s) = K_p, the closed-loop transfer function is:

Y(s)R(s)=KpG(s)1+KpG(s)\frac{Y(s)}{R(s)} = \frac{K_p \, G(s)}{1 + K_p \, G(s)}

For a unit step input r(t)=1r(t) = 1, the steady-state output is:

y()=KpK1+KpKy(\infty) = \frac{K_p K}{1 + K_p K}

So the steady-state error is:

e()=1y()=11+KpKe(\infty) = 1 - y(\infty) = \frac{1}{1 + K_p K}

This shows the key point: increasing KpK_p reduces the final error, but unless KpK_p approaches infinity, the error is never exactly zero.

Practical limit

Too large a KpK_p 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:

CI(s)=KisC_I(s) = \frac{K_i}{s}

That 1/s1/s means infinite gain at s=0s = 0 (very low frequency), which is why it cancels constant offsets and removes steady-state error.

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):

CD(s)=KdsC_D(s) = K_d \, s

At high frequency, s|s| 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 KdsK_d \cdot s. Instead, it uses a derivative with a low-pass filter:

CD(s)=Kdsτfs+1C_D(s) = K_d \frac{s}{\tau_f s + 1}

Here τf\tau_f is a small filter time constant. This has two important properties:

  • At low frequency (τfs1\tau_f s \ll 1), CD(s)KdsC_D(s) \approx K_d s, so you still get derivative behavior where it helps control.
  • At high frequency (τfs1\tau_f s \gg 1), CD(s)Kd/τfC_D(s) \approx K_d / \tau_f, so it stops growing without bound and noise amplification is limited.

Another common parameterization uses NN (the derivative filter coefficient):

CD(s)=KdNss+NC_D(s) = K_d \frac{N s}{s + N}

This is the same idea: derivative action plus a first-order low-pass filter.

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 KpK_p and KiK_i, then add a small KdK_d with filtering.

4. Units of KpK_p, KiK_i, KdK_d

Let the output unit be YY, setpoint has unit YY, so error ee has unit YY. Let the control input uu have unit UU. Then:

Kp:UYKi:UYsKd:UsYK_p : \frac{U}{Y} \qquad K_i : \frac{U}{Y \cdot s} \qquad K_d : \frac{U \cdot s}{Y}

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 Ki=0K_i = 0, Kd=0K_d = 0. Increase KpK_p from small values until the response is fast enough but still stable with acceptable overshoot.

  • Rise time becomes shorter as KpK_p increases.
  • Overshoot and oscillation appear if KpK_p is too large.

Step 2: Add Integral to Remove Steady-State Error

Increase KiK_i slowly until steady-state error is removed quickly enough.

  • Offset disappears.
  • Too much KiK_i causes slow oscillations and overshoot.
  • Windup can appear if actuators saturate.

Step 3: Add Derivative Only If Needed

Add a small KdK_d with filtering to reduce overshoot and improve settling.

  • Overshoot decreases.
  • Settling improves.
  • 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: set Ki=0K_i = 0, Kd=0K_d = 0, increase KpK_p until sustained oscillation occurs. Record KuK_u (ultimate gain) and TuT_u (oscillation period), then use the ZN formulas to set KpK_p, KiK_i, KdK_d. 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 G(s)G(s) and controller C(s)C(s), closed-loop poles satisfy:

1+C(s)G(s)=01 + C(s) \, G(s) = 0

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 L(jω)=1|L(j\omega)| = 1, with L(s)=C(s)G(s)L(s) = C(s)G(s)), phase margin, and gain margin from the Bode plot.

  • Choose a target bandwidth (how fast you want the loop).
  • Shape the loop with PID so that phase margin is sufficient (often 45 to 70 degrees).
  • 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.

— Adeel

Send me a note

Share

Share on X

aeronautyy.com/articles/technical/pid-control-from-intuition-to-implementation