How to Resolve SCL Syntax Errors When Compiling CFC Charts as Block Types in PCS 7

How to Resolve SCL Syntax Errors When Compiling CFC Charts as Block Types in PCS 7

To resolve SCL syntax errors such as Unknown statement occurring on orphaned := FC(...) lines when compiling a CFC chart as a block type, correct the internal function call assignments or restructure your template using Control Module Types (CMT). The CFC-to-block compiler generates intermediate Structured Control Language (S7-SCL) code where every function (FC) call must assign its return value to a valid variable. When an FC output is disconnected, assigned to a reserved keyword, or misaligned with chart I/O parameters, the SCL generator emits an invalid leading assignment token. Furthermore, compiling charts containing Advanced Process Library (APL) technological blocks into composite block types strips WinCC OS attributes (S7_m_c), breaking faceplate generation. The supported industry standard is to model reusable multi-block typicals as Control Module Types in the Master Library.

Table of Contents

Mechanics of the CFC 'Compile Chart as Block Type' Compiler

In STEP 7 and SIMATIC PCS 7, the Compile -> Chart as Block Type function automates the translation of a graphical Continuous Function Chart (CFC) into a reusable Function Block (FB):
1. Parsing: The compiler scans all blocks, internal interconnections, and Chart I/Os defined in the chart.
2. Code Generation: It synthesizes a text-based S7-SCL source file stored in the project's S7 Sources folder.
- Child Function Blocks (such as Pcs7DiIn) are instantiated as static multi-instance variables (VAR ... END_VAR).
- Child Functions (such as Or04 / FC364 or Or08 / FC365) are called inline during cyclic execution.
3. Compilation: The internal S7-SCL compiler compiles the generated source text into an executable Function Block (e.g., FB500) and saves it to the block folder.

Root Cause of the Orphaned Assignment (:=) SCL Syntax Error

When the compiler generates SCL statements for standard functions, it produces code according to the pattern:

//-- Block: BlockName
TargetVariable := FC365(In1 := Connection1, In2 := Connection2, ...);

If an error occurs where the generated line reads:

//-- Block: Error (Or08)
:= FC365(In1 := FbkOpen.Bad, ...);

The missing identifier before := triggers SCL compiler error: E: L 01150 C 00007: Unknown statement. This occurs due to two distinct configuration flaws:
* Unassigned or Invalid Return Value: Unlike Function Blocks that store state in instance DBs, an S7 Function (FC) computes a transient return value (RET_VAL) or output parameter. If the output of the FC in the CFC chart is left completely unassigned, or if the block instance name inside the chart conflicts with a reserved S7-SCL keyword (e.g., naming a block Error or Status), the code generator fails to generate a left-hand variable name.
* Type Incompatibility with Chart I/O: If the FC output was routed to an internal Chart I/O whose data type was modified after initial interconnection, the symbolic binding is broken, resulting in an empty token.

Why Compiling APL Blocks as Block Types Breaks WinCC OS Integration

Beyond syntax compilation errors, compiling technological charts containing Advanced Process Library (APL) blocks (such as VlvL, MotL, or PIDConL) into composite block types violates PCS 7 design principles:

Architectural RequirementStandalone APL Blocks in CFCChart Compiled as Block Type (FB)Control Module Type (CMT)OS Compile / Message GenerationS7_m_c := 'true' attributes generate WinCC tags, Alarm Logging messages, and block icons automatically.Internal child blocks lose their individual S7_m_c tags; faceplates cannot target child blocks inside a multi-instance FB.Full individual block attributes preserved; complete WinCC faceplate integration.Online Monitoring and DiagnosticsFull graphical visibility of internal signals, signal status bytes (ST), and interlock paths in CFC test mode.Black-box execution; internal intermediate calculations cannot be viewed graphically in CFC.Full graphical monitoring of every component block in runtime.Library Management and UpdatesDifficult to update multiple independent custom FBs across large plants.Monolithic FBs require CPU full download or memory re-allocation when modified.Centralized synchronization: editing the master CMT propagates updates across hundreds of instances via change download.

Method: Modern Implementation Using Control Module Types (CMT)

To create standardized, reusable equipment modules (e.g., a valve with input channel drivers and multi-input interlocks) without compiling charts into rigid block types, implement Control Module Types:

Step 1: Create the CMT in the Master Library

  1. In SIMATIC Manager, open your project's Master Data Library.
  2. Navigate to the Templates folder, right-click, and select Insert New Object -> Control Module Type.
  3. Name the CMT (e.g., CMT_ValveLean_Advanced).
  4. Double-click the CMT to open it in the CFC editor.

Step 2: Assemble Technological Blocks and Logic

  1. From the APL library catalog, drag the required blocks into the chart:
    - VlvL (FB1899) for the main valve technological logic.
    - Pcs7DiIn (FB1871) for digital inputs (feedback open, feedback closed).
    - Pcs7DiOu (FB1873) for the command output.
    - Or08 (FC365) or standard logic blocks for interlocks.
  2. Interconnect the signal statuses and values (e.g., Pcs7DiIn.Out to VlvL.FbkOpen).
  3. Connect the output of Or08 to the interlock input VlvL.Permit or VlvL.Intlock.

Step 3: Define Control Module Parameters and Signals

  1. Open the Technological Editor in CFC (View -> Technological Editor).
  2. Drag the operational parameters that require external connection or operator visibility (such as field I/O addresses, interlock bypasses, and setpoints) into the Technological Interface pane.
  3. Assign meaningful engineering names to each technological port.

Step 4: Instantiate CMTs Across the Plant Hierarchy

  1. In the Plant View, drag CMT_ValveLean_Advanced into the target plant hierarchy folder (e.g., Plant1/UnitA/Valves).
  2. Assign the instance name (e.g., XV_101).
  3. Connect the field I/O addresses directly to the assigned technological I/O pins.
  4. Execute Options -> Match Control Module Types whenever library updates are applied.

Verification

To confirm that the automation module compiles and functions properly:
- Open the S7 program in SIMATIC Manager and execute Chart -> Compile -> Charts as Program.
- Ensure the compile finishes with 0 Errors and 0 unresolved textual interconnections.
- Execute an OS Compile and verify that WinCC automatically generates the block icon for the valve, links the faceplate, and registers all alarm messages.
- Switch the AS to RUN mode, open the CFC in online Test Mode, and confirm that digital input states propagate through Pcs7DiIn and Or08 to VlvL with correct signal status 16#80 (Good).

Limitations and Operational Precautions

  • CPU Code Memory Sizing: Using Control Module Types instantiates individual function blocks for each technological device. Ensure the CPU work memory and process object (PO) license capacity accommodate the total block count.
  • SCL Source Code Alterations: If legacy constraints mandate compiling a chart to a block type, do not manually edit the generated .SCL source file in the Sources folder unless you plan to maintain it as a pure SCL source; any future "Compile Chart as Block Type" action will overwrite manual text edits.
  • Instance DB Numbering: Assign a dedicated, unreserved block number range (e.g., FB500–FB999) in the chart object properties before compiling to prevent collisions with Siemens system library blocks.

Engineer FAQ

Why did deleting the ':=' token in the SCL source allow it to compile?

Deleting := converted the line from an invalid assignment into a direct subroutine call of the function FC365(...). While this satisfies the SCL syntax checker, the return value of the function is discarded, meaning the output of the OR logic is lost.

Can an FC block have its own instance DB in PCS 7?

No. S7 Functions (FCs) are stateless and do not have instance data blocks. Any block that requires persistent state memory, WinCC operator integration, or alarm timestamps must be written as a Function Block (FB).

What happens to block icons if I embed an APL block inside a compiled block type?

The WinCC OS compiler only detects S7_m_c attributes at the top-level block interface. It cannot traverse multi-instance variables inside a custom composite FB, which causes WinCC to skip generating block icons and faceplates for the internal blocks.

How do I update all instances of a Control Module Type when I modify the template?

Open the Master Data Library, edit the CMT in the template folder, and then run Options -> 'Plant Types' -> Synchronize. The wizard analyzes all project charts and propagates changes without breaking existing field connections.

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: Control Module Engineering).
  • SIOS Entry 109809264: SIMATIC Process Control System PCS 7 Advanced Process Library Manual.
  • Siemens Programming Guideline: Working with S7-SCL and CFC in SIMATIC Process Control.

Related Articles

Related Tags

  • CFC
  • S7-SCL
  • Control Module Type
  • PCS 7
  • APL
  • Compiling
  • Industrial Automation
20 respuestas