Field fix / guidePLC / HMI Code & LogicVendor-agnostic (IEC 61131-3)Pump Systemsindustrial-automation

Duty Standby Alternation — PLC Control Template

Shared by TSIMEREZIVO Team · 4 Oct 2026 · 35 views

# Duty/Standby Pump Alternation — Usage Guide ## Overview Implements API 610 / ISO 13709 duty/standby pump logic with runtime-equalised automatic alternation, soft-handover (overlap start), and auto-failover within 2 seconds of duty pump loss. ## Key Features - **Runtime equalisation** — duty assigned to pump with fewer hours; prevents bearing fatigue on one pump - **Soft handover** — standby starts and confirms running BEFORE duty is stopped (zero process interruption) - **Auto-failover** — 2s confirmation window prevents nuisance failover; latched fault keeps failed pump isolated - **Forced duty override** — operator can manually force either pump to duty via HMI - **Both-failed alarm** — distinct critical alarm when neither pump is available ## I/O Configuration Two identical pump motor control loops (A and B). Each requires the same DI/DO/AI signals as the `latching-interlock-pump` template. Reference that template for individual pump wiring. ## Alternation Methods | Method | Mode | Trigger | |--------|------|---------| | Planned (scheduled) | Mode 3 | Operator button or timed schedule | | Automatic (runtime) | Evaluates on shutdown | Delta > `EQUALIZE_THRESHOLD` hours | | Forced | Override flag | Operator selects specific pump | ## Setting `HANDOVER_OVERLAP_TICKS` | Application | Setting | |-------------|---------| | Low-inertia systems (water) | 500–1000 ticks (5–10s) | | High-inertia / viscous | 1000–3000 ticks (10–30s) | | Critical no-interruption | 3000 ticks (30s) | ## Commissioning Steps 1. Run Pump A alone — confirm PUMP_A_RUN_FB received 2. Run Pump B alone — confirm PUMP_B_RUN_FB received 3. Test planned alternation (Mode 3) — verify overlap window; confirm no process interruption 4. Test failover: while A running, force PERM_A_OK = FALSE — confirm B starts within 2s 5. Test both-failed: force both permissives false — confirm critical alarm 6. Reset runtime hours to 0 before plant handover --- ## Control Logic — Vendor-Agnostic Pseudocode # Duty/Standby Pump Alternation — Logic ## Standards: IEC 61131-3 | ISA-5.1 | ISA-18.2 | API 610 ## Scan Rate: 10ms | Pattern: Duty/Standby with Auto-Failover ``` ROUTINE: DutyStandbyPumpAlternation SCAN_RATE: 10ms // ═══════════════════════════════════════════════════════════════ // SECTION 1 — RUNTIME TRACKING // Both pumps track individual hours for equalized wear (API 610). // Alternation criterion: difference exceeds EQUALIZE_THRESHOLD. // ═══════════════════════════════════════════════════════════════ // Accumulate runtime for each pump (10ms scan) IF PUMP_A_RUN_FB THEN PUMP_A_RUNTIME_TICKS := PUMP_A_RUNTIME_TICKS + 1 IF PUMP_A_RUNTIME_TICKS >= 360000 THEN PUMP_A_HOURS := PUMP_A_HOURS + 1.0 PUMP_A_RUNTIME_TICKS := 0 END_IF END_IF IF PUMP_B_RUN_FB THEN PUMP_B_RUNTIME_TICKS := PUMP_B_RUNTIME_TICKS + 1 IF PUMP_B_RUNTIME_TICKS >= 360000 THEN PUMP_B_HOURS := PUMP_B_HOURS + 1.0 PUMP_B_RUNTIME_TICKS := 0 END_IF END_IF // ═══════════════════════════════════════════════════════════════ // SECTION 2 — DUTY ASSIGNMENT LOGIC // Duty pump = the one with fewer runtime hours. // Reassignment only happens when both pumps are stopped (safe). // Never swap during operation — causes process disturbance. // ═══════════════════════════════════════════════════════════════ // Determine duty/standby assignment (only when both stopped) IF NOT PUMP_A_RUN_FB AND NOT PUMP_B_RUN_FB THEN IF PUMP_A_HOURS <= PUMP_B_HOURS THEN DUTY_PUMP := PUMP_A STANDBY_PUMP := PUMP_B ELSE DUTY_PUMP := PUMP_B STANDBY_PUMP := PUMP_A END_IF // Manual override: operator can force duty assignment IF FORCE_DUTY_OVERRIDE THEN DUTY_PUMP := FORCED_DUTY_SELECTION // 1=A, 2=B STANDBY_PUMP := 3 - FORCED_DUTY_SELECTION END_IF END_IF RUNTIME_DELTA := ABS(PUMP_A_HOURS - PUMP_B_HOURS) // ═══════════════════════════════════════════════════════════════ // SECTION 3 — PERMISSIVE EVALUATION (per pump) // Each pump has independent permissives. // A failed permissive removes that pump from duty candidacy. // ═══════════════════════════════════════════════════════════════ // Pump A permissives PERM_A_OK := (PERM_A_SUCTION_OK AND PERM_A_BEARING_OK AND PERM_A_OL_OK AND PERM_A_ESTOP_OK AND NOT PUMP_A_FAULT) // Pump B permissives PERM_B_OK := (PERM_B_SUCTION_OK AND PERM_B_BEARING_OK AND PERM_B_OL_OK AND PERM_B_ESTOP_OK AND NOT PUMP_B_FAULT) // If duty pump's permissives fail → re-assign standby as duty IF DUTY_PUMP = PUMP_A AND NOT PERM_A_OK AND PERM_B_OK THEN DUTY_PUMP := PUMP_B STANDBY_PUMP := PUMP_A SET_ALARM(ALM_DUTY_FAILOVER, HIGH) AUDIT_LOG(EVENT="DUTY_FAILOVER_TO_B", REASON="PERM_A_LOST") END_IF IF DUTY_PUMP = PUMP_B AND NOT PERM_B_OK AND PERM_A_OK THEN DUTY_PUMP := PUMP_A STANDBY_PUMP := PUMP_B SET_ALARM(ALM_DUTY_FAILOVER, HIGH) AUDIT_LOG(EVENT="DUTY_FAILOVER_TO_A", REASON="PERM_B_LOST") END_IF // Both failed → critical alarm, no pump available IF NOT PERM_A_OK AND NOT PERM_B_OK THEN SET_ALARM(ALM_BOTH_PUMPS_FAILED, CRITICAL) END_IF // ═══════════════════════════════════════════════════════════════ // SECTION 4 — START / STOP SEQUENCING // Duty pump starts first. Standby only starts on failover. // Soft handover: standby starts BEFORE duty stops (overlap). // Prevents process interruption during planned alternation. // ═══════════════════════════════════════════════════════════════ CASE SYSTEM_MODE OF 0: // SYSTEM OFF PUMP_A_CMD := FALSE PUMP_B_CMD := FALSE SEQ_STATE := SEQ_IDLE 1: // SYSTEM RUNNING — NORMAL OPERATION // Start duty pump IF SYSTEM_START AND NOT DUTY_RUNNING THEN IF DUTY_PUMP = PUMP_A AND PERM_A_OK THEN PUMP_A_CMD := TRUE AUDIT_LOG(EVENT="PUMP_A_START", ROLE="DUTY") ELSIF DUTY_PUMP = PUMP_B AND PERM_B_OK THEN PUMP_B_CMD := TRUE AUDIT_LOG(EVENT="PUMP_B_START", ROLE="DUTY") END_IF END_IF DUTY_RUNNING := (DUTY_PUMP = PUMP_A AND PUMP_A_RUN_FB) OR (DUTY_PUMP = PUMP_B AND PUMP_B_RUN_FB) 2: // FAILOVER — duty lost, start standby IF DUTY_PUMP = PUMP_A AND NOT PUMP_A_RUN_FB THEN // Duty A tripped; start standby B without stopping IF PERM_B_OK THEN PUMP_B_CMD := TRUE FAILOVER_TIMER := 0 AUDIT_LOG(EVENT="PUMP_B_FAILOVER_START") END_IF // Only de-energize A after B confirmed running (overlap window) IF PUMP_B_RUN_FB AND FAILOVER_TIMER >= FAILOVER_OVERLAP_TICKS THEN PUMP_A_CMD := FALSE SYSTEM_MODE := 1 DUTY_PUMP := PUMP_B STANDBY_PUMP := PUMP_A END_IF FAILOVER_TIMER := FAILOVER_TIMER + 1 END_IF IF DUTY_PUMP = PUMP_B AND NOT PUMP_B_RUN_FB THEN IF PERM_A_OK THEN PUMP_A_CMD := TRUE FAILOVER_TIMER := 0 AUDIT_LOG(EVENT="PUMP_A_FAILOVER_START") END_IF IF PUMP_A_RUN_FB AND FAILOVER_TIMER >= FAILOVER_OVERLAP_TICKS THEN PUMP_B_CMD := FALSE SYSTEM_MODE := 1 DUTY_PUMP := PUMP_A STANDBY_PUMP := PUMP_B END_IF FAILOVER_TIMER := FAILOVER_TIMER + 1 END_IF 3: // PLANNED ALTERNATION — operator-initiated or scheduled // Start standby first (pre-fill, warm-up) IF NOT ALTERNATION_IN_PROGRESS THEN IF STANDBY_PUMP = PUMP_A AND PERM_A_OK THEN PUMP_A_CMD := TRUE ALTERNATION_IN_PROGRESS := TRUE ALTERNATION_TIMER := 0 ELSIF STANDBY_PUMP = PUMP_B AND PERM_B_OK THEN PUMP_B_CMD := TRUE ALTERNATION_IN_PROGRESS := TRUE ALTERNATION_TIMER := 0 END_IF END_IF // Wait for standby to reach running speed; then stop old duty ALTERNATION_TIMER := ALTERNATION_TIMER + 1 IF ALTERNATION_TIMER >= HANDOVER_OVERLAP_TICKS THEN IF STANDBY_PUMP = PUMP_A AND PUMP_A_RUN_FB THEN PUMP_B_CMD := FALSE // Stop old duty (B) DUTY_PUMP := PUMP_A STANDBY_PUMP := PUMP_B ELSIF STANDBY_PUMP = PUMP_B AND PUMP_B_RUN_FB THEN PUMP_A_CMD := FALSE // Stop old duty (A) DUTY_PUMP := PUMP_B STANDBY_PUMP := PUMP_A END_IF ALTERNATION_IN_PROGRESS := FALSE ALTERNATION_TIMER := 0 SYSTEM_MODE := 1 AUDIT_LOG(EVENT="PLANNED_ALTERNATION_COMPLETE", NEW_DUTY=DUTY_PUMP) END_IF END_CASE // ═══════════════════════════════════════════════════════════════ // SECTION 5 — FAILOVER DETECTION // Duty pump loses run feedback → initiate failover sequence. // 2s confirmation prevents nuisance failover on brief transient. // ═══════════════════════════════════════════════════════════════ IF SYSTEM_MODE = 1 AND DUTY_RUNNING THEN DUTY_RUNNING_NOW := (DUTY_PUMP = PUMP_A AND PUMP_A_RUN_FB) OR (DUTY_PUMP = PUMP_B AND PUMP_B_RUN_FB) IF NOT DUTY_RUNNING_NOW THEN FAILOVER_CONFIRM_CTR := FAILOVER_CONFIRM_CTR + 1 IF FAILOVER_CONFIRM_CTR >= 200 THEN // 2s confirmation SYSTEM_MODE := 2 // Enter failover mode FAILOVER_CONFIRM_CTR := 0 SET_ALARM(ALM_DUTY_PUMP_LOST, CRITICAL) AUDIT_LOG(EVENT="DUTY_PUMP_LOST", PUMP=DUTY_PUMP) END_IF ELSE FAILOVER_CONFIRM_CTR := 0 END_IF END_IF // ═══════════════════════════════════════════════════════════════ // SECTION 6 — MAINTENANCE ALARMS & SCHEDULING // ═══════════════════════════════════════════════════════════════ IF PUMP_A_HOURS >= MAINTENANCE_INTERVAL_HOURS THEN SET_ALARM(ALM_PUMP_A_MAINT, LOW) END_IF IF PUMP_B_HOURS >= MAINTENANCE_INTERVAL_HOURS THEN SET_ALARM(ALM_PUMP_B_MAINT, LOW) END_IF // Runtime equalization reminder IF RUNTIME_DELTA > EQUALIZE_THRESHOLD THEN SET_ALARM(ALM_RUNTIME_UNBALANCED, LOW) END_IF // ═══════════════════════════════════════════════════════════════ // SECTION 7 — HMI OUTPUTS // ═══════════════════════════════════════════════════════════════ HMI_DUTY_PUMP := DUTY_PUMP HMI_PUMP_A_HOURS := PUMP_A_HOURS HMI_PUMP_B_HOURS := PUMP_B_HOURS HMI_RUNTIME_DELTA := RUNTIME_DELTA HMI_PUMP_A_RUNNING := PUMP_A_RUN_FB HMI_PUMP_B_RUNNING := PUMP_B_RUN_FB HMI_SYSTEM_MODE := SYSTEM_MODE HMI_PERM_A_OK := PERM_A_OK HMI_PERM_B_OK := PERM_B_OK HMI_ALTERNATION_ACTIVE := ALTERNATION_IN_PROGRESS HMI_FAILOVER_ACTIVE := (SYSTEM_MODE = 2) END_ROUTINE ``` --- ## Tag List ```csv Tag Name,Description,Data Type,Direction,Engineering Unit,Range Min,Range Max,Default Value,Address PUMP_A_CMD,Pump A Start Command Output,BOOL,output,,,,FALSE,DO:1:0.0 PUMP_B_CMD,Pump B Start Command Output,BOOL,output,,,,FALSE,DO:1:0.1 PUMP_A_RUN_FB,Pump A Running Feedback (Contactor Aux),BOOL,input,,,,FALSE,DI:0:0.0 PUMP_B_RUN_FB,Pump B Running Feedback (Contactor Aux),BOOL,input,,,,FALSE,DI:0:0.1 PUMP_A_HOURS,Pump A Accumulated Runtime Hours,REAL,internal,h,0,99999,0, PUMP_B_HOURS,Pump B Accumulated Runtime Hours,REAL,internal,h,0,99999,0, PUMP_A_RUNTIME_TICKS,Pump A Runtime Tick Accumulator (10ms),INT,internal,,0,360000,0, PUMP_B_RUNTIME_TICKS,Pump B Runtime Tick Accumulator (10ms),INT,internal,,0,360000,0, RUNTIME_DELTA,Absolute Runtime Difference Between Pumps,REAL,calculated,h,0,99999,0, DUTY_PUMP,Currently Assigned Duty Pump (1=A 2=B),INT,internal,,1,2,1, STANDBY_PUMP,Currently Assigned Standby Pump (1=A 2=B),INT,internal,,1,2,2, DUTY_RUNNING,Duty Pump Currently Running,BOOL,calculated,,,,FALSE, DUTY_RUNNING_NOW,Instantaneous Duty Running State,BOOL,calculated,,,,FALSE, SYSTEM_MODE,System Mode (0=OFF 1=RUN 2=FAILOVER 3=ALTERNATE),INT,input,,0,3,0, SYSTEM_START,System Start Command,BOOL,input,,,,FALSE, PERM_A_OK,Pump A All Permissives Satisfied,BOOL,calculated,,,,FALSE, PERM_B_OK,Pump B All Permissives Satisfied,BOOL,calculated,,,,FALSE, PERM_A_SUCTION_OK,Pump A Suction Pressure Permissive,BOOL,input,,,,TRUE,DI:0:0.2 PERM_A_BEARING_OK,Pump A Bearing Temperature Permissive,BOOL,input,,,,TRUE,DI:0:0.3 PERM_A_OL_OK,Pump A Thermal Overload Permissive (NC),BOOL,input,,,,TRUE,DI:0:0.4 PERM_A_ESTOP_OK,Pump A E-Stop Circuit Permissive (NC),BOOL,input,,,,TRUE,DI:0:0.5 PERM_B_SUCTION_OK,Pump B Suction Pressure Permissive,BOOL,input,,,,TRUE,DI:0:0.6 PERM_B_BEARING_OK,Pump B Bearing Temperature Permissive,BOOL,input,,,,TRUE,DI:0:0.7 PERM_B_OL_OK,Pump B Thermal Overload Permissive (NC),BOOL,input,,,,TRUE,DI:0:0.8 PERM_B_ESTOP_OK,Pump B E-Stop Circuit Permissive (NC),BOOL,input,,,,TRUE,DI:0:0.9 PUMP_A_FAULT,Pump A Latched Fault Active,BOOL,internal,,,,FALSE, PUMP_B_FAULT,Pump B Latched Fault Active,BOOL,internal,,,,FALSE, FORCE_DUTY_OVERRIDE,Force Manual Duty Assignment Active,BOOL,input,,,,FALSE, FORCED_DUTY_SELECTION,Forced Duty Pump Selection (1=A 2=B),INT,input,,1,2,1, FAILOVER_CONFIRM_CTR,Failover Confirmation Debounce Counter,INT,internal,,0,500,0, FAILOVER_TIMER,Failover Overlap Timer (10ms ticks),INT,internal,,0,5000,0, FAILOVER_OVERLAP_TICKS,Failover Overlap Duration Setting,INT,internal,,100,3000,500, ALTERNATION_IN_PROGRESS,Planned Alternation Currently Active,BOOL,internal,,,,FALSE, ALTERNATION_TIMER,Alternation Handover Timer (10ms ticks),INT,internal,,0,5000,0, HANDOVER_OVERLAP_TICKS,Handover Overlap Duration Setting,INT,internal,,200,3000,1000, MAINTENANCE_INTERVAL_HOURS,Preventive Maintenance Interval,REAL,internal,h,1000,50000,4000, EQUALIZE_THRESHOLD,Runtime Imbalance Alert Threshold,REAL,internal,h,0,1000,200, SEQ_STATE,Internal Sequencer State,INT,internal,,0,10,0, ALM_DUTY_PUMP_LOST,Duty Pump Lost — Failover Initiated,BOOL,calculated,,,,FALSE, ALM_DUTY_FAILOVER,Duty Re-Assignment Active,BOOL,calculated,,,,FALSE, ALM_BOTH_PUMPS_FAILED,Both Pumps Unavailable — Critical,BOOL,calculated,,,,FALSE, ALM_PUMP_A_MAINT,Pump A Maintenance Due,BOOL,calculated,,,,FALSE, ALM_PUMP_B_MAINT,Pump B Maintenance Due,BOOL,calculated,,,,FALSE, ALM_RUNTIME_UNBALANCED,Runtime Hours Imbalanced — Alternation Suggested,BOOL,calculated,,,,FALSE, HMI_DUTY_PUMP,HMI: Current Duty Pump Display,INT,output,,1,2,1, HMI_PUMP_A_HOURS,HMI: Pump A Runtime Hours,REAL,output,h,0,99999,0, HMI_PUMP_B_HOURS,HMI: Pump B Runtime Hours,REAL,output,h,0,99999,0, HMI_RUNTIME_DELTA,HMI: Runtime Hour Difference,REAL,output,h,0,99999,0, HMI_PUMP_A_RUNNING,HMI: Pump A Running State,BOOL,output,,,,FALSE, HMI_PUMP_B_RUNNING,HMI: Pump B Running State,BOOL,output,,,,FALSE, HMI_SYSTEM_MODE,HMI: System Mode Display,INT,output,,0,3,0, HMI_PERM_A_OK,HMI: Pump A Permissives State,BOOL,output,,,,FALSE, HMI_PERM_B_OK,HMI: Pump B Permissives State,BOOL,output,,,,FALSE, HMI_ALTERNATION_ACTIVE,HMI: Alternation In Progress,BOOL,output,,,,FALSE, HMI_FAILOVER_ACTIVE,HMI: Failover Active Flag,BOOL,output,,,,FALSE, ``` --- ## Alarm Matrix ```csv Alarm Tag,Condition,Setpoint,Priority,Type,Response,Delay,Auto Acknowledge ALM_BOTH_PUMPS_FAILED,NOT PERM_A_OK AND NOT PERM_B_OK,N/A,critical,safety,No pump available. Manual intervention required immediately. Check both pump faults and permissive conditions.,0s,No ALM_DUTY_PUMP_LOST,Duty pump RUN_FB lost for >2s,2s,critical,equipment,Failover initiated to standby pump. Investigate duty pump trip. Check MCC and fault log.,0s,No ALM_DUTY_FAILOVER,Automatic duty re-assignment occurred,N/A,high,equipment,A permissive loss on the duty pump triggered failover. Restore duty pump before next shutdown.,0s,No ALM_RUNTIME_UNBALANCED,ABS(PUMP_A_HOURS - PUMP_B_HOURS) > 200h,200h,low,diagnostic,Runtime hours differ significantly. Schedule planned alternation at next opportunity.,0s,Yes ALM_PUMP_A_MAINT,PUMP_A_HOURS >= MAINTENANCE_INTERVAL_HOURS,4000h,low,diagnostic,Pump A due for preventive maintenance. Schedule during planned outage.,0s,Yes ALM_PUMP_B_MAINT,PUMP_B_HOURS >= MAINTENANCE_INTERVAL_HOURS,4000h,low,diagnostic,Pump B due for preventive maintenance. Schedule during planned outage.,0s,Yes ```

More like this

Rate, comment, and get full access

Members can download files, rate contributions, and discuss fixes with the engineers who posted them — free.

Join the library