Displaying Siemens WinCC Tag Comments in HMI Runtime
Overview
Engineers designing Siemens WinCC HMI screens frequently need to display the descriptive comment (or "description") associated with an HMI tag directly in runtime. In TIA Portal, every HMI tag carries a Comment column in the tag table that documents the process variable, but WinCC runtime does not expose this metadata as a bindable property. The result is a common commissioning problem: the tag table shows "Main line gas pressure" next to PT123, yet the faceplate on the screen cannot pull that text dynamically when the operator clicks the value.
This guide documents the practical engineering approaches for surfacing tag comments in WinCC Professional, WinCC Unified, and WinCC V7/V8, including VBScript-based workarounds, text-list mappings, faceplate properties, and database queries. It also covers the Wonderware InTouch alternative briefly for cross-platform evaluation.
{TagName.Comment} or PT123.comment in standard WinCC runtime environments. All known methods use indirect techniques.Prerequisites
- Siemens TIA Portal V17 or later (for WinCC Professional / Unified).
- WinCC V7.5 SP2 or later, or WinCC V8.0 (for classic runtime scenarios).
- HMI tags configured in the project with descriptive comments populated in the tag table.
- WinCC Engineering Station with the VBScript editor enabled.
- For database methods: SQL Server knowledge and read access to the WinCC configuration database.
- For faceplate methods: WinCC Professional or Unified with faceplate licensing.
Why Tag Comments Are Not Directly Accessible in WinCC Runtime
The WinCC runtime engine stores HMI tag values in a high-speed process image for polling cycles in the 100 ms to 1 s range. Tag metadata, including the comment string, is compiled into the project and lives in the engineering database rather than the runtime image. There is no SmartTags("PT123").Comment property in WinCC Professional, and HMIRuntime.Tags("PT123").Comment is not exposed in WinCC V7 VBScript.
Three architectural reasons drive this limitation:
- Process image isolation: The runtime process image contains only the current value, quality code, and timestamp. Adding metadata would increase memory footprint per tag by 50 to 200 bytes, which scales poorly for projects with 10,000+ tags.
- Localization workflow: Comments in TIA Portal feed the text library and are exported for translation. Runtime access would conflict with the multi-language export pipeline.
- Read-only engineering data: The engineering database is opened in exclusive mode by TIA Portal during compilation, so runtime cannot query it directly without file-locking issues.
Method 1: Parallel Comment Tags (Simplest Approach)
The most reliable engineering method is to create a second HMI tag whose value contains the comment text, and bind that tag to a text field on the screen. This avoids scripting entirely and works in every WinCC edition.
Step-by-Step Procedure
- In the TIA Portal project tree, expand
HMI Tagsand open the tag table. - For each process tag (e.g.,
PT123), add a new tag namedPT123_Commentwith the following properties:- Data type:
WString(Unicode, supports 256+ characters). - Length: 254 characters.
- Connection: Internal tag (no PLC address).
- Start value: the comment text, e.g.,
Main line gas pressure.
- Data type:
- On the screen, insert an IO field or Text field and configure the Process value to
PT123_Comment. - Disable operator input on the IO field (Properties → Appearance → Mode: Output only).
- Compile and download to the HMI runtime.
Parameter Table
| Parameter | Recommended Value | Notes |
|---|---|---|
| Tag name | <OriginalTag>_Comment | Naming convention for clarity |
| Data type | WString[254] | Unicode; supports most engineering symbols |
| Acquisition cycle | None (internal) | No polling overhead |
| Update method | Manual at compile time | Change only during engineering |
Method 2: VBScript in WinCC Professional
WinCC Professional exposes the SmartTags collection for runtime values, but the comment metadata is not available through this interface. A viable runtime workaround is to populate a comment tag through VBScript when a faceplate opens, using a Select Case structure that mirrors the tag table.
Example VBScript for Faceplate Tag Comments
' VBScript: PopulateCommentTags
' Triggered by the "Open" event of a faceplate instance
Sub PopulateCommentTags(ByVal sSignalName)
Dim sComment
Select Case sSignalName
Case "PT123"
SmartTags("PT123_Comment") = "Main line gas pressure"
Case "FT201"
SmartTags("FT201_Comment") = "Compressor discharge flow"
Case "LT450"
SmartTags("LT450_Comment") = "Storage tank level"
Case Else
SmartTags("<Unknown>_Comment") = "No description available"
End Select
End Sub
Triggering the Script
- Open the faceplate in the WinCC screen editor.
- Add a faceplate property
SignalNameof typeString. - On the "Open" event, configure
PopulateCommentTags(SignalName)as the VBScript action. - On the screen, when you instantiate the faceplate, set
SignalName = "PT123".
VBScript Limitations in WinCC
| Limitation | Impact | Mitigation |
|---|---|---|
| No comment metadata API | Manual case-by-case mapping | Generate case branches from tag table export |
| Script execution latency | 50 to 200 ms on faceplate open | Pre-compute comments on screen load |
| No multi-language runtime switch | Hard-coded strings | Use text library references instead |
Method 3: Text Lists for Discrete Signal Sets
If the tag list is small (typically 10 to 50 distinct signals) and known at engineering time, a Text list in TIA Portal can map tag values to descriptive strings. The list entries can include comment-like text, and you can switch the configured list dynamically using a script.
Procedure
- In TIA Portal, open
HMI → Text and Graphic Lists → Text Lists. - Create a text list named
SignalDescriptions. - Add entries:
0 = "PT123 - Main line gas pressure",1 = "FT201 - Compressor discharge flow", and so on. - On the screen, insert a Symbolic IO field with the
Listproperty set toSignalDescriptions. - Bind the Process value to a tag that the operator controls (e.g., a selection index).
For multi-language support, populate the text list translations in Project Languages → Text Library. Each list entry supports per-language text up to 254 characters.
Method 4: Database Query in WinCC V7 / WinCC V8
WinCC V7 stores tag metadata in SQL Server. The configuration database contains the MCPTagConfig table where the Comment field is exposed. You can read this field from runtime VBScript using ADO and the WinCC OLE DB provider.
ADO Connection String and Query
' WinCC V7 VBScript: ReadTagComment
Function ReadTagComment(ByVal sTagName)
Dim conn, rs, sSQL, sComment
sComment = ""
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = _
"Provider=SQLOLEDB;Data Source=(local)\WinCC;" & _
"Initial Catalog=CC_Engineering_<ProjectName>;" & _
"Integrated Security=SSPI"
conn.Open
sSQL = "SELECT Comment FROM MCPTagConfig WHERE TagName = '" & sTagName & "'"
Set rs = conn.Execute(sSQL)
If Not rs.EOF Then
sComment = rs.Fields("Comment").Value
End If
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
ReadTagComment = sComment
End Function
Required Configuration
- Open SQL Server Management Studio and verify the database name format:
CC_Engineering_<ProjectName>(the suffix is the project folder name). - Confirm the Windows account running the WinCC runtime service has
db_datareaderpermissions on the engineering database. - Test the query manually first:
SELECT TagName, Comment FROM MCPTagConfig WHERE TagName LIKE 'PT%' - Call
ReadTagComment("PT123")from a faceplate open event.
db_datareader on MCPTagConfig only. Do not connect runtime scripts with administrator credentials.Performance Data
| Operation | Typical Time | Notes |
|---|---|---|
| Connection open | 80 to 200 ms | First call only; reuse connection |
| Single-row query | 5 to 20 ms | Indexed on TagName |
| Full table scan (10k tags) | 200 to 600 ms | Avoid in runtime hot paths |
Method 5: WinCC Unified JavaScript Approach
WinCC Unified (TIA Portal V17 and later) uses JavaScript and exposes a richer tag API. The Tags collection provides access to tag configuration properties through the HMIRuntime object, and metadata access is more standardized than in the classic runtime.
Unified JavaScript Example
// WinCC Unified: Read tag metadata at runtime
import { HMIRuntime } from "HMIRuntime";
export async function GetTagDescription(signalName) {
try {
const tagObj = await HMIRuntime.Tags.SysFct.GetTag(signalName);
if (tagObj) {
return tagObj.Comment || "No description";
}
} catch (e) {
console.error("Tag metadata read failed:", e);
}
return "Unknown";
}
Unified-Specific Notes
- The Unified runtime keeps tag metadata in the project archive and exposes it asynchronously through the
Tagsinterface. - JavaScript Promises require
async/awaitor.then()chains. Avoid blocking the UI thread with synchronous loops. - Use
Tags.SysFct.GetTagListfor bulk retrieval when populating a selection list with hundreds of signals.
Method Selection Flowchart
Comparison of All Methods
| Method | WinCC Edition | Engineering Effort | Runtime Performance | Multi-language |
|---|---|---|---|---|
| Parallel comment tags | All editions | Low (1:1 tag copy) | Excellent (no runtime logic) | Manual |
| VBScript case mapping | Professional / V7 | Medium (script maintenance) | Good (50-200 ms per call) | Manual |
| Text lists | All editions | Low (if signal set is small) | Excellent | Yes (text library) |
| Database query | V7 / V8 only | High (SQL, security setup) | Moderate (5-20 ms per query) | Yes (if comment localized in DB) |
| Unified JavaScript | Unified only | Medium (script + API verification) | Good (async, 10-50 ms) | Yes |
Engineering Best Practices
- Pick one method per project. Mixing parallel tags and database queries in the same faceplate creates two sources of truth that will drift.
-
Generate comment tags from the tag table export. Use the TIA Portal Openness API or a Python script to read the tag CSV export and emit a new CSV with the
_Commentrows. This keeps both files synchronized on regeneration. - Localize the comment tag at compile time. Store translated strings in the text library and reference them by ID rather than embedding multi-language literals in VBScript.
- Prefer text lists for small, fixed signal sets (alarm summary faceplates, navigation menus). Switch to VBScript or database methods when the signal list exceeds 50 items.
- Document the chosen method in the HMI design guideline. When multiple engineers work on a project, a written convention prevents parallel-but-different comment-handling schemes.
Verification and Commissioning Checks
After implementing any of the methods above, perform the following checks on the HMI before signing off the FAT (Factory Acceptance Test):
- Tag comment displays correctly: Click the IO field or faceplate and confirm the comment string matches the HMI tag table exactly.
-
Special characters render: Test with comments containing
°C,µm,m³/h, and accented characters such asé,ñ. WString fields handle Unicode; String fields truncate at byte 80. - Language switch: If multi-language is required, cycle through every configured runtime language and verify the comment text updates.
- Performance check: Open 20 faceplate instances in rapid succession and measure the HMI's CPU and memory. The runtime should not exceed 60% CPU on the engineering station during this test.
-
Database permissions (V7 only): With the dedicated read-only SQL account, run
SELECT COUNT(*) FROM MCPTagConfigand confirm it returns the expected tag count. This validates the read permission is correctly scoped.
Troubleshooting Matrix
| Symptom | Likely Cause | Resolution |
|---|---|---|
IO field shows ###
|
WString length too short | Increase length to 254 characters |
| VBScript returns empty string | Case branch missing for the signal | Add a default case with fallback text |
| Database query timeout | SQL service not running or wrong instance name | Verify instance in SQL Server Configuration Manager |
| Text list does not update on language switch | Text library entry not configured for all languages | Add the entry to each language's text library row |
Unified script returns undefined
|
Tag not yet loaded in runtime | Wait for first cycle or use await with GetTag
|
| Comment text shows as question marks | Encoding mismatch (Latin-1 vs Unicode) | Use WString tag, not String |
| Faceplate property not visible in instance | Property not exposed in faceplate interface | Open faceplate editor → Properties → check "Release for use in screen" |
Frequently Asked Questions
Can WinCC Professional bind a text field directly to a tag's comment property?
No. WinCC Professional does not expose the HMI tag Comment field as a runtime-bindable property. The text field cannot be configured with a path like {TagName.Comment}; the only available dynamic paths in WinCC are the tag value, quality code, and timestamp. Use one of the indirect methods (parallel comment tag, VBScript, text list, or database query) instead.
Which method has the lowest runtime overhead?
Parallel comment tags (Method 1) have the lowest runtime overhead because no script executes and no database query fires at runtime. The comment text is read directly from the process image just like a normal tag value, with the same 100 ms to 1 s update cycle.
Is the database query method officially supported by Siemens?
Siemens documents the WinCC OLE DB provider and the configuration database schema in the WinCC V7 manual set, but querying MCPTagConfig from runtime VBScript is an unsupported technique that falls outside the standard support agreement. Use it for in-house engineering tools and prototypes only, and validate with Siemens Technical Support for production deployments.
Does Wonderware InTouch support this feature natively?
Yes. InTouch exposes tag comments through the Tagname.Comment scripting syntax in both QuickScript and the modern ArchestrA scripting environment. This is one reason some plants standardize on InTouch when descriptive tag metadata must be visible to operators without parallel-tag engineering overhead.
How do I keep the comment text synchronized when the tag table changes?
Use the TIA Portal Openness API to export the tag table to CSV on every save, then run a Python or PowerShell script that reads the CSV and regenerates a separate CSV with the parallel _Comment tags. Import the regenerated CSV back into TIA Portal. This produces a deterministic, repeatable build artifact and prevents drift between the comment column and the runtime comment tag.