Creating Reusable CFC Block Types in Siemens PCS 7: Tutorial

David Krause14 min read
HMI ProgrammingSiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

1. Overview: Why Reusable CFC Blocks Matter

Continuous Function Chart (CFC) is the graphical programming language used inside Siemens SIMATIC PCS 7 plants on the AS (Automation Station). One of the most common engineering questions when scaling from a small pilot unit to a multi-unit plant is: how do I package a CFC chart so it can be instantiated, reused, and centrally updated like a Function Block in ladder logic?

This tutorial consolidates the three production-proven approaches — Block Type development in a separate S7 program, Nested Charts, and Master Data Library distribution — and shows how to extend the result with block icons and PCS 7 faceplates for the OS. The procedures apply to PCS 7 V8.2 through V9.1 SP2 with the SIMATIC CFC option package (V9.0 / V9.1) installed in the STEP 7 / SIMATIC Manager engineering station.

Important architectural fact. CFC charts are not source artifacts the way STL/FBD/LAD FBs are. Once compiled into the AS, the chart structure is loaded as FB instances into the S7 CPU. Editing the chart on disk after compilation does not propagate to previously compiled instances — you must re-import the block type. This is the root cause of the “edit one chart, other charts do not update” problem that newcomers run into.

2. Prerequisites and Engineering Environment

Before authoring reusable CFC blocks, verify the following on the ES (Engineering Station):

  • PCS 7 ES V8.2 or later installed; V9.0 / V9.1 SP2 recommended.
  • SIMATIC CFC option package (part of the PCS 7 ES setup) at the same version as PCS 7.
  • SIMATIC S7-PLCSIM (optional) for offline test of new block types.
  • An S7 program skeleton with the PCS 7 master data library applied (APL – Advanced Process Library – is the default in V9.x).
  • Read access to the Siemens manual SIMATIC PCS 7 CFC, sections 5.7.3 (create) and 5.7.4 (change / update), bundled with the ES installation under Start > SIMATIC > Documentation. The corresponding Siemens Support entry for grouped AS blocks / faceplates is How can you group together multiple AS blocks to display the data of all the blocks in the PCS 7 faceplate?.

For OS-side faceplate work you will also need WinCC Explorer (the PCS 7 OS is a WinCC project) and the PCS 7 Faceplate Designer plug-in, which is delivered with the OS Engineering toolset.

3. Method 1 — Block Type Development in a Separate S7 Program

This is the recommended approach for production libraries because it isolates the type under version control and keeps the working plant project clean.

3.1 Workflow

  1. Create a new S7 project in SIMATIC Manager dedicated to the type library (e.g., PCS7_TYPE_LIB_V1).
  2. Insert an S7 program and add the CFC chart that contains the standard block set you want to expose (e.g., one CTRL_PID, one MOT_SPEED, and the wiring between them).
  3. Declare the Chart I/Os by selecting the chart, opening View > Chart I/Os, and dragging signals from the chart surface to the Inputs or Outputs column. Name them according to the PCS 7 naming convention (PascalCase, semantic, no underscores in the type name).
  4. Set chart properties: Chart > Properties > Block Type tab — assign a unique type name (MY_PID_MOT_V1), version comment, and author.
  5. Compile: Chart > Compile > Chart as Block Type. The CFC compiler generates a real S7 FB with a corresponding DB icon and a CFC type symbol.
  6. Enable source protection: Options > Block Type > Know-How Protection. The compiled FB source is encrypted; only the type header, I/O list, and instance DB remain visible.
  7. Export the type: Options > Block Types > Export to a *.zip containing the FB, the symbol table entries, and the version manifest.

3.2 Consuming the Type in the Plant Project

  1. In the working S7 program, choose Options > Block Types > Import and select the exported archive.
  2. The new type appears under the Block Types catalog in the CFC editor sidebar.
  3. Drag it onto a CFC chart. The compiler allocates an instance DB automatically.
  4. After editing the type in the library project (bump the version comment, recompile, re-export), reopen the plant project, choose Options > Block Types > Update > New Version, and select the updated archive. All instances in the plant pick up the new FB revision.
Rule of thumb. Never change the I/O signature of a block type after it has been released; instead, create a new version with a renamed type and a successor faceplate. This avoids the need to rewire every instance in the field.

4. Method 2 — Nested Charts (Chart-in-Chart)

Nested Charts are a faster option when the reusable logic is small and you do not need to distribute it as a protected library. The inner chart becomes a sub-chart folder that can be inserted into any parent chart by reference.

  1. In the CFC editor, create a chart named PID_CORE.
  2. Add the blocks you want to encapsulate (e.g., CTRL_PID + OP_A_LIM).
  3. Open the chart toolbar and click the Chart I/O icon (the icon with the arrows into and out of a box, located below the debug button). This opens the I/O sheet at the bottom of the editor.
  4. Drag any signal from the chart onto the I/O sheet to declare a Chart Input or Chart Output. In/out direction is inferred from the data flow.
  5. Compile the chart: Chart > Compile > Chart as Block Type. Assign a type name (e.g., PID_CORE_V1).
  6. The new type appears in the catalog. Dragging it into a parent chart inserts a chart-in-chart instance; opening it (double-click) opens the original PID_CORE in read-only-by-default mode — modifications still go to the type, not the instance, which is the desired FB-like behavior.

Nested Charts are particularly useful for grouping several AS blocks (motors, valves, PID controllers) into a single faceplate — see the Siemens entry on grouping multiple AS blocks for one PCS 7 faceplate.

5. Method 3 — Master Data Library Approach

For site-wide standardization across multiple PCS 7 projects (e.g., several refineries on a common template), the Master Data Library is the right vehicle. The library is itself an S7 program that lives in a separate project and is referenced by the working project.

  1. Create the library project containing the chart and compile as a block type (steps 1–6 of §3.1).
  2. Open the Master Data Library editor from Options > Master Data Library in SIMATIC Manager.
  3. Add the type and provide a version stamp (e.g., 1.4.0) and a release comment.
  4. From the working project, run Options > Master Data Library > Synchronize. The block type is installed in the working S7 program and is now available in the CFC catalog.
  5. For OS-side artifacts (block icons, faceplates, alarm lines), include the corresponding WinCC pictures in the library and synchronize the OS project as well.
Method Best for Source protection Update mechanism OS integration
Separate S7 program (Block Type) Single-plant type libraries, I&C engineers writing custom blocks Yes (Know-How Protection) Options > Block Types > Update > New Version Manual icon/faceplate add
Nested Chart Quick encapsulation of 2–5 blocks, no external distribution Optional Re-compile the inner chart Auto-generated folder icon
Master Data Library Multi-plant / multi-project templates, EPC standardization Yes + versioned release Master Data Library > Synchronize Synchronized with OS project

6. Defining Chart I/Os Without Rewiring Every Instance

The Chart I/O sheet is the contract between the type and the rest of the plant. The most common source of broken instances is mismatched I/O names between versions.

  • Use IN for signals the type consumes, OUT for signals it produces, and IN_OUT for tags the type both reads and writes (e.g., a process variable address passed by reference).
  • Keep I/O names stable across versions. If you must rename, add the new name and deprecate the old one with a comment rather than deleting it; the CFC compiler will issue a warning instead of breaking existing wiring.
  • For S7 timer or counter tags, use the Type column to set the data type explicitly (e.g., REAL for a PV, BOOL for a permissive). Default type inference occasionally mis-detects WORD for a Boolean control bit, which later causes a SCL “type mismatch” during FB generation.

7. Compiling “Chart as Block Type” — What Actually Happens

When you trigger Chart > Compile > Chart as Block Type, the CFC compiler performs the following sequence, useful to know when debugging a failed compile:

  1. Generates SCL source for an S7 FB that mirrors the chart’s run sequence, block order, and I/O sheet.
  2. Compiles the SCL into the FB and a matching instance DB template.
  3. Generates a CFC type symbol (the yellow box icon) and registers the type in the local block-type catalog.
  4. Stores the version comment, author, and a checksum of the SCL source in the block’s comment header — this is what Options > Block Types > Show Version reports.

If step 1 fails, the most common cause is a chart I/O pointing to a tag whose data type was changed in the symbol table after the chart was drawn. Use Chart > Check Consistency first; it surfaces type mismatches in the message window before the FB generation kicks off.

8. Creating Block Icons and PCS 7 Faceplates

A CFC type is only complete when it has an OS-level representation. The block icon is the small graphic on the overview picture; the faceplate is the pop-up window an operator opens by clicking the icon.

  1. Open WinCC Explorer on the OS project that has been compiled from the same S7 program.
  2. From the PCS 7 Faceplate Designer toolbar, choose Insert New Block Icon. The designer prompts for the AS block (or block-type instance) to bind to.
  3. For a chart-in-chart type that wraps several AS blocks (e.g., a motor + a PID), the faceplate is composed of multiple sub-faceplates — the procedure is documented in Siemens Support entry 28757820.
  4. Place the icon on a process picture using the standard PCS 7 symbol catalog. The status colors (green / yellow / red / gray) follow the block’s QMODF, QERR, and BA_NA outputs by default.
Common pitfall. A protected block type generated via §3 does not automatically create a block icon for the technological sub-blocks inside it. You must explicitly expose each technological block’s status outputs as chart I/Os and bind them in the faceplate. If only the wrapper type is bound, the icon will not animate.

9. Importing, Instantiating, and Updating Block Types

Action Menu path Notes
Import a new type Options > Block Types > Import Archive is *.zip with FB, symbol, version
Insert an instance Drag from the block-type catalog to a chart One instance DB per drop
Update to a new version Options > Block Types > Update > New Version All instances refit; runtime values are kept unless I/O signature changed
Roll back a version Options > Block Types > Show Version > Reinstall Useful when an update breaks a unit; re-import the previous archive
Synchronize the library Options > Master Data Library > Synchronize Required for multi-project templates

10. Troubleshooting Common Issues

Symptom Likely root cause Fix
Edit on the inner chart only changes one instance, not all Chart was copied (not compiled as a block type) into other parents Re-compile the source chart as a block type and re-import; replace copied instances with type instances
Block icon does not appear for a technological block inside a protected type Sub-block outputs not exposed as chart I/Os Add the status outputs (QMODF, QERR, BA_EN, BA_NA) to the chart I/O sheet and rebind the faceplate
Operator clicks “Manual” on the faceplate but the block stays in Auto (ManModOp latched at 1) Operator input is being held by a write-lock from the AS; the permissive chain is missing a feedback interlock Check ManModOp in the AS online view; verify the Feature.Bit settings of the APL block (especially bits 0, 7, and 16) match the project standard; ensure the ManModOp_Lock input is FALSE
Type version update fails with “type mismatch” on FB An I/O was renamed or removed in the new version Restore the old I/O as deprecated, recompile, then run the update again; the new I/O can be added in a follow-up version
Block icon visible but no values update on the OS OS is bound to a renamed symbol after the type update Run OS compile; in WinCC Explorer check Tag Management > AS Symbols for unresolved tags
Compile error: “Chart contains blocks of incompatible run sequence groups” Blocks with different OB priorities mixed in the same chart Split the chart into sub-charts by OB priority (OB1 / OB35 / OB32) and convert the encapsulation to a block type

11. Verification and Acceptance Test

  1. After import, run Chart > Check Consistency > Across All Charts. Resolve every warning before continuing.
  2. Download the S7 program to the AS (or to PLCSIM). The download should complete with status OK and no diagnostic buffer entries of class “Programming error”.
  3. In the CFC online view, confirm the instance DB is created and the run sequence is healthy (green bars on the OB priority column).
  4. On the OS, open the picture containing the new block icon, click the icon, and verify the faceplate opens, all measured values are updating, and both Manual and Auto commands are accepted (i.e., ManModOp returns to 0 after a Manual command is cleared).
  5. For each new type, perform a forced-value test: disconnect the I/O, force a known value, and confirm the icon animates within one OS update cycle (typically 1 s for a status change, 2 s for a measured value).
  6. Sign off the type with a Block Type Release Note capturing the FB version, the symbol-table entries, the OS picture version, and the list of instances deployed. Store the release note in the project’s quality folder.

12. Field-Proven Best Practices

  • Treat a CFC block type as a versioned product: keep its S7 program, its exported archive, and its OS picture in a single change package.
  • Never edit a released type in the working plant project. Always change the library project, re-export, and update — even for a one-character typo.
  • Use the APL (Advanced Process Library) as the technological foundation and wrap it in your own block types. Re-implementing CTRL_PID from scratch is rarely justified.
  • Keep the number of chart I/Os lean. A type with more than ~24 I/Os is hard to wire on a single HMI screen and signals a poor decomposition.
  • Document the type in the PCS 7 plant documentation tool (e.g., COMOS) with a screenshot of the faceplate, a one-line description per I/O, and a sample instance wiring diagram.
  • Before going to a new major version of PCS 7, validate your custom block types against the new CFC compiler — Siemens has changed FB-generation semantics between V8.2 and V9.0, particularly around the handling of IN_OUT parameters of structured types.

What is the difference between a CFC block type and a nested chart?

A block type is an S7 FB compiled from a CFC chart and stored in a protected library; it can be imported into any S7 program and updated centrally. A nested chart is a chart-in-chart instance that lives inside the same S7 program and is read-only-by-default — it is faster to create but cannot be distributed across projects or protected with Know-How Protection.

Why does editing my chart not update the other charts that use the same logic?

You most likely copied the chart (Ctrl-C / Ctrl-V) into each parent instead of compiling it as a block type. Each copy is an independent chart; editing one does not propagate. Compile the original chart with Chart > Compile > Chart as Block Type, import the type into the S7 program, and replace the copies with type instances.

How do I create a faceplate that shows several AS blocks (e.g., a motor and a PID) at once?

Group the blocks inside a CFC chart, expose each block’s required status outputs as chart I/Os, compile the chart as a block type, and use the procedure in Siemens Support entry 28757820 to compose the faceplate from the individual sub-faceplates.

The block icon is generated for my protected type but not for the technological blocks inside it. What is wrong?

Block icons for sub-blocks are not created automatically. You must expose each technological block’s status outputs (QMODF, QERR, BA_EN, BA_NA) as chart I/Os in the source chart, recompile the type, and rebind the faceplate components to the new I/Os.

After clicking Manual on the faceplate, the block stays in Manual and ignores Auto. How do I fix it?

Check the ManModOp tag online in the AS; if it is latched at 1, the most common causes are a stale ManModOp_Lock input, an Feature.Bit setting on the APL block that does not match the project standard, or a write-lock from a higher-priority CFC chart. Clear the lock, correct the feature bits, recompile, and reload the AS to restore normal command response.

Back to blog