To implement an S7-GRAPH sequential function chart (SFC) in a SIMATIC S7-1500 PLC using TIA Portal, create an S7-GRAPH Function Block (FB), define sequential step transitions using logical expressions, and evaluate control interlocks and supervisions. Control flags manage sequencer execution by enabling step advancement, monitoring process faults, and executing mathematical or assignment actions directly within active steps.
Table of Contents
- Technical Cause: Why Custom Ladder/SCL State Machines Fail
- Prerequisites
- Programming an S7-1500 Graph Sequencer in TIA Portal
- Configuring Interlocks and Supervisions
- Executing Math and Logic Actions in Steps
- Sequencer Control Input Signal Mapping
- Verification
- Limitations and Operational Cautions
- Engineer FAQ
- Related Articles
- Related Tags
Technical Cause: Why Custom Ladder/SCL State Machines Fail
Implementing complex sequential processes using standard Ladder Logic (LAD) or Structured Control Language (SCL) state-integer variables often introduces race conditions, state machine locking, and diagnostic opacity. When multiple steps depend on non-atomic condition checks, transitions can bypass required interlocks or cause unintended parallel state execution.
S7-GRAPH implements standard IEC 61131-3 Sequential Function Charts directly inside the S7-1500 execution engine. By encapsulating step activations, transition conditions, interlocks, and supervisions into discrete state objects, S7-GRAPH enforces strict sequential evaluation and built-in fault tracking without requiring custom diagnostic logic.
Prerequisites
Before programming an S7-GRAPH sequencer in TIA Portal for an S7-1500, verify the following configuration requirements:
- Engineering Software: TIA Portal STEP 7 Professional (V12 SP1 or higher).
- Target Hardware: Siemens SIMATIC S7-1500 CPU (e.g., CPU 1511, 1513, 1516, or S7-PLCSIM).
- Memory Allocation: Dedicated Instance Data Block (DB) assigned to the S7-GRAPH Function Block (FB).
Programming an S7-1500 Graph Sequencer in TIA Portal
Follow these steps to create a basic three-step sequential process with START and STOP commands using standard boolean inputs (I0.0 through I0.7).
Step 1: Create the S7-GRAPH Block
- Open TIA Portal and navigate to the project tree.
- Expand the S7-1500 CPU node and select Add new block.
- Choose Function block (FB), set the language to GRAPH, and click OK.
- Define the initial step (
Step1) and sequential transitions (Trans1,Trans2,Trans3).
Step 2: Configure Sequencer Steps and Transitions
Map process conditions to transition logic to control movement through the sequence:
- Initial State (
Step1): The sequencer awaits the primary transition condition. - Transition 1 (
Trans1): Set condition to inputI0.0. WhenI0.0is TRUE, execution advances fromStep1toStep2. - Transition 2 (
Trans2): Set condition to inputI0.1. WhenI0.1is TRUE, execution advances fromStep2toStep3. - Transition 3 (
Trans3): Set condition to inputI0.2. WhenI0.2is TRUE, execution advances fromStep3back to the initial step or sequence completion.
Plaintext
+-----------------+
| Step1 (Init) |
+-----------------+
|
| Trans1: I0.0 = TRUE
v
+-----------------+
| Step2 | <--- Interlock Condition: I0.3 = TRUE
+-----------------+
|
| Trans2: I0.1 = TRUE
v
+-----------------+
| Step3 | <--- Supervision Condition: I0.4 = TRUE
+-----------------+
|
| Trans3: I0.2 = TRUE
v
+-----------------+
| Sequence End |
+-----------------+
Configuring Interlocks and Supervisions
S7-GRAPH provides built-in mechanisms to handle process safety and operational requirements: Interlocks and Supervisions.
Method 1: Programming an Interlock Condition
An Interlock conditions the execution of specific actions within an active step.
- Behavior: If the interlock condition is violated (
FALSE), an interlock fault alarm triggers, and linked step actions are suspended. However, the sequencer does not stop state advancement; transition conditions remain active. - Deactivation: Interlock alarms clear automatically when the step becomes inactive or when an optional operator acknowledgment occurs.
- Configuration Example: In
Step2, assign an interlock linked to inputI0.3. Connect output actionQ0.1(e.g., motor run or laser enable) to this interlock condition. OutputQ0.1energizes only whileStep2is active andI0.3is TRUE.
Method 2: Programming a Supervision Condition
A Supervision monitors the overall validity or execution time limit of an active step.
- Behavior: If a supervision condition evaluates to
TRUE(fault detected), the step generates a supervision alarm and freezes sequencer advancement. The active step remains active, and downstream transitions are blocked until the supervision fault is cleared. - Configuration Example: In
Step3, assign a supervision logic block controlled by inputI0.4(e.g., an emergency stop, guard door contact, or pressure fault). IfI0.4becomes TRUE whileStep3is active, the sequencer stops atStep3and preventsTrans3from triggering.
Executing Math and Logic Actions in Steps
Actions within S7-GRAPH steps are not limited to setting or resetting boolean bits. Complex assignments, shift operations, mathematical functions, and data transfers can be executed directly inside active steps using standard qualifiers.
Action Qualifiers and Syntax Examples
To execute logic when a step is active, select the N qualifier (Non-stored / Active while step is active) or S qualifier (Set / Stored) and enter structured syntax directly into the action field.
Action TypeQualifierS7-GRAPH Action SyntaxFunctional OperationData TransferN``"Tag_1" := "Tag_2"Copies value from Tag_2 into Tag_1 continuously while step is active.Rotate RightN``"Tag_2" := ROR("Tag_1", 3)Rotates Tag_1 right by 3 bit positions and stores the result in Tag_2.Bit ShiftN``"Tag_Out" := SHL("Tag_In", 2)Shifts Tag_In left by 2 bit positions while the step remains active.Timer StartL``T1 (PT := T#5s)Starts an internal step timer T1 with a preset duration of 5 seconds.
Sequencer Control Input Signal Mapping
To manage execution during runtime, map physical inputs or HMI variables to the standard control interface parameters of the generated S7-GRAPH block instance:
Plaintext
Inputs:
I0.0 -> Transition 1 (Step 1 to Step 2)
I0.1 -> Transition 2 (Step 2 to Step 3)
I0.2 -> Transition 3 (Step 3 to End)
I0.3 -> Interlock Condition on Step 2 (Controls Output Q0.1)
I0.4 -> Supervision Condition on Step 3 (Blocks Transition 3)
I0.6 -> Sequencer HALT / STOP Command
I0.7 -> Sequencer START / RESTART Command
Verification
Confirm proper S7-GRAPH operation using TIA Portal Watch Tables or the GRAPH Online Test tool:
- Sequencer Advancement: Force input
I0.0toTRUEin a Watch Table; confirmStep1deactivates andStep2becomes active. - Interlock Test: While in
Step2, toggleI0.3toFALSE. Verify that outputQ0.1de-energizes instantly whileStep2remains the active step. - Supervision Fault Test: Force input
I0.4toTRUEwhile inStep3. ToggleI0.2toTRUEand verify that the sequencer refuses to advance out ofStep3. ClearI0.4and confirmTrans3triggers successfully.
Limitations and Operational Cautions
- Safety Controller Separation: S7-GRAPH supervision conditions are designed for operational process diagnostics. Do not use S7-GRAPH supervisions as a replacement for hardware-based safety relays or PROFIsafe safety programs (e.g., S7-1500F Safety F-FBs).
- Instance DB Memory: Modifying GRAPH step structures or adding steps during runtime requires re-initialization of the block's Instance Data Block, which will reset active steps to default states unless memory reserve is configured.
- Timer Evaluation Scope: Timers configured within S7-GRAPH steps reset automatically when the step deactivates unless explicitly assigned with a stored (
S) qualifier.
Engineer FAQ
Can S7-GRAPH programs be executed on S7-1200 controllers?
No. S7-GRAPH is natively supported on S7-1500, S7-300, S7-400, and WinAC controllers in TIA Portal, but it is not available on SIMATIC S7-1200 PLCs.
What happens to active steps if the PLC transitions from STOP to RUN?
Upon entering RUN mode, the S7-GRAPH sequencer initializes to the designated initial step (INIT_STEP) unless retentive step flags or custom initialization logic are programmed in the FB control interface.
How do I restart an S7-GRAPH sequencer after a supervision fault?
Clear the condition that caused the supervision logic to evaluate to TRUE, then issue an acknowledgment signal to the ACK_EF (Acknowledge Errors) parameter on the S7-GRAPH instance block.
Related Articles
- How to Implement State Machines in S7-1500 SCL
- Configuring Interlocks and Alarms in TIA Portal GRAPH
- S7-1500 Motion Control Integration with S7-GRAPH Sequencers
Related Tags
Code: C277