Preventing Premature Termination of Endless Looping PCS 7 SFCs

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

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:

  1. Unprotected Alternative Branches: An engineer creates a branch where Path 1 loops back to Step 2, and Path 2 leads to the END step. If the transition leading to END evaluates to TRUE even for a single CPU execution cycle (e.g. an uninitialized bit, sensor noise, or an unconstrained operator command), execution follows Path 2 and terminates.
  2. 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:

  1. Direct Loop-Back Transition: Wire the transition following the final cyclic operation directly back to the top operational step (e.g. Step 2).
  2. Hardened Termination Condition: If an exit path to END exists, ensure its transition condition is explicitly interlocked with a dedicated, latched stop command (e.g. Stop_Requested = TRUE AND Step_Timer > T#2s).
  3. 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 input Start. 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:

Design PatternSFC State BehaviorRisk of Unexpected TerminationCPU Scan Time ImpactRecommended Use CaseHardened In-Run LoopStays in RUN state permanentlyHigh if exit branch is weakSpikes if step dwell time is omittedHigh-speed sequences (<10s cycle)Continuous Mode (Dauerbetrieb)Cycles RUN -> Completing -> RUNZero (Native OS feature)Low (Deterministic reset)Standard process recyclingExternal CFC Re-triggerRe-triggers on Ready = 1Zero (Controlled logic)LowInterlocked batch sampling cyclesUnprotected Alternative BranchFalls through to ENDVery High (Failure-prone)VariableStrictly prohibited

[!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:

  1. 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.
  2. Simulate Branch Condition: Attempt to simulate sensor jitter or noisy inputs on non-terminating branches. Confirm that the chart refuses to drop to END unless the master stop command is asserted.
  3. 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 to Completed.

Limitations and Operational Precautions

Observe these guidelines when programming cyclic SFCs:

  1. 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).
  2. 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.
  3. 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

Related Articles

Related Tags

  • PCS 7 SFC
  • Endless Loop
  • SFC State Machine
  • Continuous Mode
  • Transition Logic
  • OB80
6 respuestas