How-to
Write alternating lead lag pump logic in RSLogix Micro
Short answer
Build the sequence as two layers: internal bits select the lead and time the assist, then one final rung per pump drives each physical output. Toggle B3:0/1 with a word-level XOR behind an OSR so it flips once per level cycle, and time the 30-second assist with one TON on the level input.
On this page
- How do you lay out alternating pump logic before writing rungs?
- Why does the pump turn on in one rung and off in the next?
- How do you flip the lead bit when the XOR rejects a bit address?
- Why does the lead selection change on every scan the level switch is closed?
- How do you time the 30-second assist delay?
- What order do the rungs go in?
- How do you force the level switch to test the alternation?
- How do you turn one pump off and still empty the tank?
- Questions asked
Build it as two layers. A selection layer of internal bits and one timer decides which pump leads and when the second pump joins; an output layer of one rung per physical pump turns that decision into O:0/0 and O:0/1. The lead alternation is a single bit, B3:0/1, flipped once per level cycle by a word-level XOR behind an OSR one-shot, and the 30-second assist delay is a TON timed from the level input. The two-layer split is not style: with a rung turning an output on and a later rung turning it off, the last rung always wins the scan, and the alternation never reaches the terminals.
How do you lay out alternating pump logic before writing rungs? #
Lay it out as two layers: a selection layer of internal B3 bits and one TON that decides who leads and when the assist joins, then an output layer with exactly one rung per physical pump, O:0/0 and O:0/1. Internal bits carry every decision, and the physical outputs only copy the final command.
The sequence this has to produce:
| Level cycle | Lead pump | Assist pump | Stop condition |
|---|---|---|---|
| First closing of I:0/0 | Pump 1, at once | Pump 2, 30 s later | I:0/0 opens |
| Next closing, roles swapped | Pump 2, at once | Pump 1, 30 s later | I:0/0 opens |
This example assigns the addresses below. Move them to your own I/O and spare bits, and give every one a symbol and a rung comment as you place it.
| Address | Role in this example |
|---|---|
| I:0/0 | Level switch input |
| O:0/0 | Pump 1 physical output |
| O:0/1 | Pump 2 physical output |
| B3:0/0 | OSR one-shot bit |
| B3:0/1 | Lead selection: 0 = pump 1 leads, 1 = pump 2 leads |
| B3:0/2 | Pump 1 enable permit |
| B3:0/3 | Pump 2 enable permit |
| B3:0/4 | Pump 1 command bit |
| B3:0/5 | Pump 2 command bit |
| T4:1 | Assist timer, 1.0 s base, preset 30 |
If the job were only to latch both pumps onto one level switch with no alternation, latch two level inputs for pump start and stop control would finish it; everything below is about making the lead swap every cycle.
Why does the pump turn on in one rung and off in the next? #
The controller reads all inputs at the start of the scan, solves the rungs in order, and writes the output image to the modules only between scans, so when two rungs write one output the last rung solved wins and the earlier one is never seen. That is the whole trap.
The failed version looks like this: one rung energizes O:0/0 from the level contact, and a later rung de-energizes O:0/0 through an examine-off of the assist timer done bit. For the entire delay the later rung wins, the output image ends each scan cleared, and the pump never runs. Nothing faults and nothing looks wrong in the code; the program simply says no on every scan.
The fix is structural, not a timing trick. Every sequence condition writes an internal command bit, each physical output appears in exactly one rung, and no later rung can undo an earlier decision.
How do you flip the lead bit when the XOR rejects a bit address? #
Give the XOR word-level operands, Source A B3:0, Source B the constant 2, Dest B3:0, and it toggles only bit 1 of the word; the form B:3.0/1 is not a legal entry, and the editor is correct to demand word-level operands. The instruction combines Source A and Source B bit by bit and writes the result to Dest, so its fields take words, never single bits.
The toggle is a mask. Decimal 2 is binary 0000 0000 0000 0010: bit 1 set, every other bit clear. A bit XOR 0 stays itself and a bit XOR 1 inverts, so only bit 1 of B3:0 ever moves. First level cycle: B3:0 = 0, so 0 XOR 2 = 2, Dest B3:0 = 0000 0000 0000 0010, and B3:0/1 = 1. Second cycle: 2 XOR 2 = 0, so B3:0/1 = 0. The word returns to its start every two cycles, and the lead alternates with it.
Read the result where it belongs: an examine-off contact of B3:0/1 in pump 1 command logic, an examine-on contact of B3:0/1 in pump 2 command logic. If your editor refuses a constant in Source B, store 2 in a spare B3 word and reference that word.
Why does the lead selection change on every scan the level switch is closed? #
An unguarded XOR rung is true for every scan that I:0/0 stays closed, so B3:0/1 flips every few milliseconds and the lead selection is noise; an OSR ahead of the XOR makes it flip exactly once, on the scan the level input rises. Without that one-shot, the mask arithmetic is correct but useless.
Put an OSR in the toggle rung ahead of the XOR, with its one-shot bit on a spare address such as B3:0/0. The OSR makes the rung output true for a single scan on each rising edge of the level contact, so the XOR executes once per level cycle. Falling edges do nothing, which matches the sequence: only a completed level cycle swaps the lead.
How do you time the 30-second assist delay? #
One TON on the level input does it: T4:1 with a 1.0-second time base and a preset of 30 makes its done bit set 30 seconds after I:0/0 closes and reset the moment the input opens. The preset arithmetic is 30 counts at 1.0 s per count = 30 s.
Time the assist from the level input, not from a pump contact. The lead pump starts on the same transition that closes the level switch, so for a healthy pump 30 seconds of level is 30 seconds of lead run, which is exactly what the sequence wording asks for. The timer also never depends on a physical output, which pays off later when one pump is disabled. When I:0/0 opens, the rung goes false, the TON resets its accumulated value to zero, and the done bit drops, so every new level cycle starts the delay from scratch.
The same selection problem in a variable-speed pair, where the assist pump also takes a speed setpoint, is covered in variable-speed pump lead/lag assist control programming.
What order do the rungs go in? #
Timing first, commands next, one output rung per pump, toggle last: that order lets the command rungs read the pre-toggle value of B3:0/1 on the scan the level input rises, so the flip prepares the next cycle instead of hijacking the current one. Build the six rungs in this order:
- Assist timer. Examine-on I:0/0 feeding TON T4:1, time base 1.0 s, preset 30.
- Command rungs, one per pump. Each is examine-on I:0/0 in series with that pump's enable bit, feeding a parallel branch of the lead test and examine-on T4:1/DN, to an output coil on that pump's command bit: pump 1 uses B3:0/2, an examine-off of B3:0/1, and a coil on B3:0/4; pump 2 uses B3:0/3, an examine-on of B3:0/1, and a coil on B3:0/5.
- Pump 1 output. Examine-on B3:0/4 to a coil on O:0/0.
- Pump 2 output. Examine-on B3:0/5 to a coil on O:0/1.
- Lead toggle. Examine-on I:0/0, OSR with bit B3:0/0, then XOR with Source A B3:0, Source B 2, Dest B3:0.
Two details make the order matter. On the rising-edge scan, the command rungs are solved with the stored value of B3:0/1, so that value decides who leads this cycle; the toggle at step 5 flips the bit afterward, and the flip takes effect from the next cycle. And because steps 3 and 4 each write their physical output exactly once, nothing later in the program can clear them.
Both enable bits must be on for any command rung to pass: set them in the data table before going to run, or drive them from per-pump permit contacts. They double as your software disable switches. With B3:0/1 stored 0, pump 1 takes the first cycle.
How do you force the level switch to test the alternation? #
Force I:0/0 closed, confirm pump 1 leads and pump 2 joins at 30 seconds, force it open and confirm both commands drop, then close it again and confirm pump 2 leads: three level cycles prove the toggle, the timer and the stop condition. Forces override the real level switch and the real commands, so confirm the pumps may start and the discharge path is open before you force anything.
- With both enable bits on and the controller in run, force I:0/0 on. O:0/0 turns on the same scan, T4:1 accumulates toward 30, and at 30 the done bit sets and O:0/1 turns on.
- Force I:0/0 off. Both outputs drop in the same scan, the accumulated value resets to zero, and B3:0/1 holds its new value.
- Force I:0/0 on again. O:0/1 leads this cycle, and O:0/0 joins at the timer done bit.
- Run one more cycle and watch the lead return to pump 1: the flip happens once per level cycle, never twice in a row and never mid-cycle.
- Remove every force, confirm the controller reports no forces installed, and watch one real level cycle before you call it done.
How do you turn one pump off and still empty the tank? #
Force the physical output off and leave the logic alone: with O:0/0 forced off while pump 1 leads, the internal command bit stays on, the level timer keeps counting, and the other pump still joins after the delay, so the tank still empties. This is the disable case the exercise asks for, and it works with no extra logic because the timer never looked at the physical output.
Watch the layers while it runs: B3:0/4 on, O:0/0 forced off, O:0/1 delayed but on is exactly what the two-layer design should show. The alternation is untouched, since B3:0/1 still flips once per cycle, and removing the force at any point simply returns O:0/0 to its commanded state. Run the mirror case with O:0/1 forced off while pump 2 leads, then clear all forces.
Questions asked
Will RSLogix Micro stop you from entering the same output coil twice?
No. The editor accepts a second coil on the same address without an error and the program runs; the failure only shows at the terminal, where the last rung solved decides the state. You find a duplicate by reading rung order, not by waiting for a fault.
What happens if the level switch chatters open and closed?
Every rising edge flips the lead bit, so a bouncing float hands the lead back and forth, and each brief opening resets the TON accumulated value to zero, which delays the assist pump. If the switch bounces, pass it through a short debounce timer, for example 2 seconds in each direction, before it reaches this logic.
Can the lag pump start immediately when the lead pump is taken out?
Yes. The delayed path is one branch of the command rung; add a parallel branch with an examine-off contact of the lead pump enable bit, so when that enable drops the lag commands on in the same scan instead of waiting for the timer done bit.
How do you make pump 2 lead the first cycle instead of pump 1?
Store 1 in B3:0/1 before the controller goes to run, either by editing the data table or by setting it from a first-scan rung, and leave the rung order unchanged. The stored value is the lead for the first level cycle; every later closing of the level input flips it.
Does the OSR bit need resetting between level cycles?
No. The OSR drives its bit for exactly one scan on each rising edge of its rung condition and clears it on the next scan by itself. Give the instruction a spare bit of its own, use that bit nowhere else, and no reset logic is needed.