PLC Sim Lab
Intermediate exercise · one-shot, toggle bit, seal-in

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.

Worked solution with video · Updated 2026-10-02

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

AddressSignal
I0.0LOW level switch (on while the water is above 20 %)
I0.1HIGH level switch (on while the water is above 80 %)
Q0.0PUMP A
Q0.1PUMP B
Q0.2tank outlet valve, open while pumping
M0.0toggle bit: which pump is next
M0.1one-shot pulse from HIGH
M0.2pumping (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

  1. One-shot. A rising-edge contact on HIGH gives a pulse that lasts exactly one scan each time the level reaches HIGH.
  2. 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.
  3. 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

RungContactsOutputWhat it does
1P I0.1 (rising edge)M0.1one pulse per HIGH trigger
2(M0.1 AND NOT M0.0) OR (NOT M0.1 AND M0.0)M0.0toggle
3(I0.1 OR M0.2) AND I0.0M0.2pumping, seal-in until LOW
4M0.2 AND M0.0Q0.0PUMP A
5M0.2 AND NOT M0.0Q0.1PUMP B
6M0.2Q0.2outlet valve
The video: watch on YouTube

Test it

  1. RUN, open the monitor and switch INFLOW on. The tank fills.
  2. 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.
  3. INFLOW on again: at HIGH, M0.0 turns off and PUMP B runs. Next time PUMP A again.

Common mistakes

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