The short answer
How to Build a Sequencer
To build a sequencer, write the sequence as a numbered list of steps from the control narrative, each with what it does and what ends it; hold the current step in one integer register; write one rung or statement per transition that advances the register when the exit condition is true and the step timer has not expired, and one that sends it to a fault step when the timer expires; drive every output from the step number, never from the transition logic; add an idle step for power-up and reset, a hold step for pauses, and an abort path from every step; and test it by walking every transition, every timeout, and every abort with the equipment simulated, then live.
Key points
- One integer register holds the step; every output is a function of that register.
- Every step has an exit condition and a timeout; the timeout goes to a fault step.
- Idle, hold, and abort steps are part of the design, not afterthoughts.
- Transitions change the step; they never drive outputs directly.
- Test every path, including the ones that should never happen, before the plant relies on it.
What you need
- The control narrative with the sequence of operations
- The I/O list for the equipment in the sequence
- The programming software for the controller and a test controller or emulator
- A step table: number, name, action, exit condition, timeout, abort behavior
- A screen or a watch table to display the step and the timers
Procedure
- 1
Write the step table
From the narrative: step number, name, what the step does, what ends it, how long it may take, and what happens on abort. Step 0 is idle. Include a fault step and a hold step. Get the operator to read it.
- 2
Choose the step register
One integer, retentive if the sequence must resume after a power loss, otherwise cleared to idle on first scan. Name it for the sequence.
- 3
Write the transitions
For each step, one rung: if step equals N and the exit condition is true, set step to N plus one, or to the branch target. One more rung: if step equals N and the step timer has expired, set step to the fault step and record which step timed out.
- 4
Write the abort
One rung: if the abort condition is true and the step is not idle or fault, set step to the abort step, which shuts things down in order and then returns to idle.
- 5
Drive the outputs
For each output, a rung that energizes it when the step register equals any of the steps that need it. Outputs are never set in the transition rungs.
- 6
Add hold and resume
A hold command sets a hold flag and stores the current step; the outputs that must drop during a hold are gated by the flag; resume restores the step.
- 7
Reset the step timer
A timer that runs while the step is unchanged and resets when the register changes; its preset is the timeout for the current step from a table or a case statement.
- 8
Show it
Step number and name, time in step, the transition being waited for, and the last fault step on a screen; the sequence is debuggable only if it is visible.
- 9
Test offline
On an emulator or a test controller with inputs simulated: every transition, every timeout, every abort, hold and resume from every step, and power loss in the middle.
- 10
Test live
With the equipment, with an operator watching each step, with the timeouts real; then with each failure induced.
// Step register: SEQ_STEP
// Step 2: open inlet valve, wait for open limit, 30 s timeout
IF SEQ_STEP = 2 AND VALVE_OPEN_LS THEN SEQ_STEP := 3; END_IF;
IF SEQ_STEP = 2 AND STEP_TIMER.Q THEN FAULT_STEP := 2; SEQ_STEP := 99; END_IF;
// Output: inlet valve open command is a function of the step
VALVE_OPEN_CMD := (SEQ_STEP = 2) OR (SEQ_STEP = 3) OR (SEQ_STEP = 4);Rules
- Never write the same output from two places.
- A step that waits on the field has a timeout; a step that only waits on a timer is a timer step.
- Branches use the same pattern with different targets; loops jump back to an earlier step with a loop counter and a limit.
- The fault step records which step failed and holds until reset; the abort step drives outputs to their safe state in order.
- Power-up goes to idle unless the design says resume, and resume requires an operator confirmation.
Frequently asked questions
- How do I handle two things that must happen at once?
- Either put both in the same step, since a step can drive several outputs, or run two sequencers with their own step registers and a handshake step in each. Two sequencers writing the same output is the error to avoid.
- The sequence sticks in a step and nobody notices.
- The step has no timeout, or the timeout is hours. Every step waiting on the field has a timeout measured in the time the field action should take plus margin, and the fault step alarms.
- Should the sequence resume after a power loss?
- For a backwash or a clean-in-place, usually restart from a safe step with operator confirmation; for a batch with chemistry in progress, resume the held step after confirmation. The narrative decides, and the step register is retentive only if resume is chosen.
- How do I test a sequence without running the equipment?
- On an emulator or a spare controller with the inputs forced or simulated by a test routine that mimics the field responses, walking every transition. Then live with each step confirmed by an operator.
Related topics
- SequencersStep-based control for operations that always run in the same order: backwash, pump and valve startup, batch makeup, membrane cleans. What every step needs, three ways to implement one, handling faults and power loss mid-sequence, and what the HMI shows.
- Sequential Function ChartThe IEC 61131-3 language for sequences: steps, transitions, actions and their qualifiers, alternative and simultaneous branches, where it fits in water and wastewater, and the rules that keep a chart from sticking in a step.
- State Machines in PLC ProgramsWriting sequences as explicit states instead of tangled interlock chains: what a state is, how transitions are written, the pattern in structured text and in ladder, publishing the state to the HMI, and the failure handling every state machine needs.
- Sequences of OperationWriting the ordered, step-by-step description of what a system does: states, transitions, timeouts, and the format that lets a programmer implement it and a tester verify it without interpretation.
- PermissivesThe conditions that must be true before a device may start: how permissives differ from interlocks and trips, the list a pump or feeder usually needs, coding them so the HMI can say why a start was refused, and the rules for time delays and bypasses.
- Clean-in-PlaceCleaning membranes in place: the triggers from the normalized trends, the low pH clean for scale and the high pH clean for organics and biofouling, the sequence of flush, heat, recirculate, soak, and rinse, and how automation makes cleaning repeatable.
Direct contact
Have a controls question?
Reach Eric Sullivan directly about anything on this site, a controls or automation topic, or one of his personal projects.