Multi-loop PID and decoupling

A PID on each variable, each driving one valve. The relative gain array says which valve should go with which variable; a static decoupler cancels the steady interaction, so each loop sees only its own variable.

Theory

Multi-loop (decentralized) control is the plant default for several variables: one PID per variable, each on one valve. It works when each valve mostly moves its own variable. When it doesn't, closing one loop changes the process the other loop sees.

The relative gain array (RGA) measures that, from the steady-state gain matrix GG alone:

Λ=G∘(G−1)⊤,λ11=11−g12g21g11g22  (2×2)\Lambda = G \circ (G^{-1})^\top,\qquad \lambda_{11} = \frac{1}{1 - \dfrac{g_{12}g_{21}}{g_{11}g_{22}}}\ \ (2\times 2)

λij\lambda_{ij} is the gain from valve jj to variable ii with the other loops open, divided by the same gain with them closed (perfectly). Rows and columns add up to 1.

  • Pair on relative gains close to 1.
  • Never pair on a negative one: closing the other loops would reverse the sign, and the loop goes unstable when they close (or open).
  • Around 0.5, no pairing is good: the loops will fight whatever you choose.

Static decoupler. Put a matrix between the PIDs and the valves so the plant they see is diagonal at steady state. The simplified form keeps each loop on its own valve and adds a little of the other loop's output:

ua=w1+caw2,ub=w2+cbw1,ca=−g1bg1a, cb=−g2ag2bu_a = w_1 + c_a w_2,\quad u_b = w_2 + c_b w_1,\qquad c_a = -\frac{g_{1b}}{g_{1a}},\ c_b = -\frac{g_{2a}}{g_{2b}}

Each loop then sees its own gain divided by its relative gain (1.6× here, at λ = 0.64), so check its tuning again. A dynamic decoupler adds lead-lags for the transients; the static one gets most of the benefit.

Better than a decoupler: change the variables. If the physics gives you combinations that don't interact (total flow and ratio, energy and mass), control those. It decouples exactly, at every operating point.

When it works, and when it breaks

Works
  • Two or three interacting variables with relative gains between about 0.6 and 1.5.

  • Blending (level and composition, flow and temperature), evaporators, dryers, boilers (pressure and level).

  • When the operators should still be able to put one loop in manual and understand the other.

Breaks
  • Relative gains near 0.5 or below: the loops fight whatever the tuning.

  • A negative relative gain on the chosen pairing: unstable when another loop is in manual (or saturated).

  • One valve saturates: its loop is effectively open, the decoupler's assumption is wrong, and the other loop sees a different plant.

  • The gains move with the operating point: a decoupler designed at one recipe is wrong at another.

How to tune it

  1. Bump test each valve with the other loops in manual: the full gain matrix (and the dynamics).
  2. RGA at the operating points you run. Pick the pairing with relative gains closest to 1, positive.
  3. Tune each loop alone (SIMC on its own pair), then close both and watch them interact.
  4. If they fight: detune the less important loop (make it 3–5× slower), or add the decoupler and retune on the decoupled plant.
  5. Check with each loop in manual in turn, and with a valve at its limit.
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

  • Run both PIDs in the same OB, then the decoupler, then write both valves.
  • Bumpless: in manual, undo the decoupler: solve for the PID outputs that give the present valve positions, and track those.
  • Windup: when a valve saturates, hold the integral of the loop that drives it (and consider switching the decoupler off).
  • Keep the decoupler gains in a DB next to the operating point they were measured at.

Siemens and elsewhere

Siemens
  • Two PID_Compact instances, one per variable; the decoupler is your own SCL between them and the valves.
  • PID_Compact's manual mode with ManualValue = the tracked value keeps the transfer bumpless.
  • For a fixed recipe set, store a decoupler per recipe and switch with the recipe.
Elsewhere
  • DCS: standard PID blocks plus calculation blocks for the decoupler; some vendors ship a 2×2 decoupling block.
  • Ratio and total-flow structures are the common plant-floor answer for blending: see the ratio rung.
  • MPC is the next step when there are more variables, constraints and changing priorities.

Interactive Controller Sandbox

Test and tune Multi-loop PID and decoupling 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): 3.26
Ti (integral): 360 s
Td (derivative): 0 s

Closed-Loop Response: Decoupling vs Baseline PI

Simulating…
Running test scenarios…
Block Diagram
SP r₁SP r₂Σ+−Σ+−PID TIC-901temperaturePID LIC-902levelP · I · Du₁u₂FV-901hotFV-902coldProcesseach valve moves bothd: outlet demandy₁ Ty₂ hTT-901LT-902
Generated code
// Loop Lab export: Mixing tank: level and temperature, TIC-901
// TIA Portal SCL (S7-1200 / S7-1500). Generated code: review before use on a real plant.

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 := 2.0;    // 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 := 3.26;        // % output per % of span
      Ti : Real := 360.0;          // 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 := 100.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 2.0 s (2000 ms).
// "TT-901" is the scaled input (NORM_X/SCALE_X from the analog card), "FV-901" the output to scale back to 0-27648.
// Two loops: TIC-901 (temperature) drives FV-901, LIC-902 (level) drives FV-902.
// Give LIC-902 its own tuning once at start-up (OB100): "LIC_902_DB".Gain := 12.0; "LIC_902_DB".Ti := 64.0; "LIC_902_DB".Td := 0.0; "LIC_902_DB".InLow := 0.0; "LIC_902_DB".InHigh := 2.0; "LIC_902_DB".Invert := FALSE;
// While a valve is pinned, the loop driving it holds its integral.
"TIC_901_DB"(Setpoint := "SP", Input := "TT-901", ManualEnable := "Manual", ManualValue := "ManualOut", HoldIntegral := "SatA");
"LIC_902_DB"(Setpoint := "SP2", Input := "LT-902", ManualEnable := "Manual", ManualValue := "ManualOut2", HoldIntegral := "SatB");
"UA" := "TIC_901_DB".Output;
"UB" := "LIC_902_DB".Output;
"SatA" := SEL(G := "UA" >= 100.0, IN0 := SEL(G := "UA" <= 0.0, IN0 := 0, IN1 := -1), IN1 := 1);
"SatB" := SEL(G := "UB" >= 100.0, IN0 := SEL(G := "UB" <= 0.0, IN0 := 0, IN1 := -1), IN1 := 1);
"FV-901" := LIMIT(MN := 0.0, IN := "UA", MX := 100.0);
"FV-902" := LIMIT(MN := 0.0, IN := "UB", MX := 100.0);