Deriving Block Icon Types and Variants for Custom SCL Function Blocks in SIMATIC PCS 7

Deriving Block Icon Types and Variants for Custom SCL Function Blocks in SIMATIC PCS 7

You cannot specify or hardcode the WinCC block icon name directly within SCL (Structured Control Language) source code. In SIMATIC PCS 7, the block icon type is dynamically derived from the function block's symbolic name defined in the Step 7 Symbol Table, while the icon variant is configured per block instance inside CFC. To connect an SCL block to a custom block icon, mark the SCL block header with { S7_m_c := 'true' }, assign a symbolic name (e.g., MonCustom) to the FB in the Symbol Table, create a matching block icon in @PCS7Typicals.pdl with the property type = '@MonCustom/1', and assign variant 1 in the CFC block instance properties. The AS-OS Compiler automatically resolves the link during 'Create/update block icons'.

Table of Contents

Decoupled Architecture: SCL Algorithmic Logic vs WinCC HMI Typography

In SIMATIC PCS 7, the software architecture maintains strict separation between controller execution logic (AS) and operator visualization (OS). Function blocks written in SCL (Structured Control Language) define the mathematical algorithms, state machine transitions, I/O interfaces, and diagnostic routines running within the S7-400 CPU cyclic interrupt OBs.

Engineers developing custom function blocks often look for an SCL pragma or compiler directive to specify which WinCC block icon file or icon name the block should use. No such pragma exists in SCL. A single SCL function block type (such as an agitator or motor controller) may be instantiated hundreds of times across different plant areas, requiring distinct visual representations (e.g., horizontal pump, vertical pump, submerged pump, or compact status icon).

Hardcoding the block icon name in SCL code would destroy visual reusability. Instead, PCS 7 utilizes a three-part association model:

  1. SCL Source Code: Declares OCM capability via system attributes (S7_m_c := 'true').
  2. Step 7 Symbol Table: Establishes the block type identity (FB1250 = MonCustom).
  3. CFC Block Instance Properties: Defines the specific visual variant (Variant 1, 2, 3...) for each individual block call.

Essential SCL Pragmas and Attributes for OCM Capability (S7_m_c)

To enable an SCL function block for Operator Control and Monitoring (OCM) and make it visible to the WinCC AS-OS compiler, specific system attributes must be declared in the SCL source file:

FUNCTION_BLOCK FB1250
TITLE = 'Custom Monitoring Block'
{ 
  S7_m_c := 'true';             // Enables WinCC Tag Compilation
  S7_blockview := 'big';        // Display mode in CFC editor
  S7_tasklist := 'OB100,OB35';  // Pre-allocates execution OBs
}
AUTHOR : 'CieloEng'
FAMILY : 'Custom'
NAME   : 'MonCust'
VERSION: '0.1'

VAR_INPUT
  PV_In { S7_m_c := 'true' } : REAL := 0.0; // Monitored Process Value
  High_Lim { S7_m_c := 'true'; S7_edit := 'para' } : REAL := 100.0;
END_VAR

VAR_OUTPUT
  Alarm_Act { S7_m_c := 'true' } : BOOL := FALSE;
  Status1 { S7_m_c := 'true' } : DWORD := 16#00000000;
END_VAR

Parameters tagged with { S7_m_c := 'true' } are automatically compiled into WinCC OS tags. Parameters without this pragma remain internal to the AS controller.

Symbol Table Naming and Block Type Resolution (@SymbolName)

When the AS-OS compiler searches for a block icon in @PCS7Typicals.pdl, it resolves the block type string using the Symbolic Name assigned to the FB in the Step 7 Symbol Table:

  • If FB1250 is assigned the symbol MonCustom, the compiler constructs the template search prefix as @MonCustom.
  • If the block has no symbolic name in the Symbol Table, the compiler falls back to using the raw block number: @FB1250.
  • In @PCS7Typicals.pdl, the block icon's type attribute must match this prefix exactly: @MonCustom/<Variant>.

Therefore, maintaining rigorous and permanent symbolic naming in the Symbol Table before compiling CFC charts and OS projects is an absolute engineering prerequisite.

Configuring Block Icon Variants Inside CFC Object Properties

Different instances of the same SCL function block can display different graphic icons on the operator screens. This is governed by the Variant Number configured in CFC:

  1. Open the CFC chart hosting an instance of the custom SCL block.
  2. Double-click the block header to open the Object Properties dialog.
  3. In the 'Special Properties' section, confirm that OCM possible is checked.
  4. Check the box 'Create block icon'.
  5. In the numeric field adjacent to 'Create block icon', specify the Variant Number:
    - Enter 1: The compiler looks for an icon with type = '@MonCustom/1' in @PCS7Typicals.pdl.
    - Enter 2: The compiler looks for an icon with type = '@MonCustom/2' (e.g., a compact or vertical representation).
    - Leave blank or 0: The compiler defaults to searching for variant 1 or the base icon @MonCustom.

Comparative Workflow Matrix: SCL to WinCC Block Icon Association

The following table details the engineering roles, tools, and artifacts connecting SCL code to the runtime block icon:

| Engineering Layer | Tool / Artifact | Syntax / Configuration Action | Impact on Block Icon Generation |
|---|---|---|---|---|
| AS Source Logic | SCL Source Editor | { S7_m_c := 'true' } on FB header and I/O pins | Enables block for OS tag compilation |
| Symbol Management | Step 7 Symbol Table | FB1250 -> Symbol: MonCustom | Defines the @SymbolName prefix used for icon matching |
| CFC Instantiation | CFC Editor | Properties > Create Block Icon > Variant 1 | Selects the specific /Variant index for the instance |
| Graphic Template | WinCC Graphics Designer | @PCS7Typicals.pdl -> User Object type = '@MonCustom/1' | Provides visual template and dot-linked attributes |
| Compilation Engine | SIMATIC Manager | Plant Hierarchy > 'Create/Update Block Icons' | Instantiates icon, binds tags, and populates tagname |

Step-by-Step Procedure to Link a Custom SCL Block to a Block Icon

Follow this complete procedure to deploy a custom SCL block with an automated block icon:

  1. Write and Compile SCL Source:
    - Add { S7_m_c := 'true' } to the FB header and relevant inputs/outputs.
    - Compile the SCL source file in SIMATIC Manager. Confirm error-free compilation into the Blocks folder.

  2. Assign Symbol Table Name:
    - Open the S7 Program's Symbols table.
    - Find the compiled FB (e.g., FB1250) and assign a concise, meaningful symbol name (e.g., MonCustom).

  3. Create Icon in @PCS7Typicals.pdl:
    - Open the OS project's Graphics Designer and open @PCS7Typicals.pdl (or custom typical file).
    - Create a Customized Object with property type set to @MonCustom/1.
    - Add dot-notated dynamic properties (e.g., .PV_In, .Status1) and set servernam to PCS7 MonCustom Control.
    - Save the typicals picture.

  4. Place Block in CFC and Assign Variant:
    - Insert the block from the CFC block catalog (Custom family) into a CFC chart.
    - Open Block Properties, enable 'OCM possible', tick 'Create block icon', and set Variant to 1.

  5. Generate Block Icons:
    - In SIMATIC Manager, select the Plant Hierarchy and run Create/Update Block Icons.
    - Open the target process graphic in Graphics Designer and verify that the icon is correctly generated with full tag links.

Verification

Validate the block icon linkage through the following engineering checks:

  1. Open the target WinCC picture in Graphics Designer following block icon generation.
  2. Click the generated block icon and inspect its Object Properties.
  3. Verify that the property type equals @MonCustom/1 and the property tag / tagname contains the exact CFC plant path (e.g., Plant/Unit/Chart/Instance).
  4. Check that dynamic properties (e.g., .PV_In) are resolved to valid WinCC tag names without leading dots.
  5. Launch WinCC Runtime, change the SCL block's inputs in CFC Test Mode or PLCSIM, and confirm that the block icon visually updates in Runtime.

Limitations and Operational Precautions

  • Renaming Symbol After Generation: If the symbolic name in the Symbol Table is changed after CFC charts have been compiled, existing block icons in WinCC pictures will lose their association, causing orphan tags and broken faceplate links.
  • Block Interface Changes: Changing inputs/outputs in SCL code requires re-importing the block type in CFC (Options > Block Types), followed by an AS-OS compile and updating block icons to reconcile interface tags.
  • Strict Syntax in Typicals: The type attribute in @PCS7Typicals.pdl is case-sensitive and must strictly match @<Symbol>/<Variant>. Spaces before or after the slash will cause the compiler to report that no matching block icon was found.

Engineer FAQ

Can I set the faceplate name inside the SCL source code?

No. Faceplate associations are established in the block icon's servernam property inside @PCS7Typicals.pdl or defined via the standard APL naming convention where the system searches for @pg_<BlockSymbol>.pdl.

What happens if I do not assign a variant number in CFC?

If the variant number is left blank or set to 0, the AS-OS compiler searches for @<BlockSymbol>/1 by default. If variant 1 does not exist, the compiler issues a warning and skips icon generation.

Why does CFC Object Properties show 'Create block icon' grayed out?

The checkbox is grayed out if the block does not have { S7_m_c := 'true' } on its FB header or if 'OCM possible' is disabled in the block type attributes.

Can an SCL block have both classic and APL style block icons?

Yes. You can design a classic icon in @PCS7Typicals.pdl and an APL-style icon in @PCS7TypicalsAPLV8.pdl. However, to fully leverage APL features, your SCL block must output standard APL status bitmasks (Status1, Status2, Status3, OS_Perm).

Does compiling the SCL code automatically update the block in CFC?

No. Compiling SCL updates the block in the offline Blocks folder. In CFC Editor, you must select Options > Block Types, select the block from the offline folder, and click -> New Version to update existing instances in the charts.

Technical References

Related Articles

Related Tags

  • SCL
  • Block Icons
  • S7_m_c
  • Symbol Table
  • CFC Engineering
  • AS-OS Compiler
  • @PCS7Typicals
6 respuestas