Forcing CFC to Generate Internal Tags via OS Compilation

David Krause15 min read
HMI ProgrammingSiemensTechnical Reference
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: CFC Blocks and the OS Compilation Tag Pipeline

Continuous Function Chart (CFC) is the graphical programming language used in SIMATIC PCS 7 to interconnect function blocks, I/O signals, and operator faceplates. When a CFC chart is compiled for the operator station (OS), the PCS 7 OS compilation engine walks every block instance in the chart, reads the block type's interface description, and emits WinCC internal tags that the faceplate and standard views later bind to at runtime. By default, only a small set of administrative attributes is exposed: the block instance comment (#comment) and the block type name (#blocktype). Engineers who need richer metadata — for example a free-form description, an engineering unit string, a vendor object code, or a localized operator hint — must either enrich the block type with S7 attributes or accept that those values will be written into the OS through external WinCC text tags.

This reference describes the supported mechanism for forcing the OS compiler to materialize additional internal tags from CFC block I/O: declaring S7_shortcut and S7_unit attributes on the desired I/O of the function block (FB), then editing the values from the CFC editor. It also covers the limitations imposed by the PCS 7 licensing model and the supported fallback path through the WinCC tag table.

Scope note. The attribute-driven tag generation mechanism described here is specific to the SIMATIC PCS 7 OS compilation pipeline (CFC → WinCC). It does not apply to TIA Portal HMI tag generation in the same way; the TIA Portal flow creates HMI tags through the HMI tag table, not through FB attributes. See the Siemens support entry 109747174 for the TIA Portal HMI tag creation flow on Basic Panels, Panels, and Comfort Panels.

2. Standard Internal Tags Generated by CFC OS Compilation

When a CFC chart is compiled to the OS, the compiler creates a fixed set of internal tags for every block instance. The two attributes that are always exported are:

  • #comment — the instance comment text entered in the CFC editor on the block's "Comment" property. This tag is used by faceplate tooltips and the standard block icon header.
  • #blocktype — the symbolic block type name (FB name) of the instance. This tag is used by WinCC picture objects that switch on block type to render the correct faceplate type.

These two tags are sufficient for the base faceplate mechanic but are rarely enough for a production operator screen. Engineers typically want additional text references that describe:

  • Object code (a.k.a. KKS or tag ID)
  • Object description (long-form operator label)
  • Engineering unit (e.g. bar, °C, m³/h)
  • Vendor part number or device serial
  • Loop number, area, or plant section
  • Localizable operator messages

The OS compiler will only emit a tag for an I/O point if the FB has been authored with the corresponding S7 attribute. This is the central constraint: tag generation is a property of the block type, not a project-wide switch.

3. The S7_shortcut Attribute for Custom Text Tags

The S7_shortcut attribute is the primary lever for forcing the OS compiler to emit a text-reference internal tag. It must be declared on the desired I/O of the FB in the FB source (typically an STL/SCL source compiled with STEP 7 / CFC, or an imported F-block from the PCS 7 APL library).

Attribute declaration syntax (STEP 7 V5 / PCS 7 V9.x style):

FUNCTION_BLOCK FB_MyBlock
VERSION : '1.0'
  VAR_INPUT
    i_Value : REAL;       // S7_shortcut:='MyValue';
    i_Text  : STRING[32]; // S7_shortcut:='MyText';
  END_VAR
  VAR_OUTPUT
    o_State : BOOL;       // S7_shortcut:='State';
  END_VAR
BEGIN
  // body
END_FUNCTION_BLOCK

Once the attribute is compiled into the FB, every instance of FB_MyBlock exposes the Identifier property in the CFC editor's I/O properties dialog. The Identifier field is freely editable per instance, and the string you enter becomes the value of the internal WinCC tag after OS compilation.

Behavior in the OS compiler:

  • If the I/O is declared S7_shortcut:='MyText' and the Identifier field is left empty, the tag is still created but carries an empty string.
  • If the attribute is not declared on the I/O, the Identifier field is hidden in the CFC editor and no tag is generated.
  • The attribute name as it appears in the FB source is case-insensitive in the CFC editor but the tag suffix in WinCC exactly matches the attribute string value.
License impact. Each S7_shortcut-driven tag counts against the WinCC internal tag license. The PCS 7 licensing model is a known friction point when many custom text tags are generated per instance; see Section 8.

4. The S7_unit Attribute for Engineering Units

The S7_unit attribute is a special-cased variant that the OS compiler treats as a unit-of-measure string. It is rendered by standard faceplates next to the process value and is also exposed as a WinCC text tag for use in user graphics.

Declaration:

VAR_INPUT
  i_Pressure : REAL;  // S7_unit:='bar';
END_VAR

The CFC editor displays this as the Unit property on the I/O. The value can be edited per instance (for example, a transmitter calibrated in psi rather than bar on one loop) and the modified string is what the OS compiler writes into the generated internal tag.

Typical uses of S7_unit:

  • Process value units in standard APL faceplates (CTRL, MOT, VAL, ANA, DIG, etc.)
  • Setpoint limit units in controller faceplates
  • Counter rate units in dosing blocks

The unit string is purely cosmetic from a control standpoint — it is not used in any conversion. If the underlying engineering is in raw counts and you display "°C", the conversion must happen inside the block or in a preceding CALC block.

5. Defining Custom S7 Attributes for Parameterized Tags

Beyond the standard S7_shortcut and S7_unit, the STEP 7 attribute mechanism allows additional S7_* attribute names to be attached to I/O. The PCS 7 OS compiler, however, only knows how to materialize internal tags for a fixed allow-list of attribute names. The two attributes that drive WinCC tag generation are:

Attribute OS Compiler Behavior WinCC Tag Created
S7_shortcut:='XYZ' Always emitted as text-reference tag Internal tag with suffix matching attribute string
S7_unit:='XYZ' Always emitted as unit text tag Internal tag treated as unit string
Any other S7_* Ignored by OS compiler for tag generation No WinCC tag created

This is the reason an engineer who wants a Description, ObjectCode, or VendorPn tag must either alias the request onto one of the two supported attribute names (a misuse, since S7_shortcut is a short identifier and not a free-form description) or use a different mechanism — typically the WinCC text-variable system or a custom faceplate with internal tags declared directly in WinCC.

If you need more than two per-block text references, the supported approach is to chain FBs so that each FB exposes its own S7_shortcut tag, then aggregate the strings in the consuming faceplate using WinCC dynamic dialog or C scripting.

6. Step-by-Step Configuration in the CFC Editor

  1. Open the FB source. In SIMATIC Manager, navigate to the master data library of your project, open the S7 program, and double-click the FB that should expose the extra text tag. If the FB is a PCS 7 APL block, copy it into a project master data library first — do not edit the read-only library version.
  2. Add the S7 attribute. In the FB source (STL or SCL), locate the desired I/O declaration and append the comment line that carries the attribute. For SCL:
    i_LoopTag : STRING[32];  // S7_shortcut:='LoopTag';
  3. Compile the FB source. Save the source, then run "Generate block type" so the new attribute is baked into the compiled FB in the S7 program.
  4. Update the CFC chart. In the CFC editor, place (or re-import) an instance of the modified FB. Right-click the I/O pin, choose "Object Properties", and confirm that the Identifier field is now visible.
  5. Enter the value. Type the desired text (e.g. P-1101A) into the Identifier field. Click OK.
  6. Compile the CFC chart to the OS. Use "Charts → Compile → OS" (or the project-wide "Compile OS" from the plant view). The OS compiler reads the attribute and emits a WinCC internal tag of the configured name.
  7. Verify in WinCC Explorer. Open the WinCC project that the OS compile wrote to, navigate to the internal tag folder, and confirm the new tag is present with the expected string value.
Tip. Always run a full OS download of the WinCC project after the tag is generated, not just a delta load — WinCC internal tag additions sometimes require a server restart before the faceplate bindings pick them up reliably.

7. OS Compilation Workflow and WinCC Tag Generation

The PCS 7 OS compilation pipeline is a multi-pass process:

  1. Chart compile (AS). CFC is compiled to the automation station, generating the STL code for the S7-400 CPU.
  2. OS compile (AS → OS). The OS compile step reads the chart-level block instance data, walks the FB type library, and writes a structured intermediate file that the WinCC project importer consumes.
  3. WinCC tag import. WinCC Explorer imports the intermediate file and creates the internal tags under the configured tag prefix (default: the AS name).
  4. Faceplate regeneration. The faceplate designer regenerates the instance-specific faceplates referenced by the chart. The new tag is bound to the corresponding faceplate property.

If the tag does not appear after step 3, the most common reasons are: (a) the FB was not recompiled after the attribute was added; (b) the chart was not re-OS-compiled; (c) the FB is from a locked library and the attribute was added to a local copy that is not the version the chart actually instantiates; (d) WinCC is in runtime and a delta load silently rejected the new tag without surfacing the error.

For TIA Portal projects that do not use PCS 7 CFC, the equivalent flow is to open the HMI tag table and create internal tags manually — see the Siemens ID 109747174 article for the TIA Portal procedure. For WinCC Unified (TIA Portal V17+), internal tags are configured under "HMI tags → Internal tag" and behave like variables local to the HMI runtime — see the WinCC Unified V20 tag configuration guide.

8. Licensing Model Constraints

The PCS 7 runtime license for WinCC is sized by the count of internal tags and external tags that the OS imports. Every S7_shortcut and S7_unit attribute that produces a populated tag value adds to that count. Engineers who want a large number of descriptive tags per block (e.g. ten text fields per motor block across 500 motors) will quickly exhaust the license envelope.

Practical workarounds used in production plants:

  • Reduce the number of S7_shortcut attributes per FB to the minimum required (typically 1–2) and consolidate the rest into the standard #comment tag, using a delimiter (e.g. ObjectCode | Description | VendorPn) and splitting on the delimiter inside the faceplate C script.
  • Move descriptive text out of the OS and into the PCS 7 Asset Management / Maintenance Station, where it is not counted against the runtime license.
  • Use the WinCC TextVariable concept for translatable operator hints; TextVariables are stored once and referenced by ID, so they scale better than per-instance internal tags.
  • Use derived signal tags in the AS (e.g. a STRING[80] output of a CALC block that concatenates object code, description, and unit) and expose that single string via one S7_shortcut tag. The faceplate then splits and renders the substring.

Before adding a new S7_shortcut attribute, estimate the cumulative impact. For a plant with 2,000 control loops, each carrying three custom text tags, the per-tag license multiplier is 6,000 internal tags on top of the standard process value tags.

9. Alternative: External WinCC Text Tags

When the attribute mechanism does not fit (too many tags, wrong attribute name, or no access to the FB source), the supported alternative is to declare the text as an external WinCC text tag. A text tag in WinCC is a STRING-typed internal variable that the faceplate designer can read directly.

  1. Open the WinCC Explorer of the OS project.
  2. Right-click the internal tag folder and choose "New Tag".
  3. Set the data type to TEXT (8-bit character string) or STRING[32] / STRING[80] depending on the maximum length needed.
  4. Name the tag following your project naming convention (e.g. Text_P1101A_Description).
  5. Populate the initial value in the tag properties, or use a startup script to load the values from a CSV at OS startup.
  6. Reference the tag from the faceplate via the tag-prefix mechanism, or wire it to a dynamic dialog in a user graphic.

This approach decouples the text lifecycle from the CFC compile cycle, so text edits do not require an OS recompile. The trade-off is that the text is no longer a property of the block instance — moving a chart from one OS to another does not move the text. For text that is tightly bound to the function (object code, unit), attribute-driven generation is preferred; for text that is environment-specific (operator names, shift notes), WinCC text tags are preferred.

10. Cross-Platform Note: CFC in Beckhoff TwinCAT

The CFC editor also exists in the Beckhoff TwinCAT 3 environment, where it is a different product with a different tag-generation pipeline. The TwinCAT CFC editor wires programming blocks together and exposes a structured view of the resulting data flow, but the runtime tag generation happens through the TwinCAT IO configuration and PLC HMI web visualization rather than an OS compile step. See the Beckhoff Information System entry on Programming in CFC for the TwinCAT flow. The Siemens S7_shortcut / S7_unit attribute pattern does not apply to TwinCAT CFC and should not be ported verbatim — TwinCAT uses {attribute '...'} pragmas for similar purposes, and the HMI binding is done through the IoDriver / PLC HMI extension.

11. Troubleshooting Matrix

Symptom Likely Root Cause Corrective Action
Identifier field missing in CFC I/O properties FB source was not recompiled after adding the S7_shortcut comment Re-save the STL/SCL source, then run "Generate block type". Refresh the chart instance by deleting and re-inserting it.
Identifier field present but no tag appears in WinCC after OS compile Chart was not OS-compiled, only AS-compiled Run "Charts → Compile → OS" (or the project-wide "Compile OS") and re-download the WinCC project with a full transfer.
Tag appears in WinCC but the value is empty Identifier field was left blank in the CFC instance Enter the desired string in the Identifier field of the instance and re-OS-compile.
Tag count exceeds the license limit Too many S7_shortcut/S7_unit attributes per FB, scaled by instance count Consolidate text into one delimited string per instance and split in the faceplate, or move text to WinCC text tags.
Tag is created but faceplate does not display it Faceplate was not regenerated after OS compile Run "Generate faceplates" in the plant view, then re-download the OS picture tree.
Custom attribute (e.g. S7_objectcode) declared but no tag generated OS compiler only honors S7_shortcut and S7_unit for tag emission Rename the attribute to S7_shortcut (and accept that the naming semantics are repurposed), or move the data to WinCC text tags.
Tag appears with truncated or wrong characters FB I/O is STRING[n] with n too small for the configured text Increase the STRING length in the FB source, recompile, and re-OS-compile.
Delta OS download silently drops the new tag WinCC runtime was not restarted; delta loader cannot insert a new internal tag while the server holds an open handle to the tag set Stop the WinCC runtime on the affected server, perform a full project transfer, then restart runtime.

12. Engineering Best Practices

  • Document the attribute contract. Add a comment in the FB source describing what each S7_shortcut field is for. Engineers who later inherit the block need to know whether "Identifier" means object code, description, or unit.
  • Use a delimiter strategy. When you need more than two text references per block and license headroom is tight, store them in a single S7_shortcut STRING[80] with a delimiter (e.g. |) and parse in the faceplate. This keeps the tag count flat regardless of the number of sub-fields.
  • Localize at the faceplate, not in the tag. Storing English strings in S7_shortcut tags and translating in the faceplate's text library is more maintainable than storing localized strings per instance.
  • Version-control FB sources. Changes to FB attributes are silent — there is no PCS 7 audit trail of attribute changes. Keep the FB source in SVN/Git and review attribute changes like any other code change.
  • Validate in a sandbox OS first. A new attribute that produces hundreds of new tags can push the project over the license limit. Compile into a sandbox OS, check the tag count, then promote to production.

13. Verification Checklist

After applying the configuration above, verify the following before signing off:

  • The FB source contains the S7_shortcut (or S7_unit) comment on the correct I/O.
  • The FB has been re-generated in the S7 program and the new attribute is visible in the FB's interface view in SIMATIC Manager.
  • The CFC instance I/O properties dialog shows the Identifier (or Unit) field.
  • A non-empty value has been entered in the Identifier (or Unit) field of the test instance.
  • The CFC chart has been OS-compiled (not only AS-compiled).
  • WinCC Explorer shows the new internal tag with the expected string value.
  • The faceplate for the block type has been regenerated and downloaded.
  • The OS runtime displays the new string in the expected location of the faceplate.
  • The total internal tag count is still within the WinCC license envelope.

14. FAQ

Can the OS compiler generate internal tags from arbitrary S7 attributes?

No. The PCS 7 OS compiler only honors S7_shortcut (for text-reference tags) and S7_unit (for engineering-unit text tags) when emitting internal WinCC tags. Any other S7_* attribute is ignored for tag generation, even if declared correctly on the I/O.

How many custom text tags can a single CFC block instance expose?

In theory as many as there are I/O points with S7_shortcut or S7_unit attributes. In practice the limit is the WinCC internal tag license, which counts every emitted tag. For plants with many instances, consolidate multiple sub-fields into one delimited string tag and parse on the faceplate.

Does changing the Identifier in the CFC instance require an OS recompile?

Yes. The string entered in the Identifier field is read only at OS compile time. Editing the Identifier without re-OS-compiling leaves the WinCC tag value at its previous content. A full WinCC project transfer is also recommended.

What is the difference between an internal WinCC tag and a text variable?

An internal tag is a per-instance STRING variable that lives in the WinCC tag database. A text variable is a centralized STRING dictionary that is referenced by ID; many faceplates can reference the same text by ID, so text variables scale better for translatable operator hints. Both are valid tools and are often used together.

Does the S7_shortcut mechanism work in TIA Portal HMI projects?

No. TIA Portal does not use the CFC OS-compile pipeline. HMI tags in TIA Portal are created through the HMI tag table (internal tags) or the PLC tag table (external tags). For WinCC Unified, see the WinCC Unified V20 internal tag configuration guide.

Back to blog