Smith predictor

A PID that sees a prediction of its measurement. A model of the process runs beside the plant, with and without its dead time, and the difference is added to the measurement, so the PID can be tuned as if the dead time weren't there.

Theory

O. J. M. Smith, 1957. Split the process into a fast part and a delay, G(s)=G0(s) e−θsG(s) = G_0(s)\,e^{-\theta s}, and keep a model of both, Gm(s)=Gm0(s) e−θmsG_m(s) = G_{m0}(s)\,e^{-\theta_m s}. The controller CC is fed

yfb=y+Gm0 u−Gm0 e−θms uy_{fb} = y + G_{m0}\,u - G_{m0}\,e^{-\theta_m s}\,u

If the model is exact, the last term cancels the real measurement's response to uu. What is left is Gm0uG_{m0}u: the process without its delay. The closed loop becomes

yr=C G01+C G0 e−θs\frac{y}{r} = \frac{C\,G_0}{1 + C\,G_0}\,e^{-\theta s}

The delay has moved out of the loop. CC is tuned for G0G_0 alone, and the answer arrives θ\theta later.

As a single controller. The predictor and CC together are

Ceff=C1+C Gm0 (1−e−θms)C_{eff} = \frac{C}{1 + C\,G_{m0}\,(1 - e^{-\theta_m s})}

That's what the Bode plot here uses. Its gain ripples with frequency, every 2π/θm2\pi/\theta_m rad/s, which is why the delay margin, not the phase margin, is the number to watch.

What it doesn't change. Load disturbances still pass through the plant's full delay before the controller sees them. Only the response after that gets faster. Setpoint tracking gains the most.

When it works, and when it breaks

Works
  • Dead time much longer than the process lag (θ/τ above about 1): belts, long sample lines, paper machines, extruders, analysers.

  • The dead time is known and steady, or can be calculated (belt length / belt speed).

  • Frequent setpoint changes, where "the fast response, θ later" is a real gain.

Breaks
  • The dead time changes and the model doesn't: 20 % error with a fast inner PI can be worse than a plain PI.

  • Integrating processes: a plain Smith predictor can't reject a constant load on one (it leaves an offset or drifts). They need a modified structure.

  • Load upsets: they still take the full dead time to be seen, so the predictor helps little there.

  • Maintenance: three model parameters someone must keep right, inside a structure most technicians haven't met.

How to tune it

  1. Identify gain, lag and dead time from a bump test (FOPDT is usually enough).
  2. Put them in the model. θm\theta_m is the whole dead time the loop sees, half a controller cycle included.
  3. Tune the PI for the lag alone, as if θ=0\theta = 0. SIMC gives Ti=τT_i = \tau, Kc=τ/(Kτc)K_c = \tau/(K\tau_c).
  4. Choose τc\tau_c for robustness, not speed. The undelayed process would allow τc\tau_c of a few seconds, but any error in θm\theta_m acts like unmodelled dead time. Here τc=max⁡(τ,θ/2)\tau_c = \max(\tau, \theta/2) keeps Ms near 2 with the dead time ±15 % off. Faster and the loop rings as soon as the belt slows down.
  5. Test with the model wrong on purpose: dead time ±20 %, gain ±20 %.
The tuning rules in the lab
SIMC (Skogestad) (PI, PID)
Kc=τK(τc+θ),Ti=min⁡(τ, 4(τc+θ))K_c = \frac{\tau}{K(\tau_c + \theta)},\quad T_i = \min\big(\tau,\ 4(\tau_c + \theta)\big)

Model-based, one tuning knob: the closed-loop time constant τc. τc = θ gives a fast, still robust loop (Ms ≈ 1.6); larger τc is smoother. The min() on Ti keeps lag-dominant and integrating processes from responding too slowly to load upsets. PID uses the second-order model: Td = τ2 in series form.

Lambda (IMC) (PI)
Kc=τK(λ+θ),Ti=τK_c = \frac{\tau}{K(\lambda + \theta)},\quad T_i = \tau

The process-industry favourite: choose λ, the closed-loop time constant, and the setpoint response is first-order with no overshoot. Ti = τ cancels the process pole, which makes load rejection slow on lag-dominant processes. λ = 1–3 × τ is typical for robustness.

IMC-PID (Rivera–Morari–Skogestad) (PI, PID)
Kc=2τ+θ2Kλ,Ti=τ+θ2PID: Kc=2τ+θK(2λ+θ), Td=τθ2τ+θK_c = \frac{2\tau + \theta}{2K\lambda},\quad T_i = \tau + \frac{\theta}{2}\qquad\text{PID: } K_c = \frac{2\tau + \theta}{K(2\lambda + \theta)},\ T_d = \frac{\tau\theta}{2\tau + \theta}

Internal model control worked back into a PID (Rivera, Morari and Skogestad, 1986): the controller that makes the loop a first-order λ response, with the dead time replaced by its first-order Padé approximation. That approximation is what gives the derivative, and why Ti = τ + θ/2 rather than τ. Keep λ above about 0.8θ for the PID and 1.7θ for the PI, where the approximation stops holding. Like Lambda, it cancels the process lag, so load upsets on lag-dominant processes recover slowly. The IMC structure itself (the model running beside the plant) is the Smith predictor on the bench.

Lambda for integrating (averaging level) (P, PI)
Kc=2λ+θk′(λ+θ)2,Ti=2λ+θK_c = \frac{2\lambda + \theta}{k'(\lambda + \theta)^2},\quad T_i = 2\lambda + \theta

For integrating processes such as levels, from the ramp rate k′ (% of span per second, per % of output). λ is the arrest time: how long the level keeps moving after an inflow upset. For a step upset Δ (in % of output) the level swings about k′·Δ·λ/e before it turns round, so choose λ from the room the tank has. A long λ lets the tank absorb the upset and keeps the outflow smooth: averaging level control. P-only: Kc = 1/(k′λ), which leaves an offset that is harmless in a buffer.

Ziegler–Nichols (reaction curve) (P, PI, PID)
Kc=0.9 τKθ,Ti=3.33 θK_c = \frac{0.9\,\tau}{K\theta},\quad T_i = 3.33\,\theta

The 1942 rules, aiming for a quarter-amplitude decay. Aggressive: Ms is often above 2, so the loop rings and is sensitive to model error. Worth knowing because so many loops in the field were tuned this way.

Cohen–Coon (P, PI, PID)
Kc=τKθ(0.9+θ12τ),Ti=θ 30+3θ/τ9+20θ/τK_c = \frac{\tau}{K\theta}\Big(0.9 + \frac{\theta}{12\tau}\Big),\quad T_i = \theta\,\frac{30 + 3\theta/\tau}{9 + 20\theta/\tau}

Like Ziegler–Nichols but corrected for dead time, so it copes better when θ/τ is large. Also aimed at quarter-amplitude decay, so also aggressive.

AMIGO (Åström–Hägglund) (PI, PID)
Kc=0.15K+(0.35−θτ(θ+τ)2)τKθ,Ti=0.35θ+13θτ2τ2+12θτ+7θ2K_c = \frac{0.15}{K} + \Big(0.35 - \frac{\theta\tau}{(\theta+\tau)^2}\Big)\frac{\tau}{K\theta},\quad T_i = 0.35\theta + \frac{13\theta\tau^2}{\tau^2 + 12\theta\tau + 7\theta^2}

Derived by optimizing load rejection with a robustness limit (Ms ≈ 1.4) over a large test batch of processes. A safe modern default when you have no reason to choose a speed.

How to implement it

  • Order in the cycle: update the model with last cycle's controller output, compute the corrected measurement, then run the PID.
  • The dead time is a ring buffer of n=θm/Tsn = \theta_m/T_s model outputs. The cycle time must be constant, so use a cyclic interrupt.
  • Manual mode: re-zero the model (output = the present value, buffer cleared), so switching to automatic is bumpless.
  • Show the real measurement to the operator, not the corrected one.
  • Variable dead time: recompute nn from the speed that causes it (belt speed, line flow).

Siemens and elsewhere

Siemens
  • No standard block for dead-time compensation in PID_Compact or PID_Temp.
  • The exported LL_Smith FB (SCL, ring buffer of up to 1000 cycles) goes in front of PID_Compact: its Corrected output feeds PID_Compact's Input.
  • For longer dead times, sample the model slower than the PID (a buffer entry every few cycles), or use a larger array.
  • Keep the PID's own pretuning switched off: it would tune for the delayed process.
Elsewhere
  • DCS libraries often have a dead-time block (DEADTIME, DELAY) that makes building a Smith predictor a few blocks of configuration.
  • IMC (internal model control) is the general form of the same idea: a model in parallel with the plant, and the controller acting on the model error. A Smith predictor is IMC with a PI in place of the model inverse.
  • MPC handles dead time natively, in its prediction, along with constraints.

Interactive Controller Sandbox

Test and tune Smith predictor live on a process, benchmark against baseline PI, and inspect the resulting code.

Interactive Gains (Primary Loop)

Drag sliders or nudge gains to observe the closed-loop transient response
Kc (gain): 0.41
Ti (integral): 5.5 s
Td (derivative): 0 s

Closed-Loop Response: Smith predictor vs Baseline PI

Simulating…
Running test scenarios…
Block Diagram
SP rΣ+−PIDKc·(1 + 1/Ti·s + Td·s)PIDCV uValve1/(τᵥs + 1), char.stemΣ++d: bulk densityProcessscrew, then beltPV yTransmittere^(−θs)/(τₘs + 1)Σ++noise nΣ++predictedModelKₘ(1 − e^(−θₘs))/(τₘs + 1)PV measured
Generated code
// Loop Lab export: Belt feeder (dead time), WIC-701
// TIA Portal SCL (S7-1200 / S7-1500). Generated code: review before use on a real plant.

FUNCTION_BLOCK "LL_Smith"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_INPUT
      Input : Real;           // measurement, engineering units
      PidOutput : Real;       // the PID's output from the last cycle, %
      Reset : Bool;           // TRUE (e.g. in manual): restart the model from the present output
      Cycle : Real := 0.5;
   END_VAR
   VAR_OUTPUT
      Corrected : Real;       // to the PID's Input: the measurement with the dead time predicted away
   END_VAR
   VAR
      K : Real := 0.8;          // model gain, % of span per % output
      Tau : Real := 5.5;        // model lag, s
      DeadTime : Real := 32.8;   // model dead time, s (at most 1000 cycles)
      InLow : Real := 0.0;
      InHigh : Real := 20.0;
      Buffer : Array[0..999] of Real;   // the model output over the last DeadTime
      Head : DInt;
      Ym : Real;              // undelayed model output, % (deviation from where it started)
      U0 : Real;
      Started : Bool;
   END_VAR
   VAR_TEMP
      n : DInt;
      i : DInt;
      a : Real;
      ymd : Real;
   END_VAR

BEGIN
    #n := LIMIT(MN := 0, IN := TRUNC(#DeadTime / #Cycle), MX := 1000);
    IF #Reset OR NOT #Started THEN
        #U0 := #PidOutput;
        #Ym := 0.0;
        #Head := 0;
        FOR #i := 0 TO 999 DO
            #Buffer[#i] := 0.0;
        END_FOR;
        #Started := TRUE;
    ELSE
        // One cycle of K / (Tau*s + 1) driven by last cycle's output (exact for a held output).
        #a := 0.0;
        IF #Tau > 0.0 THEN
            #a := EXP(-#Cycle / #Tau);
        END_IF;
        #Ym := #a * #Ym + (1.0 - #a) * #K * (#PidOutput - #U0);
    END_IF;

    // The same model, DeadTime later: a ring buffer of the last n values.
    IF #n > 0 THEN
        IF #Head >= #n THEN
            #Head := 0;
        END_IF;
        #ymd := #Buffer[#Head];
        #Buffer[#Head] := #Ym;
        #Head := (#Head + 1) MOD #n;
    ELSE
        #ymd := #Ym;
    END_IF;

    // Measurement + (what the model says is coming − what the model says is arriving now).
    #Corrected := #Input + (#Ym - #ymd) / 100.0 * (#InHigh - #InLow);
END_FUNCTION_BLOCK

FUNCTION_BLOCK "LL_PID"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_INPUT
      Setpoint : Real;        // engineering units
      Input : Real;           // measurement, engineering units
      ManualEnable : Bool;    // TRUE = manual: Output follows ManualValue
      ManualValue : Real;     // %
      Feedforward : Real;     // %, added to the output (0 when unused)
      HoldIntegral : Int;     // +1 / -1: don't integrate up / down (a cascade slave is saturated)
      ExtResetEnable : Bool;  // override: this controller is not selected, so its integral follows ExtReset
      ExtReset : Real;        // %, the selected (valve) output, for external reset feedback
      Cycle : Real := 0.5;    // s, must match the cyclic interrupt the block is called from
   END_VAR
   VAR_OUTPUT
      Output : Real;          // %
      AtLimit : Int;          // +1 / -1 when the output is pinned high / low
   END_VAR
   VAR
      Gain : Real := 0.41;        // % output per % of span
      Ti : Real := 5.5;          // s, 0 = no integral action
      Td : Real := 0.0;          // s, 0 = no derivative action
      PWeighting : Real := 1.0;   // setpoint weight b on P
      DWeighting : Real := 0.0;   // setpoint weight c on D
      TdFiltRatio : Real := 0.1;  // derivative filter = TdFiltRatio * Td
      InLow : Real := 0.0;
      InHigh : Real := 20.0;
      OutLow : Real := 0.0;
      OutHigh : Real := 100.0;
      Invert : Bool := FALSE;
      Integral : Real;        // integral term, in % output (so gain changes don't bump)
      DTerm : Real;
      LastED : Real;
   END_VAR
   VAR_TEMP
      sp : Real;
      pv : Real;
      dir : Real;
      e : Real;
      eP : Real;
      eD : Real;
      p : Real;
      tf : Real;
      iNext : Real;
      v : Real;
      u : Real;
   END_VAR

BEGIN
    // Scale to % of span: the gains are then independent of engineering units.
    #sp := (#Setpoint - #InLow) / (#InHigh - #InLow) * 100.0;
    #pv := (#Input - #InLow) / (#InHigh - #InLow) * 100.0;
    #dir := 1.0;
    IF #Invert THEN
        #dir := -1.0;
    END_IF;
    #e := #dir * (#sp - #pv);
    #eP := #dir * (#PWeighting * #sp - #pv);
    #eD := #dir * (#DWeighting * #sp - #pv);
    #p := #Gain * #eP;

    IF #ManualEnable THEN
        // Track: preload the integral so switching to auto doesn't bump the output.
        #u := LIMIT(MN := #OutLow, IN := #ManualValue, MX := #OutHigh);
        #Integral := #u - #p - #Feedforward;
        #DTerm := 0.0;
        #LastED := #eD;
        #Output := #u;
        #AtLimit := 0;
        RETURN;
    END_IF;

    // Derivative on c*SP - PV through a first-order filter (backward Euler).
    IF #Td > 0.0 THEN
        #tf := MAX(IN1 := #TdFiltRatio * #Td, IN2 := 1.0E-6);
        #DTerm := #tf / (#tf + #Cycle) * #DTerm
                  + #Gain * #Td / (#tf + #Cycle) * (#eD - #LastED);
    ELSE
        #DTerm := 0.0;
    END_IF;
    #LastED := #eD;

    IF #ExtResetEnable AND #Ti > 0.0 THEN
        // External reset feedback: the integral follows the selected output through a Ti lag,
        // so this controller's output is the valve signal plus its own P and D.
        #iNext := #Integral + #Cycle / MAX(IN1 := #Ti, IN2 := #Cycle) * (#ExtReset - #Integral);
    ELSIF #Ti > 0.0 THEN
        #iNext := #Integral + #Gain * #Cycle / #Ti * #e;
    ELSE
        #iNext := #Integral;
    END_IF;

    #v := #p + #iNext + #DTerm + #Feedforward;
    #u := LIMIT(MN := #OutLow, IN := #v, MX := #OutHigh);

    // A saturated slave asks its master to stop integrating in that direction.
    IF #ExtResetEnable THEN
        #Integral := #iNext;
    ELSIF #Ti > 0.0 AND NOT ((#HoldIntegral > 0 AND #iNext > #Integral) OR (#HoldIntegral < 0 AND #iNext < #Integral)) THEN
        // Conditional integration: stop integrating while the output is pinned and the error pushes it further.
        IF NOT ((#v > #OutHigh AND #iNext > #Integral) OR (#v < #OutLow AND #iNext < #Integral)) THEN
            #Integral := #iNext;
        END_IF;
    END_IF;

    IF #v > #OutHigh THEN
        #AtLimit := 1;
    ELSIF #v < #OutLow THEN
        #AtLimit := -1;
    ELSE
        #AtLimit := 0;
    END_IF;
    #Output := #u;
END_FUNCTION_BLOCK

// OB30 "Cyclic interrupt", cycle time 0.5 s (500 ms).
// "WT-701" is the scaled input (NORM_X/SCALE_X from the analog card), "SC-701" the output to scale back to 0-27648.
// Smith predictor: feed it last cycle's PID output first, then give the PID its corrected measurement.
"WIC_701_Smith_DB"(Input := "WT-701", PidOutput := "WIC_701_DB".Output, Reset := "Manual");
"WIC_701_DB"(Setpoint := "SP", Input := "WIC_701_Smith_DB".Corrected, ManualEnable := "Manual", ManualValue := "ManualOut");
"SC-701" := "WIC_701_DB".Output;
// Show "WT-701" on the HMI, not the corrected value: the operator wants the real measurement.