Troubleshooting Unexpected Execution Reordering in CFC Runtime Groups - Data Flow Optimization and Sequence Locking

Troubleshooting Unexpected Execution Reordering in CFC Runtime Groups - Data Flow Optimization and Sequence Locking

When function blocks within a SIMATIC PCS 7 CFC runtime group appear in an unexpected or seemingly random execution sequence where they were previously structured, the condition is typically caused by triggering the automated 'Optimize Run Sequence' algorithm or having 'Chart-Oriented Insertion' enabled in the chart folder properties. The optimization algorithm analyzes inter-block signal interconnections and re-sequences blocks strictly according to data flow—placing upstream calculation blocks immediately before downstream blocks to eliminate single-cycle dead time. To restore manual sequencing and prevent future automated reordering, open the Run Sequence Editor (Ctrl+F5), arrange the blocks in the desired order, open the Runtime Group properties, and uncheck the attribute 'Optimization of run sequence' to lock the execution order.

Table of Contents

Mechanics of the CFC Run Sequence: Task Execution vs Visual Arrangement

In SIMATIC PCS 7 Continuous Function Charts (CFC), the visual layout of blocks on a graphic sheet (Chart 1, Sheet 1) has no inherent relation to the chronological order in which the S7-400 microprocessor executes their instructions. When an S7 CPU triggers a cyclic interrupt (e.g., OB35 at 100 ms), it executes blocks strictly according to the hierarchical Run Sequence defined in the Run Sequence Editor (Ctrl+F5).

Blocks are grouped into Runtime Groups. An engineer may organize a runtime group with blocks arranged logically by equipment numbering (e.g., Block 1: Motor 101, Block 2: Motor 102, Block 3: Motor 103). However, over project lifecycles, engineers frequently report that blocks inside a runtime group have suddenly shifted into an unfamiliar, non-sequential order.

Why the Optimization Algorithm Appears to 'Scramble' Blocks (Data Flow Sorting)

The primary cause of sudden reordering is the execution of 'Optimize Run Sequence...' (or 'Optimize Groups/Tasks'):

  • If an engineer right-clicks an Organization Block (e.g., OB35) or a runtime group and clicks 'Optimize Run Sequence', the system executes a deterministic mathematical topological sort.

  • The Sorting Rule: The algorithm analyzes every input and output interconnection. It mandates that any block providing an output must execute before the block that consumes that value as an input, ensuring data transfers in the same scan cycle with 0 ms dead time.

  • To satisfy this rule across complex interlocking matrices, the algorithm will rearrange blocks regardless of their equipment tags. What appears 'random' to a human engineer is mathematically optimal from a signal propagation perspective.

Chart-Oriented Insertion ('Planorientierter Einbau') and Dynamic Wiring Reordering

Starting in PCS 7 V8.1 and V8.2, Siemens introduced Chart-Oriented Insertion:

  • Under this system setting (enabled in Chart Folder Object Properties -> Advanced tab), simply drawing or moving a connection line between two blocks automatically triggers a micro-optimization in the background.

  • The moment an engineer connects an output to an input, CFC recalculates execution order, updating the block header numbers (e.g., 35/1 swapping with 35/4).

Locking Runtime Groups to Protect Custom Sequencing and Feedback Latches

In specific technological applications, automatic data-flow reordering is undesirable:

  • Sequential Equipment Staggering: Plants where high-power pumps or compressors must start with deliberate 1-cycle staggering to prevent electrical inrush currents.

  • Deliberate Feedback Delay Registers: Control circuits utilizing a 1-cycle feedback delay (flip-flops, edge detection pulse timers) can fail if an automated optimizer moves the receiving block before the sending block.

  • Sequence Protection: In the properties of any runtime group, unchecking 'Optimization of run sequence' places a permanent lock on that group. The automated optimization engine will skip locked groups, preserving the engineer's manual order.

Comparative Behavioral Matrix: Manual Sequencing vs Data Flow Optimization

The following table compares manual block ordering against automated data flow optimization:

Operational CharacteristicManual Runtime Group SequencingAutomated Run Sequence OptimizationBlock Arrangement LogicVisual / Functional / Equipment Tag OrderStrict Mathematical Data Flow DependencyInter-Block Dead TimePotential 1-cycle delay (100 ms in OB35)Minimized to 0 ms (Immediate in-cycle transfer)Stability of Order100% Fixed and LockedDynamically adjusts on wiring changesTrigger MechanismUser drag-and-drop in Ctrl+F5 editorMenu 'Optimize Run Sequence' or Chart-Oriented InsertionBest ApplicationStart sequences, feedback latches, custom logicStandard analog closed-loop control, PID loops, interlocks

Step-by-Step Procedure to Inspect, Rearrange, and Lock Runtime Sequences

Follow this procedure to correct scrambled runtime sequences and lock them against future changes:

  1. Open Run Sequence Editor:
    - In any CFC chart, press Ctrl + F5 (or click the Run Sequence icon).
    - Expand the target task (e.g., OB35).

  2. Identify the Reordered Runtime Group:
    - Expand the affected runtime group. Inspect the sequential list of block calls.

  3. Manually Re-Order Blocks:
    - Click and drag individual blocks up or down within the runtime group to restore the desired operational sequence.
    - When manually relocated, CFC marks the blocks as manually positioned.

  4. Lock Runtime Group Against Optimization:
    - Right-click the runtime group header and select Object Properties.
    - In the General tab, locate the checkbox 'Optimization of run sequence'.
    - UNCHECK this checkbox to disable automated optimization for this specific group.
    - Click OK.

  5. Compile and Download Changes:
    - In CFC, execute CFC > Compile > Changes only.
    - Download changes to the AS in RUN mode.

Verification

Verify sequence stability through these checks:

  1. In the Run Sequence Editor, verify that the blocks within the locked group remain in the exact specified order.
  2. Right-click the parent Organization Block (e.g., OB35) and run Optimize Run Sequence....
  3. Confirm that the locked runtime group is bypassed and its internal block execution order remains completely undisturbed.
  4. Switch to CFC Test Mode (Ctrl+T) and verify that sequential pulses or interlock handshakes operate with the intended timing.

Limitations and Operational Precautions

  • Dead Time Trade-Off: Locking a runtime group with sub-optimal execution order locks in a 1-cycle (100 ms) calculation lag. Ensure that fast analog control loops (e.g., flow or pressure control) are not locked in reverse order.
  • Module Driver Protection: Never manually rearrange or lock the system runtime groups prefixed with @ (e.g., @OB35_...), as the Driver Generator manages these automatically.
  • SFC Chart Calls: SFC charts have dedicated runtime groups; do not move SFC internal blocks into standard CFC runtime groups.

Engineer FAQ

Why did my blocks rearrange when I ran 'Optimize Run Sequence'?

The optimization algorithm sorts blocks strictly by signal dependency (upstream blocks executing before downstream blocks) to eliminate cycle dead time, which frequently scatters blocks that were previously arranged alphabetically or by tag name.

How can I tell which execution position a block has directly from the CFC sheet?

Look at the upper right corner of the block header. It displays the task and execution sequence number (e.g., 35/12 means OB35, Position 12).

Can I lock individual blocks instead of the entire runtime group?

Yes. When you manually move a block in the Run Sequence editor, CFC flags that individual block as manually placed, protecting it from automatic shifting.

Does optimizing the run sequence affect CPU cycle time?

No. It does not change the total number of instructions executed; it only changes the order of execution within the OB scan window.

What is the shortcut to open the Run Sequence editor?

Press Ctrl + F5 from any open CFC chart.

Technical References

Related Articles

Related Tags

  • Run Sequence
  • Runtime Groups
  • CFC Optimization
  • OB35
  • Data Flow
  • Sequence Locking
  • AS Engineering
6 respuestas