Pump PID Flow Control
PID flow control is one of the most common industrial control loops. A centrifugal pump driven by a VFD modulates its speed (and thus flow output) to maintain an operator-set flow rate as measured by a flow transmitter.
I/O list
| Tag | Type | Description |
|---|---|---|
| FlowTx_mA | AI | Flow transmitter 4-20 mA raw |
| Flow_GPM | REAL | Scaled flow in GPM |
| FlowSP_GPM | REAL | Operator setpoint from HMI |
| VFD_Speed_Pct | AO | VFD speed reference 0-100% |
| Pump_Run | DO | Pump run command |
| Auto_Mode | DI | Auto/Manual mode selector |
Structured Text code
PROGRAM main
VAR
PIDInst : PID;
Kp : REAL := 0.8;
Ki : REAL := 0.05;
Kd : REAL := 0.0;
ManualOutput : REAL := 0.0; (* HMI input when in Manual *)
END_VAR
(* Scale 4-20 mA to 0-500 GPM *)
Flow_GPM := (FlowTx_mA - 4.0) / 16.0 * 500.0;
(* Pump runs whenever in Auto and SP > 0, OR when Manual and operator sets output > 0 *)
IF Auto_Mode THEN
Pump_Run := FlowSP_GPM > 1.0;
PIDInst(
SP := FlowSP_GPM,
PV := Flow_GPM,
KP := Kp,
KI := Ki,
KD := Kd
);
VFD_Speed_Pct := PIDInst.OUT;
ELSE
Pump_Run := ManualOutput > 1.0;
VFD_Speed_Pct := ManualOutput;
END_IF;
(* Clamp output to valid range *)
IF VFD_Speed_Pct < 0.0 THEN VFD_Speed_Pct := 0.0; END_IF;
IF VFD_Speed_Pct > 100.0 THEN VFD_Speed_Pct := 100.0; END_IF;How it works
Mode switching: Auto runs PID modulating VFD speed to match flow setpoint. Manual lets operator directly set VFD speed (useful for commissioning or troubleshooting).
Analog scaling: 4-20 mA from flow transmitter scales to 0-500 GPM. Adjust the 500.0 to your transmitter range.
PID tuning: Kp=0.8, Ki=0.05 is a starting point for typical centrifugal pump flow. Real systems autotune or hand-tune per process. See [PID Tuning Guide](/concepts/pid-tuning).
Output clamping: VFD speed clamped to 0-100% to prevent integral windup and out-of-range values. Modern PID FBs often handle this internally — verify.
Pump run output: linked to PID output > 1% so the pump only runs when there's actually flow demanded. Saves pump wear at zero setpoint.