Creating Reusable Function Blocks and Nested Charts in SIMATIC PCS 7 CFC

Creating Reusable Function Blocks and Nested Charts in SIMATIC PCS 7 CFC

In SIMATIC PCS 7, you can create modular, reusable logic from CFC charts using two official methods: the Chart-in-Chart (nested chart) technique or the 'Compile Chart as Block Type' function. Chart-in-Chart creates a sub-chart with Chart I/Os within a parent chart for hierarchical organization. To generate a true compiled Function Block (FB) with its own instance DB and library catalog entry, create a chart with exposed Chart I/Os, configure OCM attributes (S7_m_c := 'true'), and execute Chart > Compile > Chart as Block Type, assigning a unique FB number and symbolic name.

Table of Contents

Modular Programming in PCS 7: Chart-in-Chart vs Block Type Compilation

In large-scale process automation projects, replicating identical equipment logic (such as automated valve groups, dosing sequences, or custom pump lead-lag logic) requires standardization to minimize engineering hours and testing overhead.

SIMATIC PCS 7 provides two graphical methodologies for encapsulating CFC logic:
1. Chart-in-Chart (Nested Chart): An open hierarchical sub-chart embedded within a parent chart. Internal blocks remain individually visible and editable.
2. Chart as Block Type: Compiles the entire graphical chart into a closed, compiled S7 Function Block (FB) placed in the offline Blocks folder. The resulting FB can be instantiated repeatedly across multiple charts just like standard APL blocks.

Implementing Chart-in-Chart (Nested Charts) with Chart I/Os

The Chart-in-Chart technique organizes complex logic into clean visual hierarchies:

  1. In SIMATIC Manager, open any CFC chart.
  2. Right-click an empty area of the canvas and select Insert New Chart (or drag a chart from the catalog).
  3. A nested chart block appears on the sheet. Double-click to open it.
  4. Place technological blocks (e.g., And04, Or04, TimerP) and interconnect signals inside.
  5. From the top menu, select View > Chart I/Os. The Chart I/O interface table opens displaying sections IN, OUT, and IN_OUT.
  6. Drag block input/output pins to the Chart I/O table to expose external connection pins.
  7. Close the sub-chart: the nested block on the parent sheet now exposes these custom connection pins for external wiring.

Compiling a CFC Chart into a Reusable Function Block (FB)

To package a chart into a certified, compiled function block:

Step / ConfigurationAction in CFC EditorEngineering SignificanceStep 1: Create Source ChartCreate a dedicated CFC chart containing the desired logic.Serves as the graphical source code for the FB.Step 2: Define Chart I/OsOpen View > Chart I/Os and expose all external inputs/outputs.Defines the formal parameter interface of the compiled FB.Step 3: Assign OCM AttributesRight-click exposed I/Os > Object Properties > Attributes.Assign { S7_m_c := 'true' } for WinCC tag generation.Step 4: Execute CompilationSelect Chart > Compile > Chart as Block Type.Invokes the SCL compiler to translate graphics into machine code.Step 5: Define Block PropertiesAssign FB number (e.g., FB1500), Name, Family, Version.Registers the block in the offline Blocks folder and catalog.

Table 1: Workflow for compiling a CFC chart into an S7 Function Block.

Configuring Operator Control and Monitoring (OCM) Attributes

For the compiled Function Block to support automated OS compilation and faceplate creation:
* In the Chart I/O table, select each process variable destined for HMI display (e.g., setpoints, actual values, operating status).
* Open Object Properties > Attributes:
* Set S7_m_c := 'true'.
* Set S7_visible := 'true'.
* In the block header properties, ensure the family matches your technological convention (e.g., USER or DRIVES).
* When the OS Compiler executes, it automatically generates a WinCC structure tag for every instance of your compiled FB.

Verification

To confirm proper block generation and execution:

  1. In SIMATIC Manager, open the Blocks folder: verify that the newly generated block (e.g., FB1500) is present.
  2. Open a test CFC chart: open the block catalog under Libraries > User Blocks and drag FB1500 onto the canvas.
  3. Verify that all exposed inputs and outputs appear correctly with assigned default values.
  4. Download the program to S7-PLCSIM or CPU: switch to Test Mode and verify that internal logic executes correctly.
  5. Perform an OS compile: verify that WinCC Tag Management generates the matching technological structure tags.

Limitations and Operational Precautions

  • A chart compiled as a block type cannot contain other charts compiled as block types, or SFC charts, or technological blocks with internal dynamic ALARM_8P allocations unless message attributes are explicitly handled.
  • Modifying the internal logic of a compiled block requires updating the source CFC chart, re-executing Chart as Block Type, and updating block types across all charts with potential CPU STOP requirements.
  • For simple modularization, modern PCS 7 versions prefer Control Module Types (CMTs) over 'Chart as Block Type', as CMTs support online instance synchronization without CPU stops.

Engineer FAQ

What is the difference between Chart as Block Type and Control Module Types (CMTs)?

Chart as Block Type compiles logic into a single closed FB. Control Module Types (introduced in PCS 7 v8.0) manage modular collections of individual standard blocks that can be updated centrally while preserving online instance editing.

Can I debug the internal logic of a compiled block in online test mode?

No. A compiled block executes as a closed machine-code FB; you can only monitor its external input/output pins in CFC. To debug internal logic, test the original source chart.

What FB number range should I choose for custom compiled blocks?

Choose FB numbers in the user range: FB1000 to FB1999 (avoiding numbers reserved by APL, such as FB1800 to FB1900) or FB2000 and above.

Technical References

Related Articles

Related Tags

  • CFC
  • Block Type
  • Chart-in-Chart
  • Chart IO
  • FB Creation
  • OCM Attributes
  • PCS 7
6 respuestas