How-to
Sequencer valve control with a table-driven PLC program
Short answer
Write the sequence as data, not as rungs: one output command word per state in the binary file, a pointer word selecting it through an indirect MOV, and a second table of limit-switch patterns that proves each state before the pointer advances. A timer alone never advances a wash step; the feedback word must equal the commanded pattern or the step is a fault.
On this page
- Why a table beats per-valve interlock rungs
- Build it in this order
- Build the command table in the binary file
- Select the state with one indirect MOV
- Prove the state from the limit switches before advancing
- Encoding the wash cycle for a filter blower and its valve bank
- Advance on proof, time each step once
- Commission state by state before the first automatic run
- Questions asked
Sequence a valve bank with data, not with interlock rungs: store one output command word per state in the binary file, point at the active state with an integer word, and let a single indirect MOV copy the right word to the outputs. Pair the command table with a second table of limit-switch patterns so the program proves every step before it advances, because a step timer alone proves nothing about a valve. This layout turns a blower-and-valve wash cycle into two short tables and a handful of rungs, it survives edits because adding a state is a new table word rather than new logic, and it gives the commissioning technician one number to watch: the pointer. Here is the full build, with a filter wash sequence worked through to finished word values.
Why a table beats per-valve interlock rungs #
The interlock way writes a rung chain per valve and per step: a limit switch permits an output, the output enables a timer, the timer permits the next valve. Six valves over eight states turns into dozens of rungs that all have to agree with each other. The table way stores what each state commands as one word of data and what proves it as another, so the rung count stays flat no matter how many states the cycle grows. It also changes the debugging model: instead of tracing rung chains, the technician watches one pointer value and two words, commanded and proven, and any disagreement between those two words is by definition the fault.
Build it in this order #
- Fix the I/O map first: every device in the sequence gets an output terminal, and every valve gets the limit switch or switches that prove its commanded position.
- Write the command table: one word per state, bit positions aligned with the output word.
- Write the prove table: one word per state, bit positions aligned with the input word.
- Write the selection rung: an indirect MOV that copies the active command word to the outputs.
- Write the advance rung: step timer done and proof word equal, through a one-shot, moving the pointer to the next state.
- Write the fault rung: a proof mismatch latches a valve-fault bit and blocks the advance.
- Commission by hand: select each state, compare commanded with proven, then run the full cycle.
Build the command table in the binary file #
Give every state its own word in the binary data file: state 0 in the first word, state 1 in the next, and so on. The SLC 500 Instruction Set Reference Manual (publication 1747-RM001) documents the data files this layout uses; B3 holds bit-addressable words and N7 holds integers. Before any bit is set, decide the mapping from your I/O drawing, bit 0 to the first output terminal and onward, and write it on the drawing, because every table value depends on it. A bit set means open or running and a bit clear means closed or stopped, the same convention as the sequence sheet.
If every device lives in one output word, the table word can move straight to that word. If the devices spread across several output cards, keep the table as an internal command word and map its bits to the physical outputs with individual rungs; the selection logic is otherwise identical.
The pointer is an ordinary integer word with one value per state. Because the selection rung writes on every scan, the outputs follow the pointer from the first scan onward, so give the pointer a defined start value from a first-scan or reset condition and the machine wakes in a known state.
Select the state with one indirect MOV #
One rung does all the switching:
MOV
Source B3:[N7:0]
Dest O:0
The bracket is the whole design: the source is the table word the pointer selects, so changing N7:0 changes the entire valve pattern, and the rung rewrites the outputs every scan to match. State transitions never touch output logic at all. Move the pointer with ordinary rungs: a start or reset command moves zero into it behind a one-shot, and each advance adds one state. Keep every pointer write behind a one-shot, because an input held true across two scans would walk the pointer away.
The SQO alternative #
RSLogix 500 packages the same walk as the sequencer output instruction SQO: it keeps the step position internally and copies each file word through a mask to the destination as its rung transitions. The companion compare instruction SQC checks live inputs against the table row, which puts the proof comparison inside the sequencer pair, so two rungs can cover both halves of the design. The trade against the MOV layout is the pointer: the SQO position lives inside the instruction rather than in a free integer word, so an operator screen or a fault routine that wants the step number reads it from the instruction instead of from a data-file word.
Prove the state from the limit switches before advancing #
Build a second table with one prove word per state, in the same bit order as the command table: bit for bit, what the limit switches must read when the state has genuinely been reached. One comparison rung then covers every valve: mask the input word down to the proven bits, compare it with the prove word for the active state, and make equality the advance permissive. The same indirect trick selects it; the compare uses the prove word the pointer chooses exactly as the MOV uses the command word.
A mismatch is a valve fault, not a timing problem. Latch a fault bit on inequality, require that bit off in the advance rung, and hold the pointer where it is. This is the part the interlock design got right by accident, because a valve that never reached its commanded position stopped the sequence, and it is the part most likely to be dropped in a table rewrite, since the timer will happily time out in a broken state. Never let timer completion alone advance a step.
Encoding the wash cycle for a filter blower and its valve bank #
The inputs, as the wash specification for one filter gives them:
- Devices: one blower and a valve bank the sheet lists as V1, V2, V5, V4, V6, V7 and V8, seven valve columns where the piping sketch shows six, so the extra column must be resolved to a real terminal before anything below is downloaded.
- States: Online and Offline, which the operator holds, then six timed steps named Drain, Air Scour, BW Air/H2O, BW H2O, Refill and Rinse, with durations the sheet fixes and the table below carries.
- The example bit mapping, which is my layout and not yours: bit 0 blower, bit 1 V1, bit 2 V2, bit 3 V5, bit 4 the extra column, bit 5 V6, bit 6 V7, bit 7 V8.
- Pointer N7:0, integer, initial value 0; command words B3:0 through B3:7; prove words in a second block of the same file, one per state in the same order.
The rule: each state word is the sum of the place values of its open devices, and bit position n contributes 2 to the power of n. Drain opens V5, the extra column, V6 and V7, which are bits 3, 4, 5 and 6, so the word is 8 + 16 + 32 + 64 = 120. Rinse opens V1 and V8, bits 1 and 7, so the word is 2 + 128 = 130. The remaining states add the same way:
| State (N7:0) | Word | Step | Duration | Decimal value |
|---|---|---|---|---|
| 0 | B3:0 | Online | operator-held | 6 |
| 1 | B3:1 | Offline | operator-held | 192 |
| 2 | B3:2 | Drain | 2 min | 120 |
| 3 | B3:3 | Air Scour | 5 min | 97 |
| 4 | B3:4 | BW Air/H2O | 10 min | 121 |
| 5 | B3:5 | BW H2O | 10 min | 56 |
| 6 | B3:6 | Refill | 1 min | 66 |
| 7 | B3:7 | Rinse | 5 min | 130 |
The result: the selection rung copies B3:[N7:0] to the output word, and the timed walk runs from state 2 to state 7 with presets of 2, 5, 10, 10, 1 and 5 minutes moved from a preset table by the same pointer.
The decision: a state is entered and held only while its prove word matches the switches; at timer done with a matching prove word the pointer advances, and on any mismatch the pointer holds and the fault bit latches. Those decimal values are correct only for the example mapping, so recompute them column by column against your own I/O drawing, and settle the extra valve column first, because its bit sits inside three of the six timed words.
Advance on proof, time each step once #
One timing rung serves the whole cycle. A timer runs while the active state is a timed one, and its preset comes from a second small table indexed by the same pointer, so the durations live beside the command words they belong to. Store the preset table in the base the timer counts and decide that unit once for the whole table.
The advance rung is three conditions in series: the timer done bit, the proof comparison made, and a one-shot so a single transition moves the pointer exactly one state. At the last timed state the pointer returns to the holding state the process specifies rather than rolling into whatever word comes next. Every write to the pointer, start, advance or fault return, goes through a one-shot for the same reason as before: a held input must not skip a state.
Commission state by state before the first automatic run #
Make the commissioning sheet before the download: state number, expected command word, expected switch pattern, duration and the one permitted next state. Then work the sequence by hand. Jog the pointer to each state, compare commanded outputs against feedback, and confirm the proof rung passes where the valves are right and fails where a switch is wrong. Run the automatic cycle only after every state passes statically.
The office copy of the software proves syntax, not behavior, and when the processor is in the field there is no bench unit to practice on. Rehearse the selection, compare and advance rungs as ladder logic practice projects so the pointer and one-shot mistakes surface on a desk instead of on a live filter.
Safety note: an indirect MOV actuates every device in the destination word in one scan, so a wrong table value or an uncontrolled pointer opens the whole bank at once. Make the first download with the processor outputs de-energized or the machine locked out, prove the table state by state as above, and only then hand the sequence to automatic.
Questions asked
When should I use SQO instead of the MOV and pointer layout?
Use SQO when the cycle is fixed and nobody needs the step number: the instruction keeps its own position and copies each table word through a mask on a rung transition. Keep the MOV and pointer layout when an operator screen should display the current step, when commissioning wants to jog the sequence one state at a time, or when a fault has to return the sequence to a known state, because the pointer is then an ordinary integer word anyone can write directly.
What should the program do when a limit switch pattern does not match?
Latch a valve-position fault bit, hold the pointer on the state that failed, and keep the commanded outputs on or drop to the offline pattern, whichever the process calls safe. Clear the fault only from a reset that returns the pointer to state 0 after someone has looked at the valve. Never let the step timer advance the sequence on a mismatch: a done bit proves elapsed time and nothing about valve position, so an advanced pointer turns one stuck valve into a process error two steps later.
Why build a state table instead of one timer and interlock rung per step?
Per-step rungs multiply: eight states over eight devices becomes dozens of rungs, each with its own chance to drift out of step after an edit. The table version holds the same information as data, so a sequence change is a new word and a new preset rather than new logic, the proof comparison is written once and covers every state, and a printout of two short tables documents the whole sequence for the next technician.
Can the scheme prove a valve that has only one limit switch?
Partly, and the prove table must say which side. With only an open switch, an open command is proven but a closed command is not, so a stuck-open valve passes every comparison unnoticed. Where a step depends on a valve being closed, that valve needs a closed-position switch so both states carry a real proof bit; otherwise mark the unproven bits out of the compare with the mask and list those valves as unproven on the commissioning sheet.
Do the operator-held states use the sequence timer?
No. States the operator holds, such as online service and offline standby, carry no duration in the wash specification, so the advance rung that watches the timer done bit is simply not serviced there. Those states change when an operator or an upstream condition moves the pointer, and the preset table carries entries only for the timed states, so nothing in the logic has to be rewritten for a step with no fixed length.