Lambda tuning, PI, ISA form
Commissioning a Loop and Proving It Holds
On this page
A pump loop is tuned in one afternoon and then runs for ten years, and nobody looks at it again until a tenant complains about pressure or a seal fails early. On the day of the complaint there is no record of the settings, no record of how the loop behaved when it was new, and so no way to say what changed. This lesson puts the whole course to work in the order a commissioning engineer follows, from the first sensor check to a signed record. It then shows how to prove from logged data that the loop still holds months later, and how to tell a loop that needs tuning from one whose equipment is failing. #LoopCommissioning #ControlPerformance #Stiction
Learning Objectives
By the end of this lesson, you will be able to:
- Follow the commissioning order for a feedback loop, from sensor check to signed record
- Identify a first order plus dead time model from a bump-test table and choose lambda tuning from it
- Convert settings into the form and units that a particular controller or drive expects
- Calculate performance measures from a log: error statistics, integrated absolute error, time at a limit and zero crossings
- Distinguish a sticking final element from poor tuning in recorded data, and estimate what each costs
Real-World System Problem: A booster pump set that nobody watches
A booster pump with a variable speed drive holds the water pressure in a building at 4.0 bar. A pressure transmitter on the discharge pipe sends its signal to the drive, the PI controller inside the drive compares it with the setpoint, and the drive changes the pump speed. When taps open, pressure falls and the speed rises.
The loop can fail in two different ways. It can be wrong from the first day: a transmitter range typed in wrongly, a controller acting in the wrong direction, a gain copied from another site. Or it can be right on the first day and become worse slowly, as a valve begins to stick or someone slows the tuning to stop a complaint. Commissioning in a fixed order prevents the first. Only a record over time finds the second, because the loop still “works” on every short visit.
The logger only reads. The loop closes inside the drive, every few milliseconds, with or without the logger.
Fundamental Theory: From first check to long-term proof
Commissioning is an order of work
Every step of commissioning depends on the step before it. Tuning a loop whose transmitter range is wrong gives settings that are wrong by the same ratio. So the order is fixed, and a failed check sends you back to repair, not forward to tuning.
The three checks before automatic
Sensor and range. Compare the transmitter with a reference gauge, then confirm that the controller holds the same range as the transmitter. A 4 to 20 mA transmitter with a range of 0 to 10 bar gives, at pressure
At 4.00 bar this is 10.4 mA. If the drive was set for 0 to 16 bar it would read 6.4 bar from the same current, and every gain would be wrong by the factor 1.6.
Final element in manual. With the controller in manual, step the output through several values and confirm that the pump follows in both directions, without a jump or a dead zone. Record the speed limits set in the drive.
Controller action. For pump pressure the output must fall when the PV rises: reverse acting. Confirm it by test, not by reading the menu: in automatic, with the loop steady, lower the setpoint a little and the output must fall.
Bump test, model and rule
With the loop in manual and the pressure steady, step the output and record the PV until it is steady again. Fit a first order plus dead time (FOPDT) model with process gain
For a pump pressure loop, lambda tuning is a common choice because it gives a smooth response without overshoot. You choose the closed-loop time constant
Enter settings in the controller’s own form and units
The same tuning can be written in several ways. Answer three questions from the manual of the controller in front of you.
- Which form? ISA form uses
and . Parallel form uses and . - Which units for the integral? Seconds, minutes, or repeats per minute (
with in seconds). - Which units for the gain? Percent of output per bar, or percent of output per percent of transmitter span. For a span
in bar, the second is .
The common mistake is to type a correct number into the wrong field. The loop then looks “badly tuned” when the calculation was right.
Test and record
A setpoint step shows speed and overshoot. A disturbance (open a tap or a test valve) shows how far the PV moves and how long it takes to return, which is what the loop does all day. Then write the record: the checks, the model, the settings in the form entered and the test results. The record makes a later comparison possible.
Proving it over time: what to log and what to compute
Four signals describe a loop: PV, setpoint, controller output and mode (automatic or manual). From a log of these, with error
| Measure | How it is computed | What it shows |
|---|---|---|
| Mean error | A steady offset: integral action off, output at a limit, or a loop left in manual | |
| Standard deviation of error | How widely the PV moves about the setpoint | |
| Integrated absolute error (IAE) | Total deviation, large for slow recovery and for oscillation | |
| Time at a limit | share of samples with output at minimum or maximum | The final element is too small for the duty, or wound up |
| Time in manual | share of samples with mode not automatic | Operators do not trust the loop |
| Zero crossings | times per hour that | Oscillation, when the crossings are many and evenly spaced |
Noise crosses zero all the time, so a crossing is counted only when the error leaves a small band on the other side. Hägglund’s monitor (1995) does a related thing: it measures the IAE between successive zero crossings and counts only the large ones. If the crossings are evenly spaced, the oscillation period is twice the typical time between them.
No single number is a verdict. A slow loop and an oscillating loop can have the same standard deviation, so the measures are read together and compared with the values from commissioning.
Sticking element or poor tuning?
A final element with stiction (static friction) does not move until the controller output has changed by some band, and then it jumps. With integral action in the loop this makes a limit cycle. The element is stuck with the PV slightly off the setpoint, the integral term ramps the output until the element jumps, the jump is too large, and the ramp begins in the other direction. No disturbance is needed to keep it going.
A tuning oscillation differs in ways that can be read from a record.
| Evidence in the record | Sticking final element | Gain too high |
|---|---|---|
| Size of the swing | Set by the stiction band, the same in calm and busy hours | Follows the disturbances, dies away in calm hours |
| Shape | Output ramps, PV blunt or square | Both close to sine waves |
| Period | Longer than the loop’s natural period | Near the ultimate period, a few dead times |
| Reduce the gain by half | Swing stays, period becomes longer | Oscillation decays and disappears |
| PV plotted against output | The same closed figure every cycle | A thin line or a spiral that shrinks |
The gain test is the strongest of these, but read it correctly. A stiction limit cycle does change when the gain is reduced: it becomes slower, because the integral term needs more time to cross the band. It does not go away, and its size stays about the same. Choudhury, Shah and Thornhill describe these signatures and a two-parameter stiction model in their work on valve stiction.
On a fast loop with a high gain the box is tilted and rounded, but it is still closed and still repeats.
What it costs: energy and wear
Pump power rises with about the cube of speed, so for a pump rated
with
The cube law holds well when the pump works mostly against pipe friction, and it overstates the saving when most of the pressure is static head.
What months of records show
One day shows a state and months show a direction. If the standard deviation of error rises slowly while the settings are unchanged, the equipment is changing: stiction grows as a valve or actuator wears. If it changed in one step on a known date, look for a person: a changed setting or a loop left in manual. If the mean output for the same demand rises month by month, the pump is delivering less for the same speed, which points to wear or a blocked strainer and not to the controller.
Application 1: Commissioning the booster pump pressure loop
| t (s) | p (bar) | t (s) | p (bar) | t (s) | p (bar) |
|---|---|---|---|---|---|
| 0.0 | 4.00 | 5.5 | 4.81 | 11.0 | 4.97 |
| 0.5 | 4.00 | 6.0 | 4.84 | 11.5 | 4.97 |
| 1.0 | 4.15 | 6.5 | 4.86 | 12.0 | 4.98 |
| 1.5 | 4.28 | 7.0 | 4.89 | 12.5 | 4.98 |
| 2.0 | 4.39 | 7.5 | 4.90 | 13.0 | 4.98 |
| 2.5 | 4.49 | 8.0 | 4.92 | 13.5 | 4.99 |
| 3.0 | 4.57 | 8.5 | 4.93 | 14.0 | 4.99 |
| 3.5 | 4.63 | 9.0 | 4.94 | 14.5 | 4.99 |
| 4.0 | 4.69 | 9.5 | 4.95 | 15.0 | 4.99 |
| 4.5 | 4.74 | 10.0 | 4.96 | 15.5 | 4.99 |
| 5.0 | 4.78 | 10.5 | 4.96 | 16.0 | 4.99 |
Step 1: Checks before automatic
Click to reveal the three checks
-
Sensor range. The expected current at 4.00 bar on a 0 to 10 bar range is
mA. The measured 10.4 mA agrees, and the drive shows 4.00 bar, so the drive holds the same range as the transmitter. ✅ -
Final element in manual. In the bump test the output moved from 60 to 70 percent and the pressure followed smoothly, with no jump and no dead zone. ✅
-
Controller action. More speed gives more pressure (
is positive), so the output must fall when the PV rises. The controller is set to reverse acting. ✅
Step 2: Identify the model from the table
Click to reveal the model
-
Final value and gain. The last four readings are all 4.99 bar, so the change is
bar for a 10 percent step. ✅ -
The two target pressures. ✅
-
Read the two times. The reading at 1.5 s is 4.28 bar, so
s. The value 4.626 lies between 4.57 at 3.0 s and 4.63 at 3.5 s. A straight line between them gives s. ✅ -
Time constant and dead time. ✅
-
Controllability ratio.
. Dead time is small beside the time constant, so PI control will work well. ✅
Step 3: Choose the settings and convert them
Click to reveal the settings
-
Closed-loop time constant.
s. ✅ -
ISA settings. ✅
-
Parallel form for this drive.
percent per bar. ✅ -
Units check. Had the drive wanted its gain in percent of output per percent of span, the entry would be
. The record states which was entered. ✅
Step 4: Test the loop
The tests were simulated against the true plant, with the dead time held in a buffer of past outputs. On site you read the same figures from the drive’s trend.
Click to reveal the test results
-
Setpoint step, 4.0 to 4.5 bar. The output moves at once by
percent, reaches a peak of 68.4 percent, and settles at 65.0 percent. ✅ -
Speed of response. The pressure covers 63.2 percent of the step in 2.09 s, has a peak of 4.501 bar (overshoot 0.1 percent), and is inside ±0.01 bar after 5.95 s. ✅
-
Demand step worth 0.30 bar. The pressure falls to 4.396 bar, a dip of 0.104 bar, and is back inside ±0.01 bar after 10.8 s. The output settles 3.0 percent higher, at 68.0 percent. ✅
-
IAE of the disturbance: 0.608 bar s. ✅
Step 5: Check the result a second way
Click to reveal the check
-
Setpoint response from the design. Lambda tuning aims for a closed loop that is first order with time constant
after the dead time. So 63.2 percent should be reached at s. The test gave 2.09 s. ✅ -
Disturbance IAE from the integral term. When the response has no oscillation, the integral term alone must supply the final change of output,
. The demand needs percent, so the IAE should be bar s. The test gave 0.608 bar s. ✅
The commissioning record
| Item | Result |
|---|---|
| Loop | Booster pump discharge pressure, PI in the drive |
| Sensor | 4 to 20 mA, 0 to 10 bar. 10.4 mA at 4.00 bar on the reference gauge. Drive range matches |
| Final element, in manual | Pump follows 60 to 70 percent smoothly. Speed limits 30 and 100 percent |
| Controller action | Reverse acting, confirmed by test |
| Bump test | 60 to 70 percent, 4.00 to 4.99 bar, read every 0.5 s |
| Model | |
| Rule | Lambda tuning, PI, |
| Settings, ISA form | |
| Settings as entered, parallel form | |
| Setpoint step, 4.0 to 4.5 bar | 63.2 percent in 2.09 s, overshoot 0.1 percent, inside ±0.01 bar in 5.95 s, peak output 68.4 percent |
| Demand step, 0.30 bar | Dip 0.104 bar, inside ±0.01 bar in 10.8 s, IAE 0.608 bar s |
| Normal operating point | 4.0 bar at about 60 percent speed |
| Date | |
| Name and signature |
Application 2: Two pump loops, one day of data
Step 1: Rule out the simple causes
Click to reveal
-
Mean error. It is zero to three decimal places on both loops, so neither has a steady offset. ✅
-
Limits and mode. Neither output reached a limit and neither loop was in manual. ✅
-
Noise floor. Noise alone, with a standard deviation of 0.01 bar, gives a mean absolute error of
bar, which is 29 bar s per hour. The as-built loop, at 34, is close to this floor. The other two are far above it. ✅
Step 2: Read the size and the rhythm of the error
Click to reveal
-
Size. The standard deviations are 0.064 and 0.060 bar, both more than four times the as-built 0.014 bar. By size alone the two loops look the same. ✅
-
Loop 1 rhythm. It has 13.9 crossings per hour, fewer than the as-built loop, and the times between them spread from 119 to 349 s. There is no regular period. The error stays on one side of zero for minutes after each change in demand. ✅
-
Loop 2 rhythm. It has 570.7 crossings per hour, 36 times the as-built figure, and half of all the gaps lie between 5 and 6 s. That is a steady oscillation with a period of about
s. ✅ -
Loop 2 final element. The speed reverses by more than 1 percent 566.9 times per hour, once for almost every crossing. ✅
Step 3: Tuning or equipment?
Click to reveal
-
Loop 1 is a tuning problem. There is no oscillation and no offset, only slow recovery. Its settings read
percent per bar with s. With the commissioning model, s, so the closed loop is almost 40 times slower than the commissioned s. The repair is to restore the recorded settings. ✅ -
Loop 2 has the recorded settings. Its
and s match the commissioning record, and the as-built column shows that those settings do not oscillate on a healthy plant. The period also argues against tuning: the ultimate period of this loop is about 2.2 s, not 10 s. ✅ -
Confirm with the gain test. For 20 minutes of steady demand, halve the gain and compare. The script gives a period of 11.0 s and a swing of 0.206 bar at
, and 23.7 s and 0.269 bar at . The oscillation became slower and did not become smaller. That is a limit cycle from a sticking final element. ✅ -
Compare with a true tuning oscillation. A free loop with the gain raised to 82 percent per bar rings at 2.2 s with a swing of 0.127 bar. At half that gain the swing is 0.043 bar, which is only noise. ✅
-
Look at the shape. Plotted against controller output, loop 2 traces the same closed figure in every cycle and loop 1 does not. The drive’s reported speed shows the fault directly: the command ramps and the speed moves in jumps of about 3 percent. ✅
Step 4: What each loop costs
Click to reveal
-
Direct energy. Against the perfect loop at 1.5723 kW, loop 1 uses 0.011 kWh per day less and loop 2 uses 0.055 kWh per day more, out of
kWh. Both are below 0.2 percent. ✅ -
Energy through the setpoint. Suppose the building needs 4.0 bar for 99 percent of the time. Loop 1 delivers only 3.803 bar at that level, so its setpoint must be raised by 0.197 bar, which is 1.97 percent more speed at all times. The script gives the cost: 3.85 kWh per day for loop 1, 2.45 for loop 2, and 0.65 for the as-built loop. ✅
-
Per year, against the as-built loop. Loop 1:
kWh. Loop 2: kWh. These are 8.5 and 4.8 percent of the pump’s energy. ✅ -
Wear. Loop 2 reverses the pump speed
times per day, about 5.0 million times per year, each a jump of about 3 percent. Loop 1 reverses 8.0 times per hour. The sluggish loop costs more energy and the sticking loop costs equipment life. ✅
Step 5: Check the diagnosis a second way
Click to reveal
-
Model the cycle. If the speed jumps between two values that differ by
percent, the process sees a square wave. A first-order process with gain and time constant answers a square wave of half period with a peak-to-peak swing of . ✅ -
Estimate the band from the record. With a swing of 0.206 bar and a period of 11.0 s (
s): ✅ -
Compare. The simulated element was given a stiction band of 3 percent. The record alone recovers it to within 6 percent, without opening anything. ✅
Verify It in Python
The first script produces every number of Application 1: the bump-test table, the model, the settings and the closed-loop test.
"""Commission the booster pump pressure loop: bump test, model, lambdatuning, and a closed-loop test with a proper dead-time buffer."""from collections import dequeimport numpy as npimport matplotlib.pyplot as plt
# ---- 1. Bump test table (true plant, known only to the simulator) ----K_TRUE, TAU_TRUE, THETA_TRUE = 0.10, 3.0, 0.5 # bar/percent, s, sU0, U1, Y0 = 60.0, 70.0, 4.00 # drive step, start pressure
t_tab = np.arange(0.0, 16.01, 0.5)rise = 1.0 - np.exp(-np.clip(t_tab - THETA_TRUE, 0.0, None) / TAU_TRUE)y_tab = np.round(Y0 + K_TRUE * (U1 - U0) * rise, 2) # gauge reads 0.01 bar
print("Bump test, drive 60 -> 70 percent at t = 0")for i in range(0, len(t_tab), 3): print(" ".join(f"{t:4.1f} s {y:4.2f}" for t, y in zip(t_tab[i:i + 3], y_tab[i:i + 3])))
# ---- 2. Identify K, tau, theta by the two-point method ----y_end = y_tab[-4:].mean()dy = y_end - y_tab[0]K = dy / (U1 - U0)y28 = y_tab[0] + 0.283 * dyy63 = y_tab[0] + 0.632 * dyt28 = np.interp(y28, y_tab, t_tab) # straight line between readingst63 = np.interp(y63, y_tab, t_tab)tau = 1.5 * (t63 - t28)theta = t63 - tauprint(f"\nfinal value {y_end:.3f} bar, change {dy:.3f} bar, K = {K:.4f} bar/percent")print(f"y28 = {y28:.3f} bar at t28 = {t28:.3f} s")print(f"y63 = {y63:.3f} bar at t63 = {t63:.3f} s")print(f"tau = {tau:.3f} s, theta = {theta:.3f} s, theta/tau = {theta / tau:.3f}")
# ---- 3. Lambda tuning, PI, ISA form, then the drive's parallel form ----lam = 3.0 * thetaKc_calc = tau / (K * (lam + theta)) # percent per barTi_calc = tau # sKc, Ti = round(Kc_calc, 1), round(Ti_calc, 1) # the drive accepts 0.1 stepsKp, Ki = Kc, Kc / Ti # parallel formSPAN = 10.0 # transmitter range 0 to 10 barprint(f"\nlambda = {lam:.3f} s")print(f"calculated: Kc = {Kc_calc:.2f} percent/bar, Ti = {Ti_calc:.2f} s")print(f"ISA form: Kc = {Kc:.1f} percent/bar, Ti = {Ti:.1f} s")print(f"parallel form: Kp = {Kp:.1f} percent/bar, Ki = {Ki:.2f} percent/(bar s)")print(f"if gain is per percent of span: {Kc * SPAN / 100:.2f} percent/percent")
# ---- 4. Closed-loop test on the TRUE plant ----DT = 0.01N_DELAY = int(round(THETA_TRUE / DT))T_END, T_SP, T_DIST = 60.0, 5.0, 30.0D_STEP = 0.30 # bar lost when the demand valve opens
n = int(T_END / DT) + 1t = np.arange(n) * DTr = np.where(t >= T_SP, 4.5, 4.0)y = np.zeros(n)u = np.zeros(n)buf = deque([U0] * N_DELAY, maxlen=N_DELAY) # dead-time bufferx = 0.0 # plant state: pressure above 4.0 barinteg = U0 # bumpless start: integral holds 60 %a = np.exp(-DT / TAU_TRUE)for k in range(n): y[k] = Y0 + x e = r[k] - y[k] # reverse acting: PV up, output down integ += Kc / Ti * e * DT out = Kc * e + integ if out > 100.0 or out < 0.0: # clamp anti-windup integ -= Kc / Ti * e * DT out = min(max(out, 0.0), 100.0) u[k] = out u_delayed = buf[0] # what left the drive theta ago buf.append(out) d = D_STEP if t[k] >= T_DIST else 0.0 x = a * x + (1.0 - a) * (K_TRUE * (u_delayed - U0) - d)
def settle(mask, target, band): idx = np.where(mask & (np.abs(y - target) > band))[0] return t[idx[-1] + 1]
sp = (t >= T_SP) & (t < T_DIST)ds = t >= T_DISTk63 = np.where(sp & (y >= 4.0 + 0.632 * 0.5))[0][0]print("\nsetpoint step 4.0 -> 4.5 bar")print(f" first output move {u[np.where(sp)[0][0]] - U0:.2f} percent")print(f" peak output {u[sp].max():.2f} percent")print(f" 63.2 percent after {t[k63] - T_SP:.2f} s")print(f" peak pressure {y[sp].max():.3f} bar " f"(overshoot {100 * (y[sp].max() - 4.5) / 0.5:.1f} percent)")print(f" inside +/-0.01 bar after {settle(sp, 4.5, 0.01) - T_SP:.2f} s")print(f" output at the end {u[np.where(sp)[0][-1]]:.2f} percent")print("demand step worth 0.30 bar")print(f" lowest pressure {y[ds].min():.3f} bar " f"(dip {4.5 - y[ds].min():.3f} bar)")print(f" inside +/-0.01 bar after {settle(ds, 4.5, 0.01) - T_DIST:.2f} s")print(f" IAE {np.sum(np.abs(4.5 - y[ds])) * DT:.3f} bar s")print(f" output at the end {u[-1]:.2f} percent")
fig, ax = plt.subplots(2, 1, figsize=(8, 6), sharex=True)ax[0].plot(t, r, "k--", label="setpoint")ax[0].plot(t, y, label="pressure")ax[0].set_ylabel("bar"); ax[0].legend(); ax[0].grid(alpha=0.3)ax[1].plot(t, u, color="tab:orange")ax[1].set_ylabel("drive output, percent"); ax[1].set_xlabel("time, s")ax[1].grid(alpha=0.3)fig.tight_layout()fig.savefig("commission_pump_loop.png", dpi=120)Expected output
Bump test, drive 60 -> 70 percent at t = 0 0.0 s 4.00 0.5 s 4.00 1.0 s 4.15 1.5 s 4.28 2.0 s 4.39 2.5 s 4.49 3.0 s 4.57 3.5 s 4.63 4.0 s 4.69 4.5 s 4.74 5.0 s 4.78 5.5 s 4.81 6.0 s 4.84 6.5 s 4.86 7.0 s 4.89 7.5 s 4.90 8.0 s 4.92 8.5 s 4.93 9.0 s 4.94 9.5 s 4.95 10.0 s 4.9610.5 s 4.96 11.0 s 4.97 11.5 s 4.9712.0 s 4.98 12.5 s 4.98 13.0 s 4.9813.5 s 4.99 14.0 s 4.99 14.5 s 4.9915.0 s 4.99 15.5 s 4.99 16.0 s 4.99
final value 4.990 bar, change 0.990 bar, K = 0.0990 bar/percenty28 = 4.280 bar at t28 = 1.501 sy63 = 4.626 bar at t63 = 3.464 stau = 2.945 s, theta = 0.519 s, theta/tau = 0.176
lambda = 1.557 scalculated: Kc = 14.32 percent/bar, Ti = 2.94 sISA form: Kc = 14.3 percent/bar, Ti = 2.9 sparallel form: Kp = 14.3 percent/bar, Ki = 4.93 percent/(bar s)if gain is per percent of span: 1.43 percent/percent
setpoint step 4.0 -> 4.5 bar first output move 7.17 percent peak output 68.41 percent 63.2 percent after 2.09 s peak pressure 4.501 bar (overshoot 0.1 percent) inside +/-0.01 bar after 5.95 s output at the end 65.00 percentdemand step worth 0.30 bar lowest pressure 4.396 bar (dip 0.104 bar) inside +/-0.01 bar after 10.82 s IAE 0.608 bar s output at the end 68.00 percentThe second script simulates the 24 hours of Application 2, computes the summary, and runs the gain test. It takes a few seconds.
"""24 hours of booster pump pressure loops, logged every second, andthe summary a monitoring record would hold for each of them."""from collections import dequeimport numpy as npimport matplotlib.pyplot as plt
K, TAU, THETA = 0.10, 3.0, 0.5 # true plant: bar/percent, s, sSP, U0 = 4.0, 60.0 # setpoint, speed that holds itDT = 0.1 # loop step, sHOURS = 24P_RATED = 7.5 # kW at 100 percent speedNOISE = 0.01 # bar, standard deviationBAND = 0.03 # bar, ignore crossings inside this
rng = np.random.default_rng(11)
def demand_profile(): """Pressure that the demand takes away, bar, one value per second.""" sec = np.arange(HOURS * 3600) h = sec / 3600.0 day = (-0.35 + 0.75 * np.exp(-((h - 7.0) / 1.5) ** 2) + 0.55 * np.exp(-((h - 13.0) / 2.0) ** 2) + 0.85 * np.exp(-((h - 19.0) / 1.8) ** 2)) times = np.cumsum(rng.exponential(150.0, size=1200)) # a valve moves levels = rng.normal(0.0, 0.12, size=times.size) # about every 150 s return day + levels[np.searchsorted(times, sec)]
def run(Kc, Ti, stick, d, noise, log=10): """PI loop, ISA form. stick is the stiction band in percent of speed. d has one value per second. One row is logged every `log` loop steps.""" n = noise.size a = np.exp(-DT / TAU) n_delay = int(round(THETA / DT)) buf = deque([U0] * n_delay, maxlen=n_delay) # dead-time buffer x, integ, act = 0.0, U0, U0 pv = np.empty(n // log); out = np.empty(n // log); spd = np.empty(n // log) for k in range(n): y = SP + x + noise[k] e = SP - y integ += Kc / Ti * e * DT cmd = Kc * e + integ if cmd > 100.0 or cmd < 0.0: # clamp anti-windup integ -= Kc / Ti * e * DT cmd = min(max(cmd, 0.0), 100.0) if abs(cmd - act) > stick: # stuck until the command act = cmd # is far enough, then jumps delayed = buf[0] buf.append(act) x = a * x + (1.0 - a) * (K * (delayed - U0) - d[k // 10]) if k % log == 0: pv[k // log], out[k // log], spd[k // log] = y, cmd, act return pv, out, spd
def crossing_gaps(err, step=1.0): """Times between zero crossings of the error, s. A crossing counts only when the error leaves the +/-BAND strip on the other side.""" state, last, gaps = 0, None, [] for i, v in enumerate(err): s = 1 if v > BAND else (-1 if v < -BAND else state) if s != state and state != 0: if last is not None: gaps.append((i - last) * step) last = i state = s return np.array(gaps)
def period(gaps, digits=0): """An oscillation is reported only when the crossings are regular: the middle half of the gaps lies within half the median gap.""" if gaps.size < 20: return "none" q1, med, q3 = np.percentile(gaps, [25, 50, 75]) return f"{2 * med:.{digits}f}" if q3 - q1 <= 0.5 * med else "none"
def reversals(x, size=1.0): """Count changes of direction of x larger than `size`.""" count, direction, extreme = 0, 0, x[0] for v in x: if direction >= 0 and v > extreme or direction <= 0 and v < extreme: if direction == 0 and abs(v - x[0]) > size: direction = 1 if v > x[0] else -1 extreme = v elif abs(v - extreme) > size: direction, extreme, count = -direction, v, count + 1 return count
def summary(pv, out, spd, d): err = SP - pv gaps = crossing_gaps(err) q1, med, q3 = np.percentile(gaps, [25, 50, 75]) power = P_RATED * (spd / 100.0) ** 3 steady = P_RATED * ((U0 + d / K) / 100.0) ** 3 # holds 4.0 bar exactly low = np.percentile(pv, 1.0) raised = P_RATED * ((spd + (SP - low) / K) / 100.0) ** 3 return [ ("mean error, bar", f"{err.mean():+.4f}"), ("standard deviation of error, bar", f"{err.std():.3f}"), ("IAE per hour, bar s", f"{np.abs(err).sum() / HOURS:.0f}"), ("output at a limit, percent of time", f"{100 * np.mean((out >= 99.9) | (out <= 0.1)):.1f}"), ("in manual, percent of time", "0.0"), ("zero crossings per hour", f"{(gaps.size + 1) / HOURS:.1f}"), ("median time between crossings, s", f"{med:.0f}"), ("middle half of those times, s", f"{q1:.0f} to {q3:.0f}"), ("oscillation period (2 x median), s", period(gaps)), ("speed reversals over 1 percent, per hour", f"{reversals(spd) / HOURS:.1f}"), ("mean speed, percent", f"{spd.mean():.2f}"), ("mean power, kW", f"{power.mean():.4f}"), ("steady loop power, kW", f"{steady.mean():.4f}"), ("energy against steady loop, kWh per day", f"{(power.mean() - steady.mean()) * HOURS:+.3f}"), ("pressure held 99 percent of the time, bar", f"{low:.3f}"), ("energy if setpoint is raised to cover, kWh/day", f"{(raised.mean() - steady.mean()) * HOURS:+.2f}"), ]
d = demand_profile()noise = rng.normal(0.0, NOISE, size=HOURS * 3600 * 10)loops = { "As built": dict(Kc=14.3, Ti=2.9, stick=0.0), # lambda = 3 theta "Loop 1": dict(Kc=0.5, Ti=2.9, stick=0.0), # lambda = 60 s "Loop 2": dict(Kc=14.3, Ti=2.9, stick=3.0), # sticks by 3 percent}logs = {n: run(c["Kc"], c["Ti"], c["stick"], d, noise) for n, c in loops.items()}tables = [summary(*logs[n], d) for n in loops]print(f"{'24 hour summary':48s}" + "".join(f"{n:>12s}" for n in loops))for row in zip(*tables): print(f"{row[0][0]:48s}" + "".join(f"{v:>12s}" for _, v in row))
# ---- The gain test: 20 minutes each, steady demand, logged at 0.1 s ----calm = np.full(1200, d[3 * 3600])short = noise[:1200 * 10]print("\nGain test, steady demand, 20 minutes each")print(" loop Kc period, s swing, bar")for tag, stick, gains in (("sticking, as built ", 3.0, (14.3, 7.15)), ("free, gain much too high", 0.0, (82.0, 41.0))): for Kc in gains: pv, out, spd = run(Kc, 2.9, stick, calm, short, log=1) pv = pv[2000:] gaps = crossing_gaps(SP - pv, step=DT) swing = np.percentile(pv, 97.5) - np.percentile(pv, 2.5) print(f" {tag} {Kc:5.2f} {period(gaps, 1):>9s} {swing:10.3f}")
# ---- Plots: five minutes of each loop, and pressure against output ----fig, ax = plt.subplots(2, 2, figsize=(10, 7))s = slice(10 * 3600, 10 * 3600 + 300)for j, n in enumerate(["Loop 1", "Loop 2"]): pv, out, spd = logs[n] ax[0, j].plot(np.arange(300), pv[s]) ax[0, j].axhline(SP, color="k", ls="--") ax[0, j].set_title(f"{n}: pressure from 10:00") ax[0, j].set_xlabel("time, s"); ax[0, j].set_ylabel("bar") ax[1, j].plot(out[s], pv[s], lw=0.8) ax[1, j].set_title(f"{n}: pressure against controller output") ax[1, j].set_xlabel("output, percent"); ax[1, j].set_ylabel("bar")fig.tight_layout()fig.savefig("prove_two_loops.png", dpi=120)Expected output
24 hour summary As built Loop 1 Loop 2mean error, bar +0.0000 -0.0001 +0.0000standard deviation of error, bar 0.014 0.064 0.060IAE per hour, bar s 34 138 179output at a limit, percent of time 0.0 0.0 0.0in manual, percent of time 0.0 0.0 0.0zero crossings per hour 15.7 13.9 570.7median time between crossings, s 172 229 5middle half of those times, s 75 to 318 119 to 349 5 to 6oscillation period (2 x median), s none none 10speed reversals over 1 percent, per hour 14.5 8.0 566.9mean speed, percent 59.27 59.27 59.26mean power, kW 1.5724 1.5719 1.5746steady loop power, kW 1.5723 1.5723 1.5723energy against steady loop, kWh per day +0.001 -0.011 +0.055pressure held 99 percent of the time, bar 3.966 3.803 3.877energy if setpoint is raised to cover, kWh/day +0.65 +3.85 +2.45
Gain test, steady demand, 20 minutes each loop Kc period, s swing, bar sticking, as built 14.30 11.0 0.206 sticking, as built 7.15 23.7 0.269 free, gain much too high 82.00 2.2 0.127 free, gain much too high 41.00 none 0.043Common Mistakes
- Tuning before checking. A wrong transmitter range or a final element that does not move over its full range cannot be corrected by any gain. Do the three checks first.
- Entering ISA values into a parallel-form controller, or seconds where the controller expects minutes or repeats per minute. Read the manual for the form and the units, and write both forms in the record.
- Testing only a setpoint step. Most loops spend their life rejecting disturbances, so test one and record the dip and the recovery time.
- Slowing the tuning to stop an oscillation that appeared with unchanged settings. The equipment changed, so find what changed.
- Judging a loop by standard deviation alone. A slow loop and a limit cycle can have the same value. Read it with the zero crossings, counted outside a band a few times larger than the noise.
Summary
- Commissioning follows a fixed order: sensor and range, final element in manual, controller action, bump test, model, rule, entry in the controller’s own form and units, tests, record.
- For the booster pump, lambda tuning with
gave percent per bar and s, entered in parallel form as and . - A log of PV, setpoint, output and mode gives the measures: mean error, standard deviation, IAE, time at a limit, time in manual and zero crossings.
- A stiction limit cycle stays when the gain is halved and only becomes slower. A tuning oscillation decays and disappears.
- An oscillation wastes little energy directly. The energy is lost when the setpoint is raised to cover the variation, and the equipment is worn by the reversals.
- Records over months separate a change made by a person from a change in the equipment.
Exercises
1. The settings
Answer
Gain:
2. A log of the booster pump loop shows 412 zero crossings of the error in one hour, evenly spaced. The settings match the commissioning record. Find the period, and say whether poor tuning is a likely cause when the ultimate period of this loop is about 2.2 s.
Answer
Period
3. After a sticking valve is repaired, the setpoint of a booster pump is lowered from 4.2 to 4.0 bar and the mean speed falls from 62 to 60 percent. The pump is rated 7.5 kW at 100 percent speed. Using the cube law at the mean speed, find the power saved, the energy saved per year of continuous running, and the saving in percent.
Answer
4. A pressure loop with
Answer
Half period
References
- Seborg, D. E., Edgar, T. F., Mellichamp, D. A. and Doyle, F. J., Process Dynamics and Control, 4th edition, Wiley, 2016.
- Åström, K. J. and Hägglund, T., Advanced PID Control, ISA, 2006.
- Hägglund, T., “A control-loop performance monitor”, Control Engineering Practice, 1995.
- Choudhury, M. A. A. S., Thornhill, N. F. and Shah, S. L., “Modelling valve stiction”, Control Engineering Practice, 2005.
The transmitter on a pump reads 0 to 10 bar. The drive was set up for a 0 to 16 bar transmitter. You calculate perfect PI settings from a bump test and enter them. What is wrong with the loop?
The model is the lesson's bump test: K = 0.099 bar per percent, τ = 2.94 s, θ = 0.519 s, with PI settings Kc = 14.3 percent per bar and Ti = 2.9 s. At 5 s the demand rises. The dark line in the lower strip is the controller output; the gold line is what the element really does. With the band on, the element sticks, then jumps. Halve the gain: the cycle gets slower, not smaller. Switch the band off and raise the gain toward 7 times: a tuning oscillation appears, fast and smooth, and lowering the gain removes it.
Check yourself
Three questions. Each wrong choice is a mistake people really make, so read the note after you answer.
1. A 4 to 20 mA transmitter has a range of 0 to 6 bar. The drive it feeds is set for 0 to 10 bar. The real pressure is 3.0 bar. What does the drive show?
2. The commissioned integral time is Ti = 2.9 s. A replacement drive asks for the integral in repeats per minute. What do you enter?
3. A pump loop swings about 0.10 bar with a period of about 10 s. You halve the controller gain for a test. It now swings about 0.14 bar with a period of about 19 s. What is the most likely cause?
- Sensor first: at 4.00 bar the 0 to 10 bar transmitter gives 10.4 mA, and the drive must use the same range.
- In manual, the pump follows each output step in both directions, with no jump.
- Reverse acting, proved by test: lower the setpoint and the output must fall.
- Bump test in manual: K = 0.099 bar per percent, τ = 2.94 s, θ = 0.52 s.
- Lambda tuning with λ = 3θ: Kc = 14.3 percent per bar, Ti = 2.9 s.
- This drive uses the parallel form: Kp = 14.3 and Ki = 14.3 ÷ 2.9 = 4.93 per second.
Discussion
No comments yet. Questions, results from your own build, a better way to explain it: all welcome.
My notes on this page
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.
Notes on earlier wording
The lesson has changed and these words are no longer in it. Your notes are kept, with the words you chose.