Choosing lambda
A small
A temperature loop that was tuned by guessing can swing for an hour after every change, and a loop that was tuned from a textbook table can do the same thing one month later, when the plant has changed a little. In both cases someone switches the controller to manual, and the loop stops earning its cost. Tuning is the work of choosing three numbers so that the loop is fast enough for the job and still has margin when the process is not exactly what the model says. This lesson gives you the three common step-test rules as formulas, tests each one on the same two machines, and shows how to choose between them. #PIDTuning #ProcessControl #LambdaTuning
By the end of this lesson, you will be able to:
A hot water tank with an electric heater supplies a wash line. The controller reads the temperature at the outlet and sets the heater power between 0 and 100 percent. The water takes time to travel from the heater to the sensor, so the sensor sees nothing for 40 seconds after the heater changes. After that the temperature moves slowly, with a time constant of 300 seconds.
Whoever tunes this loop must choose. Large settings bring the water to temperature quickly, but throw the heater to full power at every change, and the temperature passes the setpoint before it settles. Small settings are gentle, but recover slowly when a tap opens and cold water enters the tank. Water that is too hot can scald; water that is too cold fails the wash.
A higher controller gain and a shorter integral time make a loop faster, and the same two changes bring it closer to the point where it oscillates without stopping. The distance from that point is the margin.
Margin matters because the model is never exact: the dead time of a water heater changes with the flow through it, and the process gain with the supply voltage and the inlet temperature. A loop tuned with no margin works on the day of the test and oscillates on another day.
Every rule in this lesson starts from a first order plus dead time (FOPDT) model of the process:
Here
All settings in this lesson are for the ISA standard form of the controller:
Two ratios appear in every rule. The ratio
Ziegler and Nichols published two tables in 1942. This is the first one, the open-loop table, also called the reaction-curve or step-response method. It must not be confused with their second table, which uses the ultimate gain and is given later in this lesson.
| Controller | |||
|---|---|---|---|
| P | none | none | |
| PI | none | ||
| PID |
The value 3.33 is
The aim of the rule was a quarter-amplitude decay after a load disturbance: each peak of the oscillation is one quarter of the peak before it. Today this is seen as too oscillatory for most loops, and it leaves little margin.
Cohen and Coon (1953) kept the same quarter-amplitude aim but corrected the settings for the ratio
| Controller | |||
|---|---|---|---|
| P | none | none | |
| PI | none | ||
| PID |
When
Lambda tuning comes from internal model control (IMC). In place of a fixed response shape, you choose how fast the closed loop should be, as a closed-loop time constant
| Controller | |||
|---|---|---|---|
| PI | none | ||
| PID |
These are the IMC-based settings for an FOPDT model as tabulated by Seborg and co-authors. With the PI settings, a setpoint step gives a response close to a first-order curve: nothing for the dead time
Choosing lambda
A small
Lambda tuning has one known weakness: the integral time equals the process time constant, so on a slow process with a short dead time the integral term is slow, and the loop takes a long time to return after a load disturbance.
The second Ziegler-Nichols table needs no model. With integral and derivative switched off, the gain is raised until the loop oscillates with a constant amplitude. That gain is the ultimate gain
| Controller | |||
|---|---|---|---|
| P | none | none | |
| PI | none | ||
| PID |
A P-only gain of
When a step test is not possible, tune by trial: one setting at a time, and one test after each change.
Check in manual that the output moves the process in the expected direction, and set the controller action (reverse acting for heating).
Start with a low gain, a very long integral time and no derivative.
Make a small setpoint step. Raise the gain in steps of about 50 percent until the response is quick with one small overshoot. If the loop begins to oscillate, halve the gain.
Shorten the integral time in steps until the offset is removed in an acceptable time without a new oscillation.
Add derivative only on a slow, clean signal such as temperature, and only if the loop needs it. Begin with a derivative time of about one tenth of the integral time.
Finish with a load test (open a valve, switch a load), because the load response is the one the loop meets every day.
Most pressure, flow and level loops are best served by lambda tuning with PI. Ziegler-Nichols and Cohen-Coon settings are useful as an upper limit: they show the largest gain anyone would try.
The formulas above give
A gain of 7.5 percent per °C with a transmitter ranged 0 to 100 °C is a dimensionless gain of 7.5. With a transmitter ranged 0 to 200 °C the same loop needs a dimensionless gain of 15. Some controllers ask for the proportional band, which is
The two groups. The gain scale and the dead time ratio are
A ratio this small means the process is not hard to control. ✅
Ziegler-Nichols open loop. For PI:
Cohen-Coon, PI.
✅
Cohen-Coon, PID.
✅
Lambda, PI, with
✅
Lambda, PID, with
✅
| Rule | |||
|---|---|---|---|
| Ziegler-Nichols PI | 13.50 | 133.2 | 0 |
| Ziegler-Nichols PID | 18.00 | 80.0 | 20.0 |
| Cohen-Coon PI | 13.67 | 104.2 | 0 |
| Cohen-Coon PID | 20.50 | 93.3 | 14.2 |
| Lambda PI | 7.50 | 300.0 | 0 |
| Lambda PID | 10.67 | 320.0 | 18.8 |
What the first move is. At the instant of the setpoint step the error jumps to 5 °C. The integral has not yet added anything, and the derivative acts on the measurement, which has not moved. So the output jumps by
What is available. The heater is at 40 percent, so only
Compare. Ziegler-Nichols PI asks for
Lambda. Lambda PI asks for
The four quarter-amplitude settings drive the heater to 100 percent for a 5 °C change. At the limit the linear model no longer describes the loop.
Method. The time step is fixed at 0.1 s. The dead time is a buffer of
Tests. The setpoint steps from 45 to 50 °C at time zero. At 4000 s a load equal to 10 percent of heater power is removed. Without control this load would lower the temperature by
Measures. Overshoot is in percent of the 5 °C step. Settling time is the last time the temperature is more than 2 percent of the step (0.1 °C) from the setpoint. IAE is the area between the temperature and the setpoint, in °C·s. ✅
Results. The table below is the output of the script in the Python section. ✅
| Rule | First move (percent) | Overshoot (percent) | Settling (s) | IAE, setpoint (°C·s) | Largest dip, load (°C) | Recovery, load (s) | IAE, load (°C·s) |
|---|---|---|---|---|---|---|---|
| Ziegler-Nichols PI | 67.5 | 25.9 | 489 | 515 | 368 | 105 | |
| Ziegler-Nichols PID | 90.0 | 16.5 | 267 | 438 | 154 | 53 | |
| Cohen-Coon PI | 68.3 | 29.2 | 598 | 568 | 376 | 116 | |
| Cohen-Coon PID | 102.5 | 21.5 | 279 | 405 | 143 | 51 | |
| Lambda PI | 37.5 | 4.1 | 243 | 434 | 857 | 400 | |
| Lambda PID | 53.3 | 3.1 | 443 | 429 | 774 | 300 |
For the setpoint step, lambda PI is the best PI loop on every measure: 4.1 percent overshoot (0.2 °C) against 25.9 and 29.2 percent, and it settles in half the time. For the load disturbance the order is reversed. The quarter-amplitude PI settings return to the setpoint in 368 to 376 s. Lambda PI needs 857 s, because its integral time is the full 300 s.
The largest dip changes much less than the recovery time. For the first 40 s after the load arrives the sensor has seen nothing, so no setting can help.
Four of the six rows ask for a first move the heater cannot deliver. Their overshoot in the table is smaller than a simulation without the limit would show, because the limit clips the first move.
Why. At a lower flow the water takes longer to reach the sensor. Suppose the real dead time is 60 s while the settings were computed for 40 s. ✅
Run. The same setpoint step is simulated for 6000 s with no load step. The script reports the peak temperature and the swing (highest minus lowest temperature) in the last 1000 s. ✅
Ziegler-Nichols PI and both Cohen-Coon sets. These never settle. The temperature still swings by 7.07 °C, 7.30 °C and 5.53 °C after 5000 s, and the heater switches between its limits. ✅
Ziegler-Nichols PID. This set settles in the end, but slowly: it is still swinging by more than 1 °C at 2000 s, and the swing has fallen to 0.08 °C after 5000 s. Its peak is 52.2 °C. ✅
Lambda PI and PID. Both settle fully, with peaks of 51.3 °C and 51.2 °C. The overshoot has grown to about 1.3 °C, but the loop is stable. ✅
Idea. After a load step the controller output must end 10 percent higher than before, to replace the lost power. When the loop has settled the error is zero, so the whole change comes from the integral term:
Rearrange. The integral of the error after the load step is
✅
Compare. The lambda PI response does not cross the setpoint during the recovery, so the IAE equals this integral. The simulation gives 400 °C·s, the same value. ✅
Same check for Ziegler-Nichols PI.
Choose lambda.
Controller gain.
✅
Integral time.
First move. For a 0.5 bar step the drive speed jumps by
Predicted response. The pressure reaches 63.2 percent of the step at about
Simulation. With a time step of 0.001 s the simulation gives 63.2 percent at 2.02 s, a 2 percent settling time of 6.09 s and an overshoot of 0.0 percent. The prediction holds. ✅
New settings.
Only the gain changes. The integral time stays at
Setpoint step. The first move falls to
Load disturbance,
Load disturbance,
Check by hand. The load IAE is
| Measure | ||
|---|---|---|
| 15.00 | 8.57 | |
| 3.0 | 3.0 | |
| First move for 0.5 bar (percent) | 7.50 | 4.29 |
| Settling time, setpoint (s) | 6.09 | 12.11 |
| Largest dip, load (bar) | 0.204 | 0.259 |
| Recovery, load (s) | 13.54 | 18.58 |
| IAE, load (bar·s) | 1.20 | 2.10 |
The script computes the six settings for the hot water tank, simulates the setpoint step and the load step, repeats the test with a dead time of 60 s, and runs the two lambda settings on the booster pump. It saves one plot.
import numpy as npimport matplotlib.pyplot as plt
def step_test_rules(K, tau, theta, lam): """ISA-form settings (Kc, Ti, Td) from an FOPDT model.""" r = theta / tau a = tau / (K * theta) return { "ZN PI": (0.9 * a, 3.33 * theta, 0.0), "ZN PID": (1.2 * a, 2.0 * theta, 0.5 * theta), "CC PI": (a * (0.9 + r / 12), theta * (30 + 3 * r) / (9 + 20 * r), 0.0), "CC PID": (a * (4 / 3 + r / 4), theta * (32 + 6 * r) / (13 + 8 * r), 4 * theta / (11 + 2 * r)), "Lambda PI": (tau / (K * (lam + theta)), tau, 0.0), "Lambda PID": ((tau + theta / 2) / (K * (lam + theta / 2)), tau + theta / 2, tau * theta / (2 * tau + theta)), }
def simulate(K, tau, theta, Kc, Ti, Td, dr, dd, t_dist, t_end, dt, u_lo, u_hi): """Closed loop in deviation variables. Dead time is a ring buffer of theta/dt samples. Derivative acts on the measurement. The integral stops while the output is at a limit.""" n, nd = int(round(t_end / dt)), int(round(theta / dt)) buf, pos = np.zeros(nd), 0 a = np.exp(-dt / tau) # exact first-order step t = np.arange(n) * dt y_log, u_log = np.zeros(n), np.zeros(n) y = y_prev = integ = 0.0 for k in range(n): d = dd if t[k] >= t_dist else 0.0 e = dr - y u_raw = Kc * (e + integ / Ti - Td * (y - y_prev) / dt) u = min(max(u_raw, u_lo), u_hi) if u == u_raw: integ += e * dt y_prev = y y_log[k], u_log[k] = y, u delayed = buf[pos] # what entered theta seconds ago buf[pos] = u + d pos = (pos + 1) % nd y = a * y + (1 - a) * K * delayed return t, y_log, u_log
def measures(t, y, dr, t_dist, dt): band = 0.02 * abs(dr) sp, ld = t < t_dist, t >= t_dist overshoot = max(0.0, (y[sp].max() - dr) / dr * 100) outside = np.where(np.abs(y[sp] - dr) > band)[0] settle = t[sp][outside[-1] + 1] iae_sp = np.sum(np.abs(dr - y[sp])) * dt dev = y[ld] - dr outside = np.where(np.abs(dev) > band)[0] recover = t[ld][outside[-1] + 1] - t_dist return overshoot, settle, iae_sp, dev.min(), recover, np.sum(np.abs(dev)) * dt
# ---------- Plant A: hot water tank, 45 C at 40 percent ----------K, tau, theta = 0.5, 300.0, 40.0dr, dd = 5.0, -10.0 # +5 C setpoint, -10 percent loadprint("Plant A: K = 0.5 C/percent, tau = 300 s, theta = 40 s, lambda = 40 s")print(f"{'rule':11s}{'Kc':>7s}{'Ti':>7s}{'Td':>6s}{'move':>7s}{'OS%':>6s}" f"{'ts':>6s}{'IAE':>6s}{'dip':>7s}{'trec':>6s}{'IAEd':>6s}")rules_a = step_test_rules(K, tau, theta, lam=40.0)fig, ax = plt.subplots(2, 1, figsize=(8, 7), sharex=True)for name, (Kc, Ti, Td) in rules_a.items(): t, y, u = simulate(K, tau, theta, Kc, Ti, Td, dr, dd, 4000.0, 8000.0, 0.1, u_lo=-40.0, u_hi=60.0) m = measures(t, y, dr, 4000.0, 0.1) print(f"{name:11s}{Kc:7.2f}{Ti:7.1f}{Td:6.1f}{Kc * dr:7.1f}{m[0]:6.1f}" f"{m[1]:6.0f}{m[2]:6.0f}{m[3]:7.2f}{m[4]:6.0f}{m[5]:6.0f}") ax[0].plot(t, 45 + y, label=name) ax[1].plot(t, 40 + u)ax[0].axhline(50, color="k", lw=0.5)ax[0].set_ylabel("temperature (C)"); ax[0].legend(ncol=3, fontsize=8, loc="lower right")ax[1].set_ylabel("heater output (percent)"); ax[1].set_xlabel("time (s)")ax[0].set_title("Plant A: setpoint step at 0 s, load step at 4000 s")fig.tight_layout(); fig.savefig("tuning_rules_plant_a.png", dpi=120)
# Trial change after the rule: shorter integral time on the lambda PI loopt, y, u = simulate(K, tau, theta, 7.5, 150.0, 0.0, dr, dd, 4000.0, 8000.0, 0.1, u_lo=-40.0, u_hi=60.0)m = measures(t, y, dr, 4000.0, 0.1)print(f"{'Kc 7.5, Ti 150':15s} OS% {m[0]:.1f}, ts {m[1]:.0f}, dip {m[3]:.2f}, " f"trec {m[4]:.0f}, IAEd {m[5]:.0f}")
# Same settings, but the real dead time is 60 s, not the 40 s in the modelprint("\nPlant A with a real dead time of 60 s (no load step)")for name, (Kc, Ti, Td) in rules_a.items(): t, y, u = simulate(K, tau, 60.0, Kc, Ti, Td, dr, 0.0, 9e9, 6000.0, 0.1, u_lo=-40.0, u_hi=60.0) late = y[t >= 5000.0] print(f"{name:11s} peak {45 + y.max():5.1f} C, swing after 5000 s " f"{late.max() - late.min():5.2f} C")
# ---------- Plant B: booster pump, lambda tuning ----------K, tau, theta = 0.10, 3.0, 0.5print("\nPlant B: K = 0.10 bar/percent, tau = 3 s, theta = 0.5 s")print(f"{'lambda':>7s}{'Kc':>7s}{'Ti':>5s}{'move':>6s}{'OS%':>6s}{'ts':>6s}" f"{'dip':>7s}{'trec':>6s}{'IAEd':>6s}")for lam in (3 * theta, 6 * theta): Kc, Ti = tau / (K * (lam + theta)), tau t, y, u = simulate(K, tau, theta, Kc, Ti, 0.0, 0.5, -6.0, 30.0, 60.0, 0.001, u_lo=-60.0, u_hi=40.0) m = measures(t, y, 0.5, 30.0, 0.001) print(f"{lam:7.1f}{Kc:7.2f}{Ti:5.1f}{Kc * 0.5:6.2f}{m[0]:6.1f}{m[1]:6.2f}" f"{m[3]:7.3f}{m[4]:6.2f}{m[5]:6.2f}")Expected output
Plant A: K = 0.5 C/percent, tau = 300 s, theta = 40 s, lambda = 40 srule Kc Ti Td move OS% ts IAE dip trec IAEdZN PI 13.50 133.2 0.0 67.5 25.9 489 515 -0.88 368 105ZN PID 18.00 80.0 20.0 90.0 16.5 267 438 -0.65 154 53CC PI 13.67 104.2 0.0 68.3 29.2 598 568 -0.87 376 116CC PID 20.50 93.3 14.2 102.5 21.5 279 405 -0.66 143 51Lambda PI 7.50 300.0 0.0 37.5 4.1 243 434 -1.07 857 400Lambda PID 10.67 320.0 18.8 53.3 3.1 443 429 -0.76 774 300Kc 7.5, Ti 150 OS% 24.0, ts 412, dip -1.05, trec 378, IAEd 200
Plant A with a real dead time of 60 s (no load step)ZN PI peak 53.5 C, swing after 5000 s 7.07 CZN PID peak 52.2 C, swing after 5000 s 0.08 CCC PI peak 53.6 C, swing after 5000 s 7.30 CCC PID peak 52.8 C, swing after 5000 s 5.53 CLambda PI peak 51.3 C, swing after 5000 s 0.00 CLambda PID peak 51.2 C, swing after 5000 s 0.00 C
Plant B: K = 0.10 bar/percent, tau = 3 s, theta = 0.5 s lambda Kc Ti move OS% ts dip trec IAEd 1.5 15.00 3.0 7.50 0.0 6.09 -0.204 13.54 1.20 3.0 8.57 3.0 4.29 0.0 12.11 -0.259 18.58 2.10The simulation has no sensor noise and a heater that responds at once. Treat the results as a ranking of the rules, and confirm the chosen settings with a small step on the real equipment.
1. The booster pump has
2. For the hot water tank (
3. A controller needs a dimensionless gain and a proportional band. The tuning result is
Span 100 °C: dimensionless gain
4. An oscillation test on the hot water tank gives an ultimate gain
PI:
5. The drive of the booster pump must not move by more than 5 percent for a 0.5 bar setpoint step. Find the smallest
The first move is
Two people tune the same hot water tank. With setting A a new setpoint is passed by 25.9 percent before the water settles. With setting B it is passed by only 4.1 percent. Someone now opens a tap and cold water enters the tank. Which setting brings the temperature back sooner?
Three questions. Each wrong choice is a mistake people really make, so read the note after you answer.
1. A step test on the tank gives K = 0.5 °C per percent, τ = 300 s and θ = 40 s. What is the PI gain by the Ziegler-Nichols open-loop rule?
2. The tank has lambda PI settings for λ = 40 s: a gain of 7.5 percent per °C and an integral time of 300 s. The engineer wants a gentler loop and changes λ to 120 s. Which settings change?
3. The settings were computed for a dead time of 40 s. On a day of low flow the real dead time is 60 s. Which PI setting still brings the tank to rest?
No comments yet. Questions, results from your own build, a better way to explain it: all welcome.
Kept on this device only. Nothing is sent anywhere.
Tip: select words in the lesson, or tap a figure or an equation, to put a note right there.
The lesson has changed and these words are no longer in it. Your notes are kept, with the words you chose.