Programming Cyclic Pump Rotation on S7-200 CPU 224 XP

David Krause16 min read
S7-200SiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Programming Cyclic Pump Rotation on a Siemens S7-200 CPU 224 XP

This reference designs and programs a four-pump pressure-boosting station using a SIMATIC S7-200 CPU 224 XP (order number 6ES7 214-1HG40-0XB0) and an EM231 analog input module (6ES7 231-4HD32-0XB0). Pump 1 acts as the primary (jockey) pump between 2.75 bar and 4.0 bar. Pumps 2, 3, and 4 are auxiliary pumps that run two at a time between 2.0 bar and 4.6 bar, rotating selection to balance running hours, and automatically falling back when any pump is in trip state.

All ladder logic shown is targeted at STEP 7 Micro/WIN V4.0 SP9 and follows the conventions in the SIMATIC S7-200 Programmable Controller System Manual (Siemens Support entry 1109582) and the STEP 7 Micro/WIN V4.0 Programming Reference (Siemens Support entry 18849126).

System Overview and Control Objectives

The pumping station must satisfy four independent but interlocking control rules:

  1. Maintain system pressure using Pump 1 alone when demand is light, switching ON at 2.75 bar and OFF at 4.0 bar.
  2. When pressure falls to 2.0 bar with Pump 1 already running at full output, start two of the three auxiliary pumps (Pumps 2, 3, 4).
  3. Stop the running pair when system pressure reaches 4.6 bar. The next low-pressure event must select a different pair of auxiliary pumps to equalize wear.
  4. If any auxiliary pump is in trip (motor overload, breaker open, drive fault), exclude it from the selection and force the remaining two healthy pumps to run until the tripped unit is restored.

The pairing of three pumps taken two at a time gives three possible combinations: (2,3), (3,4), and (2,4). Cyclic rotation through these three pairs with a cooldown interval between cycles is the simplest field-proven equalization strategy for small pump stations. A larger plant typically uses a least-hours-start-first strategy; the same ladder scaffold applies, with the comparator block replaced by a sort of running-hour registers.

Hardware Selection and DIP Switch Settings

The CPU 224 XP (6ES7 214-1HG40-0XB0) provides 14 digital inputs, 10 digital outputs, two onboard 12-bit analog inputs (0-10 V only) and one onboard analog output. Because the pressure transmitter is a 4-20 mA device, an EM231 module is required.

Module Order Number Function
S7-200 CPU 224 XP DC/DC/DC 6ES7 214-1HG40-0XB0 CPU, 14 DI / 10 DO, 20 KB program memory, 24 V DC supply
EM231 Analog Input 6ES7 231-4HD32-0XB0 4 AI, 12-bit resolution, configurable voltage or current ranges via DIP switches

EM231 4HD32 DIP Switch Configuration

Each EM231 4HD32 has two DIP switch banks of three switches each. Bank A (SW1-SW3) sets the range for channels 0 and 1; Bank B (SW4-SW6) sets the range for channels 2 and 3. Always power-cycle the module after changing DIP switches.

Range SW1/SW4 SW2/SW5 SW3/SW6 Resolution
0 to 10 V OFF OFF OFF 2.5 mV
0 to 5 V ON OFF OFF 1.25 mV
0 to 1 V OFF ON OFF 250 µV
±10 V OFF OFF ON 2.5 mV
±5 V ON OFF ON 1.25 mV
±2.5 V OFF ON ON 1.25 mV
0 to 20 mA ON ON OFF 5 µA
±20 mA ON ON ON 5 µA

For a 4-20 mA pressure transmitter, set Bank A to ON, ON, OFF (0-20 mA hardware range). The 4 mA zero offset is subtracted in software. Apply this to channels 0 and 1 if redundant transmitters are wired; otherwise only SW1-SW3 are set.

Sensor Wiring and Scaling

Wire the two-wire pressure transmitter to EM231 channel 0 as follows: transmitter positive terminal to the CPU 24 V DC sensor supply (L+ terminal on the EM231 or the CPU sensor supply), transmitter negative terminal to EM231 terminal I+ (channel 0), and short I- to M on the EM231. The CPU 224 XP sensor supply can deliver up to 280 mA at 24 V DC for the entire station, per the S7-200 system manual chapter on sensor supply.

Raw Count to Bar Conversion

The EM231 returns integer counts in the range 0 to 32000 for a 0-20 mA input:

  • 4 mA = 6400 counts = 0 bar
  • 20 mA = 32000 counts = 10 bar (transmitter full scale)
  • Resolution: 1 count = (10 - 0) bar / (32000 - 6400) counts = 0.00390625 bar/count

Inline scaling formula: P_bar = (AIW0 - 6400) / 2560

Equivalent in real-number form for ladder use: P_bar = (AIW0 - 6400) × 0.000390625

I/O Allocation Table

Address Type Function Notes
AIW0 Input (Word) Pressure transmitter, EM231 channel 0 4-20 mA mapped to 0-10 bar
I0.0 Input Pump 1 running feedback Auxiliary contact of contactor
I0.1 Input Pump 2 running feedback —
I0.2 Input Pump 3 running feedback —
I0.3 Input Pump 4 running feedback —
I0.4 Input Pump 1 trip (overload / breaker) NC contact, inverted in PLC
I0.5 Input Pump 2 trip NC contact, inverted in PLC
I0.6 Input Pump 3 trip NC contact, inverted in PLC
I0.7 Input Pump 4 trip NC contact, inverted in PLC
I1.0 Input Auto / Manual selector 0 = Auto, 1 = Manual
I1.1 Input System enable (E-Stop OK) Closed = enabled
Q0.0 Output Pump 1 starter coil Through contactor
Q0.1 Output Pump 2 starter coil —
Q0.2 Output Pump 3 starter coil —
Q0.3 Output Pump 4 starter coil —
Q0.4 Output Common fault lamp —

Variable Memory Map

Address Type Function
VD100 REAL Scaled pressure in bar (0.0 - 10.0)
VB200 BYTE Auxiliary state machine state (0-4)
VB201 BYTE Pair rotation counter (0, 1, 2 cycles 3 pairs)
VB202 BYTE Cooldown timer preset (seconds)
M0.0 BOOL Pump 1 run latch
M0.1 BOOL Auxiliary pair demand (pressure < 2.0 bar)
M0.2 BOOL Auxiliary pair stop (pressure > 4.6 bar)
M0.3 BOOL Trip detected on Pump 2
M0.4 BOOL Trip detected on Pump 3
M0.5 BOOL Trip detected on Pump 4
VD300 DINT Pump 2 running time accumulator (seconds)
VD304 DINT Pump 3 running time accumulator (seconds)
VD308 DINT Pump 4 running time accumulator (seconds)

State Machine for Auxiliary Pumps

The auxiliary pump control is a finite state machine with five states. The state variable is VB200 and the transition rules are evaluated every scan.

S0 IdleAll aux off S1 Pair A runPumps 2 + 3 S2 Cooldown A5 s, all off S3 Pair B runPumps 3 + 4 S4 Cooldown B5 s, all off S5 Pair C runPumps 2 + 4 P < 2.0 bar P >= 4.6 bar 5 s elapsed P >= 4.6 bar 5 s elapsed P >= 4.6 bar P < 2.0 bar Trip override: if a pump in the running pair is in trip, replace it with the healthy third pump.

Ladder Logic Implementation

Network 1 — Read Raw AIW and Convert to Real

|       SM0.0          MOVW   AIW0,    VW100
|       SM0.0          ITD    VW100,   VD102
|       SM0.0          DTR    VD102,   VD106   // VD106 = AIW0 as REAL

Network 2 — Apply 4 mA Offset and Scale to Bar

|       SM0.0          MOVR   6400.0,  VD110
|       SM0.0          -R     VD106,   VD110   // VD110 = AIW0 - 6400
|       SM0.0          MOVR   0.000390625, VD114
|       SM0.0          *R     VD114,   VD110   // VD110 = pressure in bar

Network 3 — Threshold Comparators with Hysteresis

|       VD110 >= 2.75                  M0.0     // Pump 1 demand (set)
|       M0.0   AND  VD110 < 4.0        (continue latch)
|       M0.0                              Q0.0   // Pump 1 starter

|       VD110 < 2.0                    M0.1     // Aux pair demand
|       VD110 >= 4.6                   M0.2     // Aux pair stop

Network 4 — Trip Status with NC Inversion

|       AN    I0.5         =     M0.3   // Pump 2 trip (NC input)
|       AN    I0.6         =     M0.4   // Pump 3 trip (NC input)
|       AN    I0.7         =     M0.5   // Pump 4 trip (NC input)
|       O     M0.3
|       O     M0.4
|       O     M0.5                =     Q0.4   // Common fault lamp

Network 5 — Pair Selection by Rotation Counter

The pair-rotation counter VB201 cycles through 0, 1, 2 on each high-pressure stop. Use a comparator block to decode the counter to discrete pair select bits.

|       VB201 = 0          =     M10.0   // Select pair A: Pumps 2 and 3
|       VB201 = 1          =     M10.1   // Select pair B: Pumps 3 and 4
|       VB201 = 2          =     M10.2   // Select pair C: Pumps 2 and 4

Network 6 — Trip Override Resolves Pump Selection

|       M10.0 AND NOT M0.3 AND NOT M0.4   =  M11.0   // Pair A healthy
|       M10.1 AND NOT M0.4 AND NOT M0.5   =  M11.1   // Pair B healthy
|       M10.2 AND NOT M0.3 AND NOT M0.5   =  M11.2   // Pair C healthy

// If the selected pair contains a tripped pump, fall back to the next healthy pair
|       M11.0                              =  M12.0
|       M11.1                              =  M12.1
|       M11.2                              =  M12.2

// Trip-fallback: if Pump 2 is tripped, force the system to run Pumps 3 and 4 (the only healthy pair)
|       M0.3   AND  NOT M0.4  AND  NOT M0.5   =  M12.1   // Force pair B
|       M0.4   AND  NOT M0.3  AND  NOT M0.5   =  M12.0   // Force pair A (Pumps 2 and 4)
|       M0.5   AND  NOT M0.3  AND  NOT M0.4   =  M12.0   // Force pair A (Pumps 2 and 3)

Network 7 — State Machine Logic

// Transition S0 -> S1 (start pair A on low pressure)
|       VB200 = 0  AND  M0.1  AND  M12.0  MOVB  1,  VB200

// Transition S1 -> S2 (high pressure reached)
|       VB200 = 1  AND  M0.2                MOVB  2,  VB200

// Increment rotation counter on entering S2
|       VB200 = 1  AND  M0.2                INCB  VB201
|                                  WRB    VB201, VB201  // keep in 0..2
|       VB201 > 2                          MOVB  0,  VB201

// S2 -> S3 after 5 s
|       VB200 = 2  AND  T37                MOVB  3,  VB200

// S3 -> S4 on high pressure
|       VB200 = 3  AND  M0.2                MOVB  4,  VB200

// S4 -> S0 after 5 s (or -> S1 on demand with low pressure)
|       VB200 = 4  AND  T38                MOVB  0,  VB200
|       VB200 = 4  AND  M0.1                MOVB  1,  VB200

Network 8 — Cooldown Timer

|       VB200 = 2  TON  T37, +50         // 5.0 s at 100 ms time base
|       VB200 = 4  TON  T38, +50

Network 9 — Pump Output Drive

|       (VB200 = 1  AND  M12.0)
|       (VB200 = 1  AND  M12.1)
|       (VB200 = 3  AND  M12.1)
|       (VB200 = 3  AND  M12.2)
|       (VB200 = 0  AND  M0.1  AND  (M12.0 OR M12.1 OR M12.2))
|  =    Q0.1    // Pump 2

|       (VB200 = 1  AND  M12.0)
|       (VB200 = 1  AND  M12.1)
|       (VB200 = 3  AND  M12.1)
|       (VB200 = 3  AND  M12.2)
|       (VB200 = 0  AND  M0.1  AND  (M12.0 OR M12.1 OR M12.2))
|  =    Q0.2    // Pump 3

|       (VB200 = 3  AND  M12.1)
|       (VB200 = 3  AND  M12.2)
|       (VB200 = 4  AND  M0.1  AND  (M12.1 OR M12.2))
|  =    Q0.3    // Pump 4

Network 10 — Minimum Run and Minimum Off Time (Anti-Cycle)

To prevent rapid cycling and contactor wear, latch each auxiliary output for a minimum of 30 seconds on time and 30 seconds off time.

|       Q0.1  OR  (M0.1  AND  VB200 = 1  AND  M12.0)  TON  T101, +300
|       T101  S    M30.1                                 // Pump 2 minimum run
|       M30.1 = Q0.1

|       NOT Q0.1  TON  T102, +300
|       T102     R    M30.1

Repeat the same ladder block for Pumps 3 and 4 with timers T103, T104 and T105, T106, and latches M30.2, M30.3, M30.4.

Running Hours Tracking

Use the 1-minute clock bit SM0.4 to accumulate running time. The S7-200 system manual documents SM0.4 as a 1-minute clock with 50% duty cycle. Each rising edge of SM0.4 therefore represents 30 seconds of operation; doubling the count or storing directly in minutes is acceptable.

|       SM0.4
|       EU                  // Detect rising edge once per minute
|       A     Q0.1          INCD  VD300    // Pump 2 minutes
|       A     Q0.2          INCD  VD304    // Pump 3 minutes
|       A     Q0.3          INCD  VD308    // Pump 4 minutes

To display running hours, divide each accumulator by 60. In the HMI or SCADA tag, expose VD300 / 60, VD304 / 60, and VD308 / 60 as integer hours. Retain values in the permanent memory area (VB14 to VB31, controlled by SMB31 and SMB32) so the counters survive power loss.

Trip and Fault Handling

The trip-fallback logic in Network 6 guarantees that a single tripped auxiliary pump does not stall the system. If two auxiliary pumps are tripped simultaneously, the system cannot meet the design pressure band. The PLC must raise the common fault lamp and write a distinct fault code to memory for the HMI:

Fault Code Condition Action
0 No fault —
1 One auxiliary pump tripped Fallback to remaining two healthy pumps
2 Two auxiliary pumps tripped Latch fault, run Pump 1 only, raise alarm, force common fault lamp
3 All three auxiliary pumps tripped Stop all pumps except Pump 1, raise critical alarm, disable auto-restart
10 Pressure transmitter open loop (AIW0 < 6000) Hold last valid pressure, raise sensor fault
11 Pressure transmitter over-range (AIW0 > 32500) Clamp to 10 bar, raise sensor fault

Trip Auto-Reset Logic

Once the operator clears the trip condition at the motor protection breaker, the PLC should immediately accept the restored pump. Implement this with a positive edge on the trip input:

|       AN    I0.5  EU    M40.1    // Pump 2 trip clears
|       M40.1                R     M0.3

|       AN    I0.6  EU    M40.2    // Pump 3 trip clears
|       M40.2                R     M0.4

|       AN    I0.7  EU    M40.3    // Pump 4 trip clears
|       M40.3                R     M0.5

Commissioning Procedure

  1. Power the S7-200 station with all motor starters disconnected. Verify the CPU enters RUN mode and the SF/DIAG LED is OFF.
  2. Open STEP 7 Micro/WIN V4.0 SP9, go online, and confirm the EM231 is recognized in the system block.
  3. Force AIW0 to 6400 with the transmitter disconnected. Verify VD110 reads 0.0 bar (within ±0.01 bar).
  4. Apply a 4 mA calibration signal. Verify VD110 reads 0.0 bar.
  5. Apply a 12 mA signal. Verify VD110 reads 5.0 bar ±0.02 bar.
  6. Apply a 20 mA signal. Verify VD110 reads 10.0 bar ±0.02 bar.
  7. Force Q0.0 in the status chart. Verify Pump 1 contactor pulls in. Reset.
  8. Force Q0.1, Q0.2, Q0.3 in turn. Verify each pump contactor pulls in. Reset.
  9. Force M0.1 (aux pair demand). Verify the state machine transitions S0 → S1 and the correct pair drives the outputs.
  10. Force M0.2 (aux pair stop). Verify the state machine transitions to the cooldown state, then the next pair.
  11. Simulate a trip on Pump 2 by opening I0.5. Verify that Pumps 3 and 4 run continuously and the fault lamp Q0.4 turns ON.
  12. Restore I0.5. Verify the state machine returns to normal rotation on the next demand cycle.
  13. Disconnect the pressure transmitter. Verify the PLC holds the last valid pressure and raises the sensor fault code.

Verification Checks

Test Acceptance Criterion
Pump 1 turn-on pressure 2.70 - 2.80 bar
Pump 1 turn-off pressure 3.95 - 4.05 bar
Auxiliary turn-on pressure 1.95 - 2.05 bar
Auxiliary turn-off pressure 4.55 - 4.65 bar
Pair rotation Sequential: (2,3) → (3,4) → (2,4) → repeat
Cooldown duration 5.0 s ±0.5 s
Minimum run time 30 s ±1 s
Single-trip response Within 1 s of trip input, healthy pair runs
Running-hour resolution 1 minute increments

Troubleshooting Matrix

Symptom Likely Cause Diagnostic Step Corrective Action
All pumps run continuously Pressure transmitter open, AIW0 = 0 Monitor AIW0 in status chart Check loop wiring, replace transmitter
Pump 1 chatters Pressure band too narrow or transmitter noise Read VD110 with trend; check electrical noise Increase hysteresis to 2.65-4.10, add 0-5 s input filter
No pumps start System enable input open or all aux tripped Check I1.1 and M0.3-M0.5 Restore enable, clear trips
Aux pair never rotates VB201 not incrementing Watch VB201 in status chart during high pressure Verify M0.2 is asserted when VD110 ≥ 4.6
Same two pumps always run Trip input stuck on third pump Force I0.5-I0.7 and watch M0.3-M0.5 Reset overload device; check wiring polarity of NC contact
VD110 reads 0.0 bar at known pressure EM231 DIP switches in voltage mode Power down, inspect SW1-SW3 Set SW1=ON, SW2=ON, SW3=OFF
VD110 reads -0.5 bar at 0 bar Wrong 4 mA zero offset Check raw AIW0 at 4 mA Re-trim transmitter or adjust offset constant
SF LED ON after power-up EM231 not detected Check expansion bus connection Reseat module; verify unique I/O addressing

Edge Cases and Field-Proven Caveats

  • Water hammer: never stop two pumps simultaneously on the same high-pressure event. The 5-second cooldown staggers the stop and prevents surge. For long pipe runs, increase the cooldown to 10-15 s.
  • Sensor drift: the 4 mA zero of industrial pressure transmitters drifts with temperature. Schedule a six-monthly two-point calibration against a dead-weight tester, and adjust the 6400 offset constant in VD110 if the zero error exceeds ±0.05 bar.
  • Power-on reset: the S7-200 retains the V memory only if the retentive range is configured in the system block. The default VB0-VB1023 is volatile. Mark VD300, VD304, and VD308 as retentive in the System Block > Retentive Ranges dialog.
  • Scan time impact: the floating-point math in Network 2 takes roughly 12 µs per scan on a CPU 224 XP. With a typical scan of 5 ms, this is negligible. Do not place the scaling math inside a high-speed counter or interrupt routine.
  • EMI on the 4-20 mA loop: route the analog cable in a separate conduit at least 200 mm from VFD output cables. If the transmitter is more than 50 m from the PLC, install a 250 Ω resistor at the PLC terminal and convert to 1-5 V (DIP set to 0-5 V, scale formula becomes P = (AIW0 - 640) / 2560).
  • Multiple transmitters: the EM231 4HD32 has only 4 channels. If redundancy is required, install a second EM231 and use the higher of the two pressures in the control logic.

Frequently Asked Questions

What is the exact scaling formula to convert 4-20 mA from the EM231 4HD32 to bar?

With DIP switches set to 0-20 mA range, the raw AIW0 count is 6400 at 4 mA and 32000 at 20 mA. The formula is P_bar = (AIW0 - 6400) / 2560. For a 0-10 bar transmitter, 1 count equals 0.00390625 bar.

How does the PLC detect a tripped pump and continue operation?

Wire the motor protection breaker or overload relay auxiliary as a normally-closed contact to inputs I0.5, I0.6, and I0.7. The PLC inverts the input and latches it as a trip flag (M0.3-M0.5). The pair selection logic in Network 6 excludes any flagged pump and falls back to the next healthy pair automatically.

Why does Pump 1 use a 2.75 to 4.0 bar band while the auxiliary pair uses 2.0 to 4.6 bar?

Pump 1 is the jockey pump that handles normal leakage and small demand. Its tight band keeps system pressure stable without frequent starts. The auxiliary pair only activates under sustained high demand at 2.0 bar, and the 4.6 bar stop provides enough margin to prevent short cycling of the larger pumps.

Can the logic be expanded to choose the auxiliary pair by least running hours instead of a fixed rotation?

Yes. Replace the rotation counter logic in Network 5 with three compare blocks (LDW>=) that evaluate VD300, VD304, and VD308. The pair with the smallest combined accumulator of its two pumps is started. The rest of the ladder remains unchanged.

What should I do if AIW0 reads 0 or 32767 unexpectedly?

A reading near 0 means the loop is open (broken wire, missing 24 V supply, or transmitter failure). A reading at 32767 means the input is over-range, usually from a wiring fault such as reversed polarity on a powered transmitter. Hold the last good pressure, raise fault code 10 or 11, and stop all pumps after a configurable timeout to protect the system.

Back to blog