Configuring S7_m_c and S7_xm_c Attributes for Custom Structured Blocks in PCS 7

Configuring S7_m_c and S7_xm_c Attributes for Custom Structured Blocks in PCS 7

In SIMATIC PCS 7 V9.0, automatically generating WinCC tags during OS compilation for custom S7-SCL function blocks with structured outputs requires configuring both S7_m_c and S7_xm_c User-Defined Attributes (UDA) with strict syntax compliance. While S7_m_c := 'true' flags the block and elementary variables for Operator Communication and Monitoring, structured types (such as APL structures AnaVal or DigVal) require the compound attribute S7_xm_c := 'Value,true;'. The UDA parser in CFC strictly demands a trailing semicolon inside the string and forbids whitespace between identifiers and parameters; omitting the semicolon or adding spaces triggers compiler errors such as "UDA key Out1: 'Value,true' is not a correct block UDA value".

Table of Contents

Role of OCM Attributes in Automated WinCC Tag Generation

One of the defining architectural capabilities of SIMATIC PCS 7 is automated engineering: rather than manually creating tags in WinCC and mapping them to data block addresses, the PCS 7 OS compiler scans the S7 Program and automatically creates WinCC tags, structure tags, and alarm messages.

This automation is governed by system attributes embedded in block source code:
* { S7_m_c := 'true' }: Operator Communication and Monitoring (OCM). When applied to a Function Block (FB) header and individual parameters, it instructs the compiler to expose the block instance and variables to WinCC.
* When engineers create custom blocks in S7-SCL—such as mathematical calculation blocks, custom signal converters, or signal conditioners—they must declare these attributes correctly so the OS compiler generates WinCC tags without consuming unnecessary Process Objects (PO) or requiring manual tag creation.

Elementary vs Structured Parameter Attributes (S7_m_c vs S7_xm_c)

In the Advanced Process Library (APL), variables are rarely simple primitives (like REAL or BOOL); they are structured types containing both the value and an IEEE 754 quality code (such as AnaVal containing Value: REAL and ST: BYTE):

Parameter TypeS7-SCL Declaration ExampleRequired UDA Attribute StringResult in WinCC OS CompileFB HeaderFUNCTION_BLOCK FB2001 { S7_m_c := 'true' }None (Block level OCM)Enables block instance for OS compilationElementary ScalarOutReal { S7_m_c := 'true' } : REAL;S7_m_c := 'true'Generates standard 32-bit floating point tagElementary BooleanOutBin { S7_m_c := 'true' } : BOOL;S7_m_c := 'true'Generates binary tagAPL Structure OutputOutAna { S7_m_c := 'true'; S7_xm_c := 'Value,true;' } : AnaVal;S7_xm_c := 'Value,true;'Generates structure tag exposing the Value subfieldMultiple SubfieldsLimit { S7_m_c := 'true'; S7_xm_c := 'High,true;Low,true;' } : StructHigh,true;Low,true;Generates structure tag exposing both subfields

When an output parameter is a STRUCT, simply declaring S7_m_c := 'true' is insufficient because WinCC needs to know which specific elements within the structure are to be compiled as tags.

Strict Syntax and Whitespace Rules in User-Defined Attributes

The Step 7 and CFC compiler utility responsible for parsing User-Defined Attributes (s7cfcx.dll) employs a strict lexical analyzer. Any deviation from the required syntax results in the compilation error: UDA key Out1: 'Value,true' is not a correct block UDA value.

Engineers must adhere to two absolute syntax rules:
1. Mandatory Trailing Semicolon: Every parameter assignment inside the S7_xm_c string literal must end with a semicolon ; before the closing quote:
- Correct: S7_xm_c := 'Value,true;'
- Incorrect: S7_xm_c := 'Value,true' (Causes UDA parse failure)
2. Zero Whitespace Rule: Whitespace characters (spaces or tabs) are strictly forbidden within the attribute string:
- Correct: S7_xm_c := 'High,true;Low,true;'
- Incorrect: S7_xm_c := 'High, true; Low, true;' (Spaces after commas or semicolons cause UDA key syntax rejection)
- The same whitespace restriction applies to parameter attributes like S7_xedit := 'High,para;Low,para;'.

Step-by-Step Implementation in S7-SCL and CFC Block Update

To create a custom block with structured outputs that compile cleanly into WinCC:

  1. Write S7-SCL Source:
    scl FUNCTION_BLOCK FB2050 TITLE = 'Custom Signal Converter' { S7_m_c := 'true' } VAR_OUTPUT OutAna { S7_m_c := 'true'; S7_xm_c := 'Value,true;' } : AnaVal; RunState { S7_m_c := 'true' } : BOOL; END_VAR BEGIN OutAna.Value := 123.45; OutAna.ST := 16#80; // Good quality RunState := TRUE; END_FUNCTION_BLOCK
  2. Compile S7-SCL Source: In S7-SCL editor, click File -> Compile. Verify zero errors.
  3. Update Block Types in CFC:
    - Open SIMATIC Manager.
    - Navigate to the S7 Program -> Charts folder.
    - Select Options -> Update Block Types....
    - Select FB2050 and complete the update wizard.
  4. Compile OS:
    - Select the OS project -> click Compile.
    - Select Changes only.
    - Upon completion, open WinCC Explorer and inspect Tag Management; the custom tag appears under the AS connection automatically.

Verification

To verify that the custom structured tags compiled successfully:
1. In WinCC Explorer, expand Tag Management -> SIMATIC S7 Protocol Suite -> Named Connections.
2. Locate the chart folder where the block is instantiated; confirm that a WinCC tag named <ChartName>/<BlockInstance>.OutAna#Value exists.
3. Activate WinCC Runtime; create an I/O field linked to the tag and confirm that the live value updates accurately.
4. Verify in SIMATIC Manager Process Object View that no spurious AS RT PO licenses were consumed.

Limitations and Operational Precautions

Never create WinCC tags manually by typing absolute DB addresses for CFC block instances (e.g., DB102.DBD4). During a full CFC compilation or project reorganization, the Step 7 compiler dynamically rearranges and renumbers instance data blocks, instantly breaking all manually mapped WinCC tags. Always rely on the automated OCM mechanism (S7_m_c / S7_xm_c).

Engineer FAQ

Why did my custom block cause a UDA key syntax error during block update?

You either omitted the mandatory trailing semicolon inside the attribute string (e.g., writing 'Value,true' instead of 'Value,true;') or included blank spaces between parameters.

Does adding S7_m_c to a custom block consume a Process Object (PO)?

A block only consumes an AS RT PO if it generates operator messages (Alarm_8P) or is assigned a block icon with WinCC control properties. Simple mathematical calculation blocks exposing tags without alarms do not consume POs.

Can S7_xm_c expose the Quality Code (ST) byte to WinCC?

Yes. By declaring S7_xm_c := 'Value,true;ST,true;', both the floating-point value and the status byte will be generated as WinCC tags.

Technical References

Related Articles

Related Tags

  • S7-SCL
  • S7_m_c
  • S7_xm_c
  • WinCC Tags
  • OCM Attributes
6 respuestas