---
title: Time delay in control loops
heading: Where delays come from, why they limit bandwidth, Padé approximations and their right-half-plane zeros, the delay a digital controller adds, and the Smith predictor with its sensitivity to model errors
eyebrow: S9 · Lesson 30 · Time delay in control loops
xp: 50
---

::: hook
Fluid takes time to flow down a pipe to a sensor, a network packet takes time to arrive, a digital controller takes a sample to compute and a zero-order hold half a sample to deliver. A delay doesn't change the loop gain's magnitude at all, but it subtracts phase in proportion to frequency, so it caps how fast any loop can be. This lesson measures that cost, shows how to model a delay with rational transfer functions, and presents Otto Smith's 1957 trick for controlling a plant as if its delay weren't there.
:::

::: play
- The phase of a pure delay, $-\omega T$, against ωT, with two rational approximations: the first-order Padé $\frac{1 - sT/2}{1 + sT/2}$ and the second-order Padé $\frac{1 - sT/2 + s^2T^2/12}{1 + sT/2 + s^2T^2/12}$.
- All three agree at low frequency. The first-order one falls behind by ωT = 1 (−53° against −57°) and saturates at −180°; the second-order one tracks to about ωT = 2 and saturates at −360°.
- Both approximations have the same magnitude as the delay, 1 at every frequency, because they're all-pass.
:::

```sim plot
view: graph
x: u = 0..8
y: phase = -480..0 °
plot: -u*180/pi | samples: 400 | label: exact delay
plot: -2*atan(u/2)*180/pi | samples: 400 | color: ch3 | label: first-order Padé
plot: -2*arg(1 - u^2/12 + j*u/2)*180/pi | samples: 400 | color: ch4 | label: second-order Padé
```

::: predict
## An integrator with a delay, $L = Ke^{-s\theta}/s$, needs 60° of phase margin. What's the largest Kθ allowed?

- [ ] 1
- [x] π/6, about 0.52
- [ ] π/2, about 1.57
- [ ] It depends on K and θ separately

::: reveal
The loop crosses at $\omega_c$ = K, where the phase is $-90° - K\theta$ (radians converted). A 60° margin leaves 30° = π/6 for the delay, so Kθ ≤ 0.524. The loop's speed is tied to the delay: halve the delay and you can double the gain.
:::
:::

::: nameit
## The cost of a delay

$e^{-j\omega\theta}$ has magnitude 1 and phase $-\omega\theta$. At the crossover that's $\omega_c\theta$ radians of margin used up, which is why a delay limits $\omega_c$ to roughly $1/\theta$ (lesson 28).

## Digital controllers

A controller sampling every $T_s$ with a zero-order hold adds about $T_s/2$ of effective delay from the hold, plus up to $T_s$ more if the output is applied one sample after the input is read. That's 1.5 $T_s$ in total, costing $1.5\omega_cT_s$ radians at crossover: 27° for a 1 kHz crossover sampled at 20 kHz.

## Padé approximations

Rational stand-ins for the delay let polynomial tools (root locus, Routh, state space) handle it:

$$e^{-s\theta} \approx \frac{1 - s\theta/2}{1 + s\theta/2} \approx \frac{1 - s\theta/2 + s^2\theta^2/12}{1 + s\theta/2 + s^2\theta^2/12}$$

Both have zeros in the right half-plane (the first-order one at $+2/\theta$), the polynomial signature of a delay: the response can't start until the delay passes.

## The Smith predictor

Run a model of the plant without its delay, $P_0$, and a model of the delay alongside the controller. Feed back the measured output plus the difference between the undelayed and delayed model outputs. If the model is exact, the controller effectively sees $P_0$, and the closed loop is

$$\frac{y}{r} = \frac{CP_0}{1 + CP_0}e^{-s\theta}$$

the delay-free response, simply delayed. The controller can be tuned as if there were no delay. The catch is model error: if the real delay differs from the model's, the predictor feeds back a wrong correction, and robustness falls quickly.
:::

::: example
## A process $P = e^{-5s}/(2s + 1)$ is dominated by its delay. Compare SIMC PI with a Smith predictor.

::: solution
1. **SIMC PI.** With $\tau_c = \theta$:
   $$\begin{aligned} K_p &= \frac{2}{1 \times 10} \\ &= 0.2 \\ T_i &= 2\ \text{s} \end{aligned}$$
2. **Its response.** Simulated with the exact delay, it overshoots 4% and settles within 2% at 30.3 s.
3. **Smith predictor.** It lets the PI be tuned for the delay-free plant: $T_i$ = 2 s and $K_p$ = 1 make the inner loop
   $$\frac{1}{2s + 1}$$
4. **Its response.** The output is that response delayed 5 s, with no overshoot, settling at
   $$\begin{aligned} t_s &= 5 + 2 \times 3.91 \\ &= 12.8\ \text{s} \end{aligned}$$
5. **If the model is wrong.** If the real delay is 6 s instead of the modeled 5, the same predictor overshoots 16% and takes 27.5 s.

**Answer:** SIMC PI settles in 30.3 s with 4% overshoot; the Smith predictor settles in 12.8 s with none, but overshoots 16% and takes 27.5 s if the delay is really 6 s.
:::
:::

::: example
## How good is the first-order Padé approximation?

::: solution
1. **At ωθ = 1.** The first-order Padé phase is
   $$-2\tan^{-1}0.5 = -53.1°$$
   against the delay's −57.3°: 4.2° short.
2. **At ωθ = 2.** It gives −90° against −114.6°.
3. **Second order.** The second-order version gives −57.2° and −112.6° at those points.
4. **When first order is enough.** Since a loop with a delay must cross over below about ωθ = 1, the first-order approximation is usually adequate for analysis near crossover.

**Answer:** good enough near crossover: 4.2° short at ωθ = 1, though by ωθ = 2 it gives only −90° against −114.6°.
:::
:::

::: example
## At ωθ = 2, compare the true delay's phase with the first- and second-order Padé approximations.

::: solution
1. **True delay.** It lags by
   $$2\ \text{rad} = 114.6°$$
2. **First-order Padé.** The approximation $(1 - s\theta/2)/(1 + s\theta/2)$ lags by
   $$2\tan^{-1}(1) = 90°$$
   short by 24.6°.
3. **Second-order Padé.** It lags by
   $$\begin{aligned} &2\tan^{-1}\frac{\omega\theta/2}{1 - (\omega\theta)^2/12} \\ &= 2\tan^{-1}1.5 \\ &= 112.6° \end{aligned}$$
   short by only 2.0°.
4. **What it means for design.** A design that crosses over near ωθ = 2 needs at least the second-order form to predict its margin.

**Answer:** the delay lags 114.6°, the first-order Padé 90° (24.6° short) and the second-order Padé 112.6° (2.0° short).
:::
:::

::: check
given: u = 0.5 | 1 | 2 | 3
answer: (u - 2*atan(u/2))*180/pi
unit: °
tolerance: 0.5%

## At ωθ = {u}, how far does the first-order Padé approximation's phase lag fall short of the true delay's?

::: right
Right. $\omega\theta - 2\tan^{-1}(\omega\theta/2)$ = {answer}°.
:::

::: misses
- [any] Not yet. Compare $-\omega\theta$ with $-2\tan^{-1}(\omega\theta/2)$.
:::
:::

::: check
given: K = 1 | 4; h = 0.1 | 0.5 | 2; P = 45 | 60
answer: (90 - P)*pi/180/(K*h)
tolerance: 0.5%

## A plant $Ke^{-s\theta}/s$ has K = {K} and θ = {h} s. What proportional gain gives a {P}° phase margin?

::: right
Right. $\omega_c = KK_p$ and the phase there is $-90° - KK_p\theta$, so $K_p$ = {answer}.
:::

::: misses
- [(90 - P)/(K*h)] Convert the spare phase to radians.
- [any] Not yet. Set $90° - KK_p\theta$ equal to the margin.
:::
:::

::: check
given: f = 0.5 | 2 | 5; s = 10 | 50 | 100
answer: 1.5*2*pi*f/s*180/pi
unit: °
tolerance: 0.5%

## A digital loop sampled at {s} kHz crosses over at {f} kHz. How much phase do the hold and one sample of computation delay cost there?

::: right
Right. 1.5 $T_s$ of delay: $1.5\omega_cT_s$ = {answer}°.
:::

::: misses
- [0.5*2*pi*f/s*180/pi] That's the hold alone. The one-sample computation delay adds $\omega_cT_s$ more.
- [any] Not yet. Delay of 1.5 samples at $\omega_c$.
:::
:::

::: check
given: h = 0.2 | 1 | 4
answer: 2/h
unit: rad/s
tolerance: 0.5%

## Where's the right-half-plane zero of the first-order Padé approximation of a {h} s delay?

::: right
Right. $1 - s\theta/2 = 0$ at s = +{answer}.
:::

::: misses
- [1/h] The zero is at $2/\theta$.
- [any] Not yet. Solve $1 - s\theta/2 = 0$.
:::
:::

::: check
given: K = 0.5 | 2; t = 2 | 10; c = 1 | 4; h = 1 | 5
answer: t/(K*c)
tolerance: 0.5%

## With a Smith predictor, a PI controller ($T_i$ = τ) is tuned for $Ke^{-s\theta}/(\tau s + 1)$ with K = {K}, τ = {t} s, θ = {h} s. What $K_p$ gives a delay-free closed-loop time constant of {c} s?

::: right
Right. The predictor removes θ from the design, so $K_p = \tau/(K\tau_c)$ = {answer}.
:::

::: misses
- [t/(K*(c + h))] That's SIMC without a predictor. The predictor takes the delay out of the loop.
- [any] Not yet. Design as if θ = 0.
:::
:::

::: check
given: c = 1 | 3; h = 2 | 6
answer: h + c*ln(50)
unit: s
tolerance: 0.5%

## With a perfect model, a Smith-predictor loop responds like $e^{-s\theta}/(\tau_cs + 1)$ with $\tau_c$ = {c} s and θ = {h} s. When does it settle within 2%?

::: right
Right. θ + $\tau_c\ln 50$ = {answer} s.
:::

::: misses
- [c*ln(50)] Add the delay.
- [any] Not yet. Delay plus 3.91 time constants.
:::
:::

::: check
kind: parts
given: u = 0.5 | 1 | 2 | 3

## A delay is approximated at ωθ = {u}.

::: part
answer: (u - 2*atan(u/2))*180/pi
unit: °
tolerance: 1%

### By how much does the first-order Padé approximation understate the phase lag?

::: misses
- [any] True lag ωθ against $2\tan^{-1}(\omega\theta/2)$.
:::
:::

::: part
answer: (u - 2*atan((u/2)/(1 - u^2/12)))*180/pi
unit: °
tolerance: 2%

### And the second-order one?

::: misses
- [any] Its lag is $2\tan^{-1}\frac{\omega\theta/2}{1 - (\omega\theta)^2/12}$.
:::
:::
:::

::: check
kind: derivation
vars: h = 0.001..10, w = 0.01..1.5

## A delay of h seconds, at a frequency w (rad/s) with wh below 1.5.

::: step
answer: -w*h*180/pi

### What is its phase, in degrees?
:::

::: step
answer: -2*atan(w*h/2)*180/pi

### What phase does the first-order Padé approximation give?
:::

::: step
answer: 2/h

### Where is that approximation's right-half-plane zero?
:::

::: right
Right. The approximation's RHP zero is the polynomial trace of the delay: the response must wait.
:::
:::

::: explain
## Why is a Smith predictor sensitive to errors in the modeled delay?

::: model
The predictor works by subtracting its model's delayed output from the measured output, which cancels the real delayed response and leaves the controller looking at the undelayed model. If the model's delay is wrong, the two signals are misaligned in time, and their difference is no longer zero during transients: it's a time-shifted copy of the response that the controller treats as real error. That spurious error arrives at the wrong moment and drives the controller harder, causing overshoot or oscillation. Because the controller was tuned aggressively on the assumption that the delay was gone, it has little margin to absorb the mistake.
:::
:::

::: practice

::: check
given: K = 2 | 10; h = 0.05 | 0.3; P = 40 | 55
answer: (90 - P)*pi/180/(K*h)
tolerance: 0.5%

## $K_p$ for {P}° margin on $\given{K}e^{-s\theta}/s$, θ = {h} s?

::: misses
- [any] $(90° - \text{PM})/(K\theta)$ in radians.
:::
:::

::: check
given: f = 1 | 10; s = 20 | 200
answer: 1.5*2*pi*f/s*180/pi
unit: °
tolerance: 0.5%

## Phase lost to 1.5 samples at {s} kHz, {f} kHz crossover?

::: misses
- [any] $1.5\omega_cT_s$.
:::
:::

::: check
given: u = 0.3 | 1.5 | 2.5
answer: (u - 2*atan(u/2))*180/pi
unit: °
tolerance: 0.5%

## First-order Padé phase shortfall at ωθ = {u}?

::: misses
- [any] $\omega\theta - 2\tan^{-1}(\omega\theta/2)$.
:::
:::
:::
