How Nested CFC Charts Execute and How to Manage Runtime Sequences in PCS 7

How Nested CFC Charts Execute and How to Manage Runtime Sequences in PCS 7

In SIMATIC PCS 7, inserting a Continuous Function Chart (CFC) into another CFC chart creates a nested subchart rather than an encapsulated subroutine. In the controller operating system, execution is block-based rather than chart-based: the individual blocks within the nested chart are installed directly into the execution list of the assigned Organization Block (such as OB35). If a chart is created in the Plant View and subsequently dragged into another chart, a duplicate copy of the chart structure is instantiated. If the original chart's blocks remain registered in the run sequence alongside the newly inserted copy, the code will execute twice per cyclic interrupt. Deterministic single execution requires inspecting and managing runtime groups in the CFC Run Sequence Editor.

Table of Contents

Top-Level Charts vs. Nested Subcharts in the CFC Hierarchy

In the PCS 7 CFC editor, engineers can construct visual hierarchy by embedding charts within charts:
- Top-Level Chart: A standalone CFC chart residing directly in a plant hierarchy folder in SIMATIC Manager.
- Nested Chart (Subchart): A chart inserted inside a parent chart sheet to group related logic (e.g., placing interlock logic inside a pump control chart).
- Chart I/O Interfaces: Nested charts utilize Chart I/O pins to exchange signals with parent chart blocks across sheet boundaries.
- No Program Jump Instruction: Unlike traditional PLC programming where a subroutine is called via a jump instruction, a nested CFC chart does not execute as a call subroutine. The CFC compiler flattens the hierarchy and schedules individual block instances directly into controller runtime groups.

Block-Based CPU Execution Mechanics in Cyclic OBs

Understanding CPU scheduling in SIMATIC S7-400 controllers explains how blocks are processed:
1. The Organization Block Container: Cyclic interrupts (such as OB35, configured for 100 ms) maintain an execution list of Function Blocks and Functions.
2. Runtime Groups: Within OB35, blocks are organized into Runtime Groups. A runtime group corresponds to an individual CFC chart or functional section.
3. Execution Order: When OB35 triggers, the CPU executes the runtime groups sequentially from top to bottom, invoking each block's machine code once per cycle.
4. Subchart Placement: When a subchart is created, the compiler creates a corresponding runtime group under the parent chart's position in the run sequence.

The Risk of Duplicate Execution When Dragging Charts

The question of whether a chart executes once or twice depends on how the chart was instantiated:

Instantiation MethodRun Sequence BehaviorTotal Executions Per CycleDrag from Master Library / TemplateCreates a new single instance in the target chart; creates one runtime group in OB35.Once: Standard deterministic execution.Insert New Nested Chart (Empty)User builds logic directly inside the child sheet; compiler registers one runtime group.Once: Correct execution.Drag Existing Chart from Plant ViewCFC creates a copy of the chart structure inside the target chart, while the original chart remains in the plant folder.Twice: If both the original chart and the copy have active blocks in OB35, the logic executes twice!

If duplicate execution occurs on technological blocks (such as timers, integrators, or totalizers), process calculations run at double speed, causing setpoint overshoots and erratic control behavior.

Method: Managing and Verifying the CFC Run Sequence Editor

To ensure that blocks execute strictly once per cycle in the correct chronological order, configure the Run Sequence Editor:

Step 1: Open the Run Sequence Editor

  1. In the CFC editor, select Edit -> Run Sequence... (or click the Run Sequence icon on the toolbar).
  2. The window displays an expandable tree of all Organization Blocks (OB100, OB1, OB35, OB34, etc.).

Step 2: Locate the Assigned Organization Block

  1. Expand OB35 (Cyclic Interrupt 100 ms).
  2. Locate the runtime groups corresponding to your parent chart and subcharts.
  3. Observe the naming convention: runtime groups are named after the chart path (e.g., Plant1/UnitA/Chart_Pump101).

Step 3: Identify and Eliminate Duplicate Runtime Groups

  1. Search the OB35 tree for duplicate block names or redundant chart entries.
  2. If the original standalone chart was replaced by a nested subchart, delete the obsolete standalone chart from SIMATIC Manager.
  3. If an orphaned runtime group remains, right-click the empty or redundant group in the Run Sequence Editor and select Delete.
  4. Confirm that each technological block instance appears exactly once in the execution tree.

Step 4: Optimize Execution Order (Data Flow Direction)

  1. Verify that upstream blocks execute before downstream blocks:
    - Analog/Digital Input Channel Drivers (Pcs7DiIn, Pcs7AnIn) must execute first.
    - Mathematical calculations and interlock logic must execute second.
    - Control blocks (MotL, VlvL, PIDConL) must execute third.
    - Digital Output Channel Drivers (Pcs7DiOu) must execute last.
  2. If a block is out of order, drag and drop it into its correct chronological position in the list.

Verification

To confirm that nested charts execute cleanly and deterministically:
- Open the CFC chart in online Test Mode (Debug -> Test Mode).
- Monitor dynamic accumulator blocks (such as runtime meters or totalizers): confirm that time increments advance by exactly one second per real-time second.
- Open Options -> Reference Data -> Run Sequence: verify that the tabular listing shows no duplicate block calls within the same OB.
- Check CPU performance data: verify that cyclic interrupt execution times remain stable without unexplained spikes.

Limitations and Operational Precautions

  • Do Not Nest Charts More Than 2-3 Levels Deep: While CFC technically supports multiple levels of chart nesting, deep hierarchies hinder operator troubleshooting, obscure signal flow, and complicate runtime sequence visualization.
  • Avoid Mixing Different OBs Inside a Single Chart: All blocks within a tightly coupled nested chart should execute within the same organization block (e.g., all in OB35). Distributing blocks across different cycle rates (e.g., inputs in OB35, logic in OB32) introduces multi-cycle latency and phase-shift jitter.
  • Automatic Runtime Group Creation: When inserting new blocks, CFC uses the "Insertion Point" setting. Always check where new blocks are placed to avoid scattering logic across distant runtime groups.

Engineer FAQ

Does inserting a chart as a subchart save CPU memory?

No. In PCS 7, memory allocation is determined by the total number of block instances and their associated instance data blocks (DBs). Nesting charts improves graphical project organization for the engineer, but does not reduce CPU RAM consumption.

How do I navigate between a parent chart and a nested subchart?

Double-click the subchart icon inside the parent chart sheet to drill down into the child logic. To navigate upward, click the Upward arrow icon on the CFC navigation toolbar.

What happens if I delete a parent chart that contains nested subcharts?

Deleting the parent chart in SIMATIC Manager deletes all internal nested subcharts and removes their associated blocks from the CPU run sequence.

Can a nested chart have its own Chart I/O?

Yes. Open the nested chart, select View -> Chart I/O, and define input and output parameters. These parameters appear as connectable pins on the subchart block face when viewed from the parent chart.

Technical References

  • Siemens Industry Online Support: SIMATIC PCS 7 CFC for S7 Manual (A5E00278782).
  • SIOS Entry 109742323: PCS 7 Compendium Part A - Configuration Guidelines (Section: Execution Sequences and Timing).
  • SIOS Entry 109809264: SIMATIC Process Control System PCS 7 Advanced Process Library Manual.
  • Siemens Engineering Guide: Deterministic Program Scheduling in SIMATIC S7-400.

Related Articles

Related Tags

  • CFC
  • Run Sequence
  • OB35
  • Nested Charts
  • S7-400
  • Execution Order
  • Industrial Automation
20 respuestas