Overview
S7-GRAPH is the optional STEP 7 package for programming sequential control systems using a state-machine style notation that maps directly to the Sequential Function Chart (SFC) element of IEC 61131-3. According to Siemens, "GRAPH is a graphic programming language for creating sequential control systems. Sequences can be programmed in a fast straightforward manner using sequencers" (see Creating GRAPH programs (S7-300, S7-400, S7-1500)). The same package is available as S7-GRAPH V5.3 for Classic STEP 7 on S7-300/400 and as the integrated GRAPH editor in TIA Portal for S7-300/400/1500.
An S7-GRAPH sequencer expresses a process as a network of steps joined by transitions with executable actions attached to steps and interlocks / supervisions guarding the run time behaviour. The sequencer compiles to a Function Block (FB) plus an instance DB that holds step state, mode selection, fault flags, and diagnostic timers. The runtime scans the active step every OB1 cycle, evaluates its leaving transition, fires any edge-driven actions, and walks forward when the transition becomes true.
Engineers new to S7-GRAPH typically have questions in five areas, which are all covered below:
- Interlocks and supervisions
- Event-dependent actions versus permanent operations
- Terminations and jumps
- Alternative branching (OR)
- Simultaneous branching (AND)
Reference target: TIA Portal V20 with the S7-GRAPH optional package, on S7-1500 (CPU 1515-2 PN as a representative part number). Differences for S7-300/400 and for Classic STEP 7 are flagged inline.
Prerequisites
Confirm the following before creating an S7-GRAPH project:
| Item | Requirement |
|---|---|
| Engineering tool | TIA Portal V18 or later (V20 used as reference here); for legacy hardware, Classic STEP 7 V5.5 SPx with the S7-GRAPH V5.3 optional package installed |
| License | Siemens S7-GRAPH licence (a separate floating or node-locked key required on every engineering PC) |
| Supported CPU families | S7-300 (CPU 31x), S7-400 (CPU 41x), S7-1500 (CPU 15xx including F variants). S7-1200 is not supported. |
| Minimum CPU firmware | S7-300 / S7-400: firmware V2.0 (V3.0 if you use the S7-GRAPH online watch with S7-PLCSIM). S7-1500: firmware V1.0 or later. S7-1500F: firmware V1.5 or later for fail-safe sequencers. |
| Block architecture | Function Block (FB) compiled to GRAPH; instance Data Block (iDB) generated automatically. Multi-instance use inside higher-level FBs is allowed. |
| Prerequisite knowledge | Bit logic, timers (TP/TON/TOF), edge detection (POS/NEG), boolean step chains, FC/FB calling conventions. |
The minimum firmware for S7-GRAPH online watch on SIMATIC S7-PLCSIM is V4.5 of PLCSIM with TIA Portal V17+; older combinations produce read-only views of the sequencer.
Sequencer Block Architecture
An S7-GRAPH sequencer is always an FB of type GRAPH. The editor builds the state machine inside the FB; at compile time it generates the instance DB containing:
-
Step flags — one bit per step (
S1,S2, …,Sn) -
Active step — current step number (
S_ACTIVE, INT) - Mode control byte — AUTO / MANUAL / TAP / TOP / OFF / INIT
-
Fault flags — supervision error (
FAULT), interlock error (S_INTERLOCK), acknowledgement request (ACK_SF_REQ) - Elapsed-time counters for every step
- Transition flags used for diagnostics
- Edge memory for rising / falling event actions
The standard interface of the sequencer FB exposes the symbols below. Their semantics are identical in Classic STEP 7 and TIA Portal:
| Symbol | I/O | Type | Function |
|---|---|---|---|
OFF_SQ |
IN | BOOL | Switch sequence off; all steps deactivate and are not scanned. |
INIT_SQ |
IN | BOOL | Reset to initial step (active step → Step 1). |
ACK_SF |
IN | BOOL | Acknowledge a pending supervision / interlock fault. |
S_PREV |
IN | BOOL | Manual mode: go to previous step. |
S_NEXT |
IN | BOOL | Manual mode: go to next step. |
S_SEL |
IN | INT | Manual mode: step number to make active. |
SW_AUTO |
IN | BOOL | Mode = Automatic (production). |
SW_TAP |
IN | BOOL | Mode = Single-step / Tap. |
SW_MAN |
IN | BOOL | Mode = Manual — operator selects the step. |
SW_TOP |
IN | BOOL | Mode = Top — manual advance without interlock. |
ENO_OK |
OUT | BOOL | False if a process fault or invalid mode combination is present. |
S_ACTIVE |
OUT | INT | Currently active step number. |
ERROR |
OUT | BOOL | Any active fault (supervision or sequencing error). |
FAULT |
OUT | BOOL | Supervision fault active. |
S_NO_OFF |
OUT | BOOL | Sequence off. |
S_MORE |
OUT | BOOL | More than one step active — diagnostic for a parallel branch. |
S_TRANSIT |
OUT | BOOL | Indicates a transition between steps during this scan. |
The complete predefined set is documented in the TIA Portal online help under Sequencer interface parameters. For Classic STEP 7 the same list is in the S7-GRAPH V5.3 manual (module C1 of the S7-300/400 training package, available through the Siemens Automation Cooperates with Education (SCE) portal).
Steps, Transitions, and Actions: The Core Elements
Three primitives appear at every junction in the GRAPH editor:
- Step — represents a stable state of the process. While active it executes its attached actions and accumulates elapsed time.
- Transition — Boolean condition evaluated between two steps. When the leaving step is active and the condition is true, control advances to the next step.
- Action — commands issued from a step. Each action has an action qualifier that defines when the action fires and whether the assigned operand is stored.
The qualifier is the single most important piece of metadata on an action line:
| Qualifier | Trigger | Edge | Stored | Typical use |
|---|---|---|---|---|
N |
While step active | — | No | Run a level-sensitive command (e.g. drive on) |
S |
On step entry | Rising | Yes (latch) | Set a flag for downstream logic |
R |
On step entry | Rising | Yes (reset) | Reset a flag set by an earlier step |
D |
Time-limited, runs to completion | Rising | No (auto-resets) | Pulse / start-timer action |
L |
Time-limited, interruptible | Rising | No | Delayed command that must cancel on early step exit |
P |
On step entry | Rising | No (one scan) | Counter pulse, edge-driven trigger |
SD |
On step entry, after delay | Rising | Yes (stored, after delay) | Latched output that should fire only after N seconds |
DS |
Delayed stored | Rising | Yes (set after delay) | Latched output that fires N seconds in |
SL |
Stored, time-limited | Rising | Yes (auto-reset on timeout) | Stored output with forced timeout |
CALL |
Conditional call to FC/FB | Level or rising | n/a | Invoke external block from this step |
(N), (S) … |
Conditional (qualifier wrapped in parentheses) | — | No | Run command only when a Boolean inside the step is true — the Boolean is the per-step interlock condition |
The qualifier is placed immediately before the operand in the action editor. Examples:
| Action line | Meaning |
|---|---|
N "Motor".Run |
Run motor while step is active |
S "HMI".HeaterReady |
Latch HeaterReady on step entry |
D(5s) "Valve".Open |
Pulse valve open for 5 s on step entry |
L(2s) "Pump".Rinse |
Run pump for 2 s; cancel output if step exits earlier |
(N) "Cylinder".Extend |
Extend only when the step's interlock condition is true |
Permanent vs. Event-Dependent Actions
Actions themselves are split into two kinds based on their position inside the step object.
Permanent operations (Ständige Anweisungen) belong to the body of the step, not to an action line. They run on every scan for which the step is active, independent of any edge. Typical uses:
- Set a runtime flag (e.g.
"DB_State".step_active_X1 := 1;) - Compute a derived value every cycle
- Override interlocks in commissioning or test mode
Because permanent operations repeat every scan, do not place level-sensitive on/off commands there. Use an N-qualified action instead, otherwise the assignment happens on every cycle rather than on a clean step edge.
Event-dependent actions sit in the action list of a step and execute on a specific event defined by the qualifier. Common events:
-
Step entry — qualifiers
S,D,P,SD,DS -
Step exit (falling edge, available for stored qualifiers) —
R,SL -
Step active (level) —
N -
Conditional — qualifier wrapped in parentheses, e.g.
(N),(S),(D)
The practical rule: use an event-dependent action for anything that should fire once, and use a permanent operation only for cyclic logic that must repeat every scan.
Interlocks (Intra-Step Logic)
From the S7-GRAPH manual: "An interlock is a programmed condition within a step. An interlock influences the execution of individual actions."
Mechanically, an interlock is a Boolean condition written into the dedicated interlock field of a step — for example "PartPresent" AND NOT "E_StopActive". While the step is active:
- If the interlock is true, every action of that step executes normally; all qualifiers fire on their respective edges.
- If the interlock is false, every action whose qualifier is wrapped in parentheses (e.g.
(N),(S),(D)) is suppressed.
An interlock is a per-step enable signal. It does not stop the sequence from advancing, and it does not appear as a fault. It is the cleanest way to express "this step is allowed to drive outputs only when safety pre-conditions are met."
Example: a "Press ram extend" step needs both a part-present sensor and a guard-closed signal. Without an interlock the ram extends whenever the step is active regardless of guard state. With an interlock it only extends while both conditions remain true — if the operator opens the guard mid-stroke the action drops instantly, but the sequence can still advance when the leaving transition becomes true.
To wire a real signal as interlock, place the condition in the step's interlock field (TIA Portal shows it as the top half of the step box, marked with an I). The compiler then routes the condition to the action suppression logic.
Supervisions (Transition Watchdogs)
From the same manual: "A supervision is a programmable condition within a step. A supervision influences the way in which control passes from one step to the next."
A supervision is also a Boolean attached to a step. While the step is active the runtime checks the condition every scan:
- If the condition becomes true while the leaving transition is also true, the sequencer treats this as an error. The leaving transition is blocked, the sequencer enters the ERROR state, and
FAULTrises. - The operator must then
ACK_SFto clear the fault, after which the sequence can advance manually.
The canonical pattern is "step X must complete within N seconds". The condition is then "DB_Seq".STEP_X.T > 10s (elapsed-time supervision). When the leaving transition is satisfied but the process hasn't moved, supervision fires, the sequence goes into ERROR, and the operator diagnoses.
A supervision is the right place to put:
- Maximum-time assertions ("cycle complete in < 30 s")
- Uniqueness constraints ("two limit sensors reading active simultaneously")
- Sensor plausibility ("pressure above 5 bar AND flow below 1 L/min")
- Watchdog between a go command and the done feedback
Implementation tip: combine the supervision with an alarm action so the HMI shows both the symbolic step number and a human-readable fault text. The supervision field (lower half of the step, marked with an S) accepts both a single Boolean and a structured condition with timer references.
When the sequencer enters ERROR the S_ACTIVE output still reflects the step that caused the fault. Holding INIT_SQ resets the sequence to step 1; alternatively a manual S_NEXT after ACK_SF walks the sequencer past the offending transition.
Alternative Branching (OR)
GRAPH supports two non-linear shapes: alternative (exclusive) branches drawn with a single fork line, and simultaneous (parallel) branches drawn with a double fork line.
Alternative branches are exclusive: only one of the parallel paths is selected per cycle.
- The leaving transition below step N opens.
- The incoming transition of the lane whose condition first becomes
trueis selected; any remaining lanes become inactive for that cycle. - The branches converge at a join transition; control proceeds once the selected lane completes.
Use alternative branches for either/or dispatch: route product to line A or line B based on recipe, go to cleaning or to maintenance from "end of batch", pick between two recipes with same preconditions.
Rules of thumb when designing an OR split:
- Put the most safety-critical lane first (lowest transition number) so it cannot be starved by a slower upstream signal.
- Avoid overlapping
truetransition conditions — overlapping trues cause non-deterministic selection. If overlapping is unavoidable, prefer simultaneous branching with a downstream decision step instead. - Label each transition with the condition it represents (e.g.
"recipe".mode = 2) so the editor view remains self-documenting.
Simultaneous Branching (AND)
Simultaneous branches are parallel: when the leaving transition is true, all incoming lanes fire at once and all parallel steps become active together. Each lane then processes independently, and the sequence does not leave the branching until the joining transition downstream becomes true.
Mechanically:
- Step N has a transition below it that branches into two or more parallel lanes drawn with a double horizontal line.
- When the transition is true, both downstream steps become active simultaneously and
S_MORErises. - Each lane processes independently (interlocks, supervisions, jumps, actions are all local).
- A joining transition downstream waits for the last active lane to finish before the merge step activates.
Use simultaneous branches for genuinely independent work that should not serialize:
- Two valves opening and closing in parallel as part of the same phase
- A pump pre-charge running concurrently with a heater warm-up
- Synchronising motor axes that must share a common handshake but not interlock
Be aware of:
- The merge transition must explicitly handle "all parallel steps finished". The default is an AND across the preceding step flags; make the editor render the joining condition so it is auditable.
- Cross-lane data exchange must go through instance-DB bits because intra-scan ordering is deterministic but cross-lane ordering is not.
- Every parallel lane can produce its own supervision fault; build an aggregated ERROR handler that lists all parallel contexts.
Terminations, Jumps, and the Sequence End
Three mechanisms handle non-linear control flow.
Sequence end (terminator): a step whose transition connects to the End object. When the transition becomes true, the sequencer switches to the OFF state, every step deactivates, and the scan stops. To restart, drive INIT_SQ from the calling program or the HMI.
Jump to step: drawn as an arrow from a transition to a step upstream or downstream of the current step. The jump may be conditional (only fires when the transition is true) or unconditional (always fires when the transition evaluates true). Important: only the target step becomes active after the jump — the jumped-over steps do not see a rising edge and therefore do not fire any edge-triggered actions. Pair jumps with a dedicated transition reset bit to avoid stale flags.
Loop back (jump to earlier step): a jump to an earlier step implements retry/iterate logic. Define a maximum-loop counter using the sequencer's UDINT counter in the instance DB, and use a separate transition to break out of the loop into a fault branch when the counter exceeds a threshold.
Branch terminator (empty step): an alternative or simultaneous lane can be terminated early with an empty terminator step. The runtime evaluates the empty terminator immediately and moves to the joining transition.
The canonical retry pattern with alternative branching is: try → success transition to next step → failure transition jumps back to try with a counter increment step in between.
Operating Modes and the Control Interface
S7-GRAPH sequencers expose four operating modes plus two reset states, normally driven by an HMI control block:
| Mode bit | State | Operator action | Use case |
|---|---|---|---|
SW_AUTO |
Automatic | None | Production run |
SW_TAP |
Single-step (Tap) | Press S_NEXT per step |
Commissioning, training |
SW_MAN |
Manual | Select step via S_SEL, then S_NEXT / S_PREV
|
Service / repair |
SW_TOP |
Top (manual, no interlock) | Force step transitions without interlocks | Forced run / override |
OFF_SQ |
Sequencer off | All steps deactivated | Safe stop |
INIT_SQ |
Reset to initial step | Force sequence to Step 1 | Recover from fault |
The mode bits are mutually exclusive. The compiler generates a runtime error in the instance DB if more than one mode bit is active in the same cycle.
For each step you can also configure step-specific permission bits (often grouped as S_AUTO, S_TAP, S_MAN, S_TOP) so that the same step behaves differently in AUTO vs MANUAL — for example, jogging an axis in MANUAL while locking the axis in AUTO.
Commissioning, Verification, and Debug
Take an S7-GRAPH block from source to a verified running sequencer with this sequence:
- Compile the FB in the GRAPH editor (Project → Compile). Errors appear in the diagnostics window. Common issues are dangling transitions, unconnected alternative branches, action qualifiers with mismatched brackets, and missing operator rights.
- Download FB and instance DB. Use Online → Download to Device in TIA Portal (or PLC → Download in Classic). In RUN mode, both should download; in the unlikely event of a download error on the GRAPH FB, switch to STOP and retry.
- Open GRAPH Watch (Online → Monitor / Modify) and view the sequencer in three panes: Structure (steps + transitions with raw Boolean values), Active Status (current step, elapsed times, mode), and Cross-references.
-
Force
SW_AUTOfirst, then drive the initial transition by simulating the binary inputs the sequencer expects. Check that the active step number changes only when the leaving transition is true. -
Trigger a supervision fault by holding the leaving transition false for longer than the supervision time. Verify that the sequencer enters
ERROR, thatFAULTrises, and that a rising edge onACK_SFclears it. -
Verify interlocks by clearing the interlock bit while the step is active. Actions marked
(N),(S)etc. should be suppressed — their assigned operand should not see a rising edge. -
Verify branching by alternating the parallel path conditions. In alternative branching, only one lane activates per cycle; in simultaneous branching, both lanes activate at the same time and
S_MORErises. -
Walk the sequencer in TAP mode: set
SW_TAP, then pulseS_NEXTrepeatedly. Confirm that every step takes exactly one operator click to advance and that no step is skipped. -
Verify the HMI tag wiring with a watch table on the GRAPH instance DB: every HMI-controlled BOOL/INT (mode,
ACK_SF,INIT_SQ,OFF_SQ,S_SEL) must read and write to the exact symbolic address shown.
The instance DB layout is fully symbolic and can be inspected in a watch table. Use the predefined UDT GRAPH_STATE (or the equivalent block-parameter view in the watch) for cross-referencing in diagnostic blocks.
CALL qualifier only with FC/FB blocks that complete quickly, and set a sensible upper bound in OB1 for max cycle time.Troubleshooting Matrix
| Symptom | Likely cause | First check | Fix |
|---|---|---|---|
| Sequence never advances from Step 1 | Leaving transition's Boolean condition is false | Watch the transition in GRAPH Watch; verify input bits | Correct transition condition or wire input signals |
| Actions never fire even though step is active | Interlock is false; using parenthetical qualifier (N), (S) etc. |
Watch the interlock expression | Make interlock unconditionally true, or use plain qualifier |
FAULT rises immediately when transition becomes true |
Supervision of leaving step is true at the same moment as the transition | Inspect the S-field on the step | Tighten the supervision so it fires only after a real timeout |
| Sequence advances but outputs do not energise | Action qualifier is (N) but the corresponding condition is false |
Watch the conditional expression on the action line | Either drop the parentheses or fix the Boolean condition |
| Parallel branches behave as exclusive | Editor rendered single-line fork by mistake (OR instead of AND) | Inspect the branching graphics — should be a double line | Switch branch type from OR to AND in the editor |
S_MORE stays 1 after the merge step activates |
Join transition is missing one of the parallel predecessor flags | Inspect the join transition's Boolean expression | Add the missing parallel step flag |
ENO_OK drops immediately |
Invalid mode combination (e.g. SW_AUTO + SW_MAN) or non-existent initial step |
Watch the mode bits in the instance DB | Enforce mutually exclusive mode bits in the HMI tag frame |
ACK_SF has no effect |
Action is executed as a constant rather than a rising edge on the FB input | Watch DB input | Use rising-edge detection on the HMI side |
| Sequence runs but elapsed-time counter for step never resets | Step expression is being re-entered via a jump without resetting the time | Inspect jump target and verify INIT_SQ behaviour |
Insert a clearing transition between source and target, or accept the running count |
| Compile error: "Action qualifier not supported in this block type" | Block compiled against an older S7-GRAPH definition set | Inspect Block interface version in the FB properties | Upgrade the FB interface version and recompile |
FAQ
What CPU firmware is the minimum for S7-GRAPH sequencers?
S7-300/400 require firmware V2.0 or later (V3.0 if you use the S7-PLCSIM online watch). S7-1500 supports S7-GRAPH from firmware V1.0; S7-1500F supports fail-safe sequencers from firmware V1.5. The S7-1200 family does not support S7-GRAPH; sequential control must be implemented in LAD/FBD/SCL or a third-party SFC package.
What is the practical difference between an interlock and a supervision?
An interlock suppresses the actions of a step while leaving the sequence free to advance; it is a per-step enable. A supervision blocks the transition out of a step when its condition becomes true alongside the leaving transition, raises FAULT, and requires ACK_SF before the sequencer can leave the step.
When should I use event-dependent actions vs permanent operations?
Use an event-dependent action (qualifier S, R, D, L, P, SD, DS, SL) for logic that should fire on entry, exit, or a one-shot condition. Use a permanent operation only for cyclic level-sensitive computation that must run every scan while the step is active.
Why does my parallel branch activate all steps simultaneously?
You used simultaneous branching (the double-line fork) instead of alternative branching. Switch the branch type from AND (double horizontal line) to OR (single horizontal line) in the editor if you need exclusive selection; keep AND when both lanes must run in parallel.
How do I acknowledge a supervision fault from HMI?
Bind the HMI button to the symbol <Sequencer_FB_instance_DB>.ACK_SF (or the HMI tag wired to that input). A single rising edge on ACK_SF clears the supervision, after which the sequencer can advance through the blocked transition.