Give each step a number, act only on the active step, and move on only when the transition condition is met. Number in tens so steps can be inserted later. Publish the step number, the blocking condition and the step timer so the operator can see what the machine is waiting for. Add hold, abort and a defined recovery path before commissioning, not after.
- One active step at a time, one place that changes the step number; anything else becomes untraceable.
- Every step needs a maximum time, or a stalled machine waits silently forever.
- The blocking condition is the difference between a diagnostic screen and a decorative one.
Why a Step Sequence Beats Ad-Hoc Logic
A machine cycle written as a pile of interlocked bits works until the first modification. Nobody can say what state the machine is in, two conditions overlap, and an edge case leaves the cycle half complete.
A state machine fixes this by enforcing three rules:
- The machine is in exactly one step at any moment.
- Outputs are decided by the active step, not by scattered conditions.
- The step changes only when a named transition condition is satisfied.
The result is a cycle you can read, draw and explain. It also gives you a single integer that describes the machine's state, which is exactly what the HMI and SCADA need.
Siemens gives you several ways to implement it: CASE in SCL, a jump list in ladder, or the GRAPH language. CASE in SCL is the most portable and the easiest to review; see ladder logic vs SCL for the language choice.
Steps, Transitions and Numbering
Design the sequence on paper first. For each step write three things: what the machine does, what must be true to move on, and how long it should take.
| Step | Action | Transition condition | Expected time |
|---|---|---|---|
| 0 | Idle, all outputs off | Start command and Ready | n/a |
| 10 | Home the axes | Both home switches made | 8 s |
| 20 | Open inlet valve, fill | High level switch made | 40 s |
| 30 | Close inlet, run mixer | Mix timer complete | 120 s |
| 40 | Open discharge valve | Low level switch made | 30 s |
| 90 | Cycle complete | Acknowledged or auto-repeat | n/a |
| 99 | Aborted | Reset command | n/a |
Number in tens. When commissioning reveals a purge step between fill and mix, it becomes step 25 and nothing else moves. Renumbering a sequence after the HMI text list is built is how machines end up displaying the wrong step name.
Keep step numbers 90 and above for terminal states such as complete, aborted and fault, so a quick look at the number tells you which category the machine is in.
Hold, Abort and Recovery
The happy path is the easy part. What separates a commissioned machine from a demo is what happens when something interrupts the cycle.
- Hold: freeze the sequence, stop motion, remember the step. On resume, continue from where it stopped.
- Abort: jump to a defined abort step that puts the machine in a safe state, then require a reset.
- Fault: an interlock trip forces the same behaviour as abort, with the fault latched. See PLC interlocks and permissives.
- Recovery: decide in advance whether the machine can resume mid-cycle or must return to home. For a filling machine with product in the vessel, "return to home" may mean draining it.
Hold is easy to get wrong. Freezing the step number but leaving outputs energised means a valve stays open for the whole break. Decide per step what hold actually means and write it explicitly.
Test the abort from every step during commissioning, not just from the first one. Aborting from step 40 with a full vessel is the case that finds design gaps.
Build a full machine sequence in class
Siemens sessions covering step sequences, SCL project development and HMI diagnostics.
Step Timing and Operator Visibility
Every step should have a maximum time. If it is exceeded, raise a warning naming the step and what it is waiting for. Without this, a stalled machine simply waits, and the first anyone knows is a missed production target.
Publish four values to the HMI interface data block:
- StepNumber: the active step, displayed through a text list as readable text.
- BlockingCondition: which transition condition is not satisfied, also mapped to text.
- StepTimer: how long the machine has been in this step.
- CycleTime: the duration of the last complete cycle.
The blocking condition is the single most valuable output of the whole sequence. "Step 20, waiting for high level switch LS-102, 4 minutes" restarts production; "Step 20" does not. Screen configuration is covered in the HMI sequence status screen and at plant level in the WinCC sequence overview.
Archiving the step number on change also lets you find which step is quietly eating cycle time across a shift.
Hands-On Lab: Build a Five-Step Machine Cycle
Hands-on- TIA Portal with an S7-1200 or S7-1500 CPU, or PLCSIM
- Simulated inputs for the transition conditions
- Simulation only
- Estimated time: 45 minutes
Design on paper
Write the step table with action, transition condition and expected time for five steps.
Write the CASE structure
Implement the sequence in SCL with CASE on StepNumber, acting only on the active step.
Add the blocking condition
Write the identifier of the unsatisfied transition condition into BlockingCondition.
Add hold and abort
Implement hold that freezes the step and stops motion, and abort that jumps to step 99.
Add step timing
Time each step and raise a warning when the expected duration is exceeded.
The cycle runs end to end, hold and abort behave correctly from every step, and a stalled sequence names both the step and the condition it is waiting for.
Frequently asked questions
Should I write sequences in GRAPH, SCL or ladder?
SCL with a CASE statement is the most portable and easiest to review. GRAPH is excellent for visual step sequences but ties you to that language, and ladder becomes unwieldy beyond a few steps.
Why number steps in tens?
So a step discovered during commissioning can be inserted without renumbering the sequence and the HMI text list that depends on it.
What is the difference between hold and abort?
Hold freezes the cycle and resumes from the same step. Abort jumps to a defined safe state and requires a reset, normally restarting the cycle from the beginning.
How do I stop a machine waiting forever at one step?
Give every step a maximum time and raise a warning when it is exceeded, naming both the step and the transition condition that has not been met.
