Preventing Premature Termination of Endless Looping PCS 7 SFCs
An endless looping Sequential Function Chart (SFC) in SIMATIC PCS 7 unexpectedly stops and transitions to 'Completed' when an unintended branch path or transient transition condition evaluates to TRUE, allowing execution to fall through to the final END step. To guarantee perpetual cyclic operation, ensure all alternative termination branches have mutually exclusive, hardened conditions that cannot float TRUE during sensor glitches. Alternatively, utilize the certified auto-restart design: in the step action of the COMPLETING state, pulse the SFC Start command to trigger an immediate restart, or configure the SFC operating mode property to 'Continuous mode' (Dauerbetrieb).
Table of Contents
- Anatomy of SFC Execution: Why Looping State Machines Fall Through to END
- Design Pattern A: Hardened In-Run Looping Topology
- Design Pattern B: Automated Re-Triggering via COMPLETING / READY State
- Continuous SFC Implementation Patterns Comparison Matrix
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Anatomy of SFC Execution: Why Looping State Machines Fall Through to END
In SIMATIC PCS 7, engineers frequently deploy Sequential Function Charts (SFC and SFC Types) for continuous cyclic routines such as automatic filter backwashing, cyclic sampling manifolds, or periodic tank agitation. A common design flaw in these applications is an 'endless loop' that runs successfully for days, only to halt unexpectedly in the Completed (Beendet) state.
In the standardized ISA-88 / PCS 7 SFC state model, an SFC only terminates when execution enters the predefined END step. This premature exit occurs because:
- Unprotected Alternative Branches: An engineer creates a branch where Path 1 loops back to Step 2, and Path 2 leads to the
ENDstep. If the transition leading toENDevaluates toTRUEeven for a single CPU execution cycle (e.g. an uninitialized bit, sensor noise, or an unconstrained operator command), execution follows Path 2 and terminates. - Transient Transition Evaluation: In standard SFC transition evaluation, transitions are checked top-down and left-to-right. If the loop-back transition condition drops momentarily, and the termination branch is not strictly mutually exclusive, execution falls through.
Design Pattern A: Hardened In-Run Looping Topology
To maintain an endless loop strictly within the RUN state without entering Completed:
- Direct Loop-Back Transition: Wire the transition following the final cyclic operation directly back to the top operational step (e.g. Step 2).
- Hardened Termination Condition: If an exit path to
ENDexists, ensure its transition condition is explicitly interlocked with a dedicated, latched stop command (e.g.Stop_Requested = TRUE AND Step_Timer > T#2s). - Enforce Minimum Step Dwell Time: Always configure a minimum execution duration on the looping transition (e.g.
Step_Final.U >= T#1s). Zero-delay loops can cause multiple transitions to clear within a single OB scan, spiking CPU execution times and risking OB80 cycle time errors.
Design Pattern B: Automated Re-Triggering via COMPLETING / READY State
The Siemens-recommended architecture for recurring sequential routines allows the SFC to complete normally, then restarts it cleanly (documented in SIOS Entry ID 17991071):
- SFC Operating Mode Property: In the SFC Editor under Chart -> Properties -> Operating Parameters, configure Operating mode: Continuous mode (
Dauerbetrieb). In this mode, the SFC automatically restarts upon entering the completed state. - Auto-Trigger via CFC Logic: In the CFC chart hosting the SFC instance, connect the output
Ready(Bereit) through a one-scan pulse generator back into the inputStart. When the sequence reaches the end, it gracefully completes, resets internal step timers, and restarts afresh in the next cycle.
Continuous SFC Implementation Patterns Comparison Matrix
The following table compares different design patterns for continuous cyclic SFC execution:
RUN state permanentlyDauerbetrieb)RUN -> Completing -> RUNReady = 1END[!NOTE]
Commercial Accuracy Notice: Designing and configuring Sequential Function Charts (SFC and SFC Types) uses standard > engineering tools included with the SIMATIC PCS 7 Engineering System (6ES7658-1EX58-0YA5). Utilizing continuous looping > patterns consumes no additional runtime licenses or Process Objects.
Verification
Verify that the continuous SFC loops reliably without stopping:
- CFC Online Test: In the SFC Editor, switch to Test -> Test Mode. Observe the step progression over multiple full cycles. Confirm that after reaching the final operational step, execution loops seamlessly back to Step 1.
- Simulate Branch Condition: Attempt to simulate sensor jitter or noisy inputs on non-terminating branches. Confirm that the chart refuses to drop to
ENDunless the master stop command is asserted. - Long-Term Soak Test: Monitor the SFC state tag (
QSTATE) in WinCC Tag Logging over 72 hours. Confirm that the state remains continuously active (RUN) without intermittent dropouts toCompleted.
Limitations and Operational Precautions
Observe these guidelines when programming cyclic SFCs:
- Prevent OB80 Cycle Overruns: Never create an endless loop that can evaluate infinitely within a single CPU cycle. Always incorporate step delays or wait for cyclic timer triggers (
Step.U >= T#1s). - Provide a Clean Abort Path: Even an endless loop must provide an abort transition linked to emergency stop conditions to allow operators to de-energize equipment during plant emergencies.
- Memory Accumulation: Ensure internal calculation variables inside step actions are reset periodically to prevent floating-point precision loss over months of continuous looping.
Engineer FAQ
Why did my endless loop SFC run fine for days and then suddenly stop?
A temporary sensor glitch or momentary power dip caused an alternative branch transition leading to the END step to evaluate to TRUE for a single scan cycle, terminating the chart.
What is 'Continuous mode' (Dauerbetrieb) in PCS 7 SFC?
It is a built-in SFC operating parameter that automatically resets and restarts the chart immediately after it completes, providing perpetual execution without custom looping logic.
Can an endless loop SFC cause a CPU STOP?
Yes, if steps have zero dwell time and loop back instantly. Clearing multiple steps in one cycle can cause the OB execution time to exceed the configured maximum scan time, triggering OB80 and stopping the CPU.
How do I safely stop an endless loop SFC from the operator faceplate?
Configure a manual stop button on the faceplate linked to an exit transition leading from the loop directly to the END step.
Technical References
- SIMATIC PCS 7 SFC for S7 Programming Guide (Entry ID 109754984)
- SIMATIC S7-400 Organization Blocks and Execution Timing (Entry ID 109751826)
- How to Configure Cyclic and Endless Loops in PCS 7 SFC (Entry ID 17991071)
- Siemens Industry Online Support FAQ on SFC State Machine Architecture (Entry ID 109756843)
Related Articles
- Resolving Conversion Error During SFC Type Changes Download in PCS 7
- Configuring Different Units of Measure in Specific PCS 7 SFC Instances
- Resolving SIMATIC BATCH SFC Allocation Errors After Emergency Recipe Aborts
- Interpreting CFC Feedback Line Indicators and Run Sequence Optimization in PCS 7
Related Tags
- PCS 7 SFC
- Endless Loop
- SFC State Machine
- Continuous Mode
- Transition Logic
- OB80