---
title: PID control
url: https://doc.liz6.com/en/theory/02-control-theory/04-pid-control
locale: en
area: theory
tags:
- Control theory
- Theory
date: 2026-09-10
modified: 2026-09-10
description: Proportional action reacts to current error; integral action retains a correction; derivative action responds to change. Building on Response and stability, we first analyze continuous, unsaturated control and then identify implementation requirements.
---

# PID control

Proportional action reacts to current error; integral action retains a correction; derivative action responds to change. Building on [Response and stability](03-response-and-stability.md), we first analyze continuous, unsaturated control and then identify implementation requirements.

## P: immediate action from error

For $u=u_b+K_pe$, $u_b=0.4$ and $e=r-\theta$, the thermal equilibrium error is

$$e_\infty=\frac{k(r-\theta_a)-P_{\max}u_b-d}{k+P_{\max}K_p}.$$

With target 40 °C, ambient 10 °C, baseline parameters, $d=0$ and $K_p=0.04$, this is $200/60=3.33$ K. More gain reduces this offset but also increases noise in the action and exposure to limits.

P control does not universally require a steady-state offset. A plant with integral dynamics may track a step without offset in a stable proportional loop. State the plant, input, bias action and stability conditions.

## I: store the correction in a state

Let $z$ denote the integral contribution itself:

$$u_c=u_b+K_pe+z,\qquad \dot z=K_ie.$$

$K_i$ has units $\mathrm{K}^{-1}\mathrm{s}^{-1}$; $z$ is dimensionless duty ratio. Positive error increases $z$. Zero error stops its change, rather than erasing it. At ambient 10 °C, maintaining 40 °C needs $u=0.6$, so equilibrium stores $z=0.2$. Zero error requires stability, feasibility, unbiased sensing and no persistent saturation.

PI adds a state. Its thermal characteristic polynomial is

$$C_{\mathrm{th}}s^2+(k+P_{\max}K_p)s+P_{\max}K_i=0.$$

For $K_p=0.04,K_i=0.001$, it becomes $s^2+0.03s+0.0005$, with roots $-0.015\pm0.01658j$. The oscillatory modes come from integral action, not an unexplained extra inertia in the original plant.

**PID control · Experiment**

Reference 40 °C; ambient 20→10 °C at 100 s; integral starts at zero. PID differentiates measurement with Kd=1 s/K and a 5 s filter. Requests are not clipped. Component curves exclude the 0.4 baseline.


Ambient falls from 20 to 10 °C at 100 s while the reference stays 40 °C. Compare P, PI and filtered PID, including separate P/I/D contributions. Requests are not clipped; the experiment reports whether they remain physically within 0–1. [Constraints](08-constraints-and-robustness.md) adds actuator saturation.

## D: filter the measured trend

Ideal parallel PID is $u_c=u_b+K_pe+K_i\int e\,dt+K_d\dot e$. Differentiating a step reference produces derivative kick. A common alternative differentiates the measurement through a filter:

$$\tau_f\dot y_f=y_m-y_f,\qquad u_D=-K_d\frac{y_m-y_f}{\tau_f}.$$

Its measurement-to-action transfer is $-K_ds/(\tau_fs+1)$, with finite high-frequency gain. Derivative on measurement and derivative on error are different structures: only the latter directly differentiates reference changes.

For $K_d=1$ s/K, $\tau_f=5$ s, $y_m=38$ °C and $y_f=37.5$ °C, $u_D=-0.1$. Rising temperature reduces heating. Initialize the filter consistently, often from the first reading, to avoid an artificial startup spike. D uses observed trends; it does not predict unknown future disturbances.

## Work through one update

For $e=2$ K, $z=0.15$, $u_D=-0.1$ and $K_p=0.04$, the request is $0.4+0.08+0.15-0.1=0.53$. A 1 s forward integral update gives $z_{j+1}=0.15+0.001\times2\times1=0.152$. This convention calculates the current action before advancing the state; using updated states is another implementation that must be specified consistently.

Parameter forms also matter. $K_p[1+1/(T_is)+T_ds]$ corresponds to $K_i=K_p/T_i$, $K_d=K_pT_d$, with filtering specified separately. Discrete coefficients depend on the sample period.

## Tune against several requirements

First verify feedback direction, plant time scales and feasible actions. Start with P or PI; add D for an identified dynamic need. Test reference changes, load changes, measurement noise, initial-state errors and saturation. Record requested and applied action and integral state, not output alone. Empirical tuning is a starting point with assumptions, not a universal guarantee.

## Check your understanding

Why can PI deliver more than the baseline after error becomes zero?

<details><summary>Reasoning</summary>

Zero error stops integration but retains $z=0.2$, supplying the extra 200 W needed for the new heat loss.

</details>

Should noisy measurements automatically lead to more D?

<details><summary>Reasoning</summary>

No. Differentiation emphasizes rapid measurement changes. Distinguish actual dynamics from noise and compare filtering, bandwidth and action cost before adding derivative gain.

</details>

## Further reading

The [python-control cruise-control example](https://python-control.readthedocs.io/en/stable/examples/cruise-control.html) illustrates PI with limits. [MathWorks anti-windup examples](https://www.mathworks.com/help/simulink/slref/anti-windup-control-using-a-pid-controller.html) distinguish back-calculation and conditional integration.
