Alternating pump control (duty / standby)
Two pumps empty a tank, and each time the high level switch triggers they take turns: A, B, A, B. A short exercise that teaches three building blocks at once: the one-shot, the toggle bit and the seal-in.
Loads the panel and the ladder program from the video. Press RUN PLC and try it.
The task
A water tank is emptied by two pumps, PUMP A and PUMP B. Each time the HIGH level switch triggers, one pump runs until the level falls below the LOW switch. The pumps must alternate: the first time pump A, the second time pump B, then A again, and so on. Alternating (duty / standby) spreads the wear evenly and proves regularly that the standby pump still works.
Inputs and outputs
| Address | Signal |
|---|---|
I0.0 | LOW level switch (on while the water is above 20 %) |
I0.1 | HIGH level switch (on while the water is above 80 %) |
Q0.0 | PUMP A |
Q0.1 | PUMP B |
Q0.2 | tank outlet valve, open while pumping |
M0.0 | toggle bit: which pump is next |
M0.1 | one-shot pulse from HIGH |
M0.2 | pumping (sealed in) |
In the Playground an INFLOW selector switch is wired straight to the fill valve of the tank, so you can let water in whenever you like.
Thinking it through
- One-shot. A rising-edge contact on HIGH gives a pulse that lasts exactly one scan each time the level reaches HIGH.
- Toggle. On every pulse the bit M0.0 changes state. In ladder this is an exclusive OR: (pulse AND NOT M0.0) OR (NOT pulse AND M0.0) drives M0.0.
- Pumping. HIGH starts pumping, a seal-in keeps it going, and LOW (which goes off below 20 %) stops it. While pumping, M0.0 chooses the pump.
The one-shot is the key. Without it the toggle would flip on every scan while the level is above HIGH, a few hundred times a second, and the pumps would chatter.
The ladder program
| Rung | Contacts | Output | What it does |
|---|---|---|---|
| 1 | P I0.1 (rising edge) | M0.1 | one pulse per HIGH trigger |
| 2 | (M0.1 AND NOT M0.0) OR (NOT M0.1 AND M0.0) | M0.0 | toggle |
| 3 | (I0.1 OR M0.2) AND I0.0 | M0.2 | pumping, seal-in until LOW |
| 4 | M0.2 AND M0.0 | Q0.0 | PUMP A |
| 5 | M0.2 AND NOT M0.0 | Q0.1 | PUMP B |
| 6 | M0.2 | Q0.2 | outlet valve |
Test it
- RUN, open the monitor and switch INFLOW on. The tank fills.
- At HIGH the pulse fires, M0.0 turns on and PUMP A runs. Switch INFLOW off: the pump empties the tank and stops at LOW.
- INFLOW on again: at HIGH, M0.0 turns off and PUMP B runs. Next time PUMP A again.
Common mistakes
- Toggling on the HIGH level instead of its edge: the pumps chatter.
- Toggle written after the pump rungs: it still works, but the selection then changes one scan later than you expect, which matters when you add more logic.
- No seal-in: the pump stops as soon as the level drops below HIGH, a few centimetres later.
What happens if the HIGH float itself gets stuck? That is the follow-up fault-finding exercise: the stuck Lead float.
Try it yourself
Build it from scratch in the free PLC Sim Lab Playground, or open the finished solution and change it:
Loads the panel and the ladder program from the video. Press RUN PLC and try it.
Frequently asked questions
What is a toggle (flip-flop) bit in ladder logic?
A bit that changes state on every pulse. Without a dedicated instruction it is written as an exclusive OR of the pulse and the bit itself, and it must be fed by a one-shot, otherwise it changes on every scan.
Why alternate duty and standby pumps?
So both pumps wear evenly, and so the standby pump is run regularly: a pump that stands still for months may not start when it is finally needed.
More: all PLC exercises · free PLC course with certificate · PLC timers and counters · ladder logic basics