Why S7_xm_c Structure Tags Fail in Shared Data Blocks but Work in Function Blocks in PCS 7

Why S7_xm_c Structure Tags Fail in Shared Data Blocks but Work in Function Blocks in PCS 7

In SIMATIC PCS 7 (including V9.0 SP1), configuring the compound User-Defined Attribute S7_xm_c := 'Value,true;' on structured variables inside a global Shared Data Block (DB) fails to generate subfield tags during OS compilation because the STEP 7 DB compiler does not support S7_xm_c parsing on global shared DBs. The OS compiler's structure generator (s7tgtopx.exe) only evaluates S7_xm_c attributes when declared within the formal interface of a Function Block (FB) and its associated instance data block. To expose structured process values to WinCC, engineers must encapsulate the structured data within an FB, flatten the shared DB into elementary scalar tags (REAL, BOOL) with standard S7_m_c := 'true', or manually create structure tags in WinCC.

Table of Contents

Architectural Difference: Shared DBs vs Function Block Interfaces

A foundational architectural tenet of SIMATIC PCS 7 is encapsulation: all automation entities are engineered as autonomous Function Blocks (FBs) with dedicated instance Data Blocks (DBs) managed within Continuous Function Charts (CFC).

However, engineers migrating from classic STEP 7 or building custom interface arrays frequently create global Shared Data Blocks (e.g., DB4) and attempt to define structured variables (such as custom analogs containing Value: REAL and ST: BYTE) using PCS 7 Operator Communication and Monitoring (OCM) attributes:
* { S7_m_c := 'true' } on the DB header.
* { S7_m_c := 'true'; S7_xm_c := 'Value,true;' } on the STRUCT variable.

When opening Special Object Properties -> Operator Control and Monitoring on the shared DB, the engineer observes that the WinCC Attributes tab lists scalar elements, but completely omits all sub-elements of the structure. When the OS is compiled, structure tags are not generated in WinCC Tag Management.

Why the OS Compiler Ignores S7_xm_c in Shared Data Blocks

The failure is governed by internal compiler limitations in STEP 7 V5.x and the PCS 7 OS compiler:

Object TypeS7_m_c (Scalar Variables)S7_xm_c (Structure Subfields)Compiler Evaluation MechanismFunction Block (FB / Instance DB)SupportedFully SupportedSCL/CFC compiler generates formal type descriptors parsed by s7tgtopx.exeShared Global Data Block (DB)SupportedUNSUPPORTEDDB compiler parses flat symbols; ignores structure sub-attributesUser Data Type (UDT)Supported on scalarsIgnored inside UDT definitionMust be instantiated in FB interface to evaluate S7_xm_c

The DB compiler treats the entire STRUCT within a shared DB as a single opaque block of memory. It does not parse the compound S7_xm_c attribute string down into individual child tags. The sub-element parser is explicitly hardcoded only for Function Block parameter interfaces (VAR_INPUT, VAR_OUTPUT, VAR_IN_OUT).

Demonstration: FB Success vs DB Failure Syntax

The behavior can be verified by comparing identical declarations in S7-SCL:

  1. Shared DB Declaration (Fails to Generate Struct Tags in WinCC):
    scl DATA_BLOCK DB4 TITLE = 'Shared DB Example' { S7_m_c := 'true' } STRUCT Analog { S7_m_c := 'true'; S7_xm_c := 'Value,true;' } : STRUCT Value : REAL; ST : BYTE; END_STRUCT; END_STRUCT; BEGIN END_DATA_BLOCK
    Result: OS compile generates zero tags for Analog.Value.

  2. Function Block Declaration (Succeeds 100%):
    scl FUNCTION_BLOCK FB5 TITLE = 'FB Example' { S7_m_c := 'true' } VAR_OUTPUT Analog { S7_m_c := 'true'; S7_xm_c := 'Value,true;' } : STRUCT Value : REAL; ST : BYTE; END_STRUCT; END_VAR BEGIN Analog.Value := 50.0; END_FUNCTION_BLOCK
    Result: When instantiated in CFC, OS compile automatically generates <ChartName>/<Instance>.Analog#Value in WinCC Tag Management.

Recommended Engineering Workarounds for PCS 7

If structured process values must be transferred to WinCC:

  1. Encapsulate in a Function Block (Recommended Best Practice):
    - Create a simple S7-SCL Function Block representing the equipment or data buffer.
    - Declare the structured outputs using S7_m_c and S7_xm_c.
    - Instantiate the FB in a CFC chart.
    - OS compile handles all structure tag creation automatically without errors.
  2. Flatten Shared Data Block Variables:
    - If a shared DB must be used, avoid nested STRUCT definitions.
    - Declare variables as flat elementary scalars:
    scl Analog_Value { S7_m_c := 'true' } : REAL; Analog_ST { S7_m_c := 'true' } : BYTE;
    - Both variables appear cleanly in the WinCC Attributes tab and compile into WinCC.
  3. Manual WinCC Tag Management: Create a custom Structure Type manually in WinCC Tag Management and bind it to the absolute DB offset (DB4.DBD0).

Verification

To verify structure tag behavior:
1. In S7-SCL, compile the test FB with S7_xm_c := 'Value,true;'.
2. Instantiate the FB in a test CFC chart.
3. Run Compile OS (Changes only).
4. Open WinCC Explorer -> Tag Management -> Named Connections; verify that the structure tag appears under the AS connection.
5. In Graphics Designer, bind an I/O field to the tag; verify live runtime value display.

Limitations and Operational Precautions

Never rely on manually mapped absolute WinCC tags for shared DBs in projects undergoing active development. If another engineer edits the shared DB and inserts new variables, absolute byte offsets shift, corrupting all manually mapped WinCC tags. Always follow the PCS 7 paradigm by encapsulating structured telemetry inside Function Blocks.

Engineer FAQ

Can S7_xm_c be used on User Data Types (UDTs)?

You cannot declare S7_xm_c inside the UDT source itself. However, when you instantiate the UDT as a variable in a Function Block interface, you can apply S7_xm_c to that parameter.

Why does Siemens restrict S7_xm_c to Function Blocks?

Because PCS 7 engineering automation is built entirely around object-oriented block instances in CFC. Shared DBs are considered legacy artifacts outside the standard APL methodology.

What happens if I forget the trailing semicolon in S7_xm_c inside an FB?

Omitting the trailing semicolon (e.g., writing 'Value,true' instead of 'Value,true;') triggers a UDA syntax parsing error during block type update.

Technical References

Related Articles

Related Tags

  • S7_xm_c
  • S7_m_c
  • Shared DB
  • Function Block
  • WinCC Structure Tags
6 respuestas