Setting Dynamic Text Background Colors in TIA WinCC Professional
Engineers migrating from WinCC 7.x to the TIA Portal, or commissioning new Comfort/PC-based HMIs, frequently need a single text field to switch its background color based on the state of one or more PLC tags. In WinCC 7.x the Dynamic Dialog editor accepts a multi-tag expression directly. In TIA Portal, the equivalent mechanism is the Animations pane of a screen object, but it is only available when the configured target system is WinCC Runtime Professional (or, in earlier releases, WinCC Runtime Advanced with a script). This article walks through the configuration in detail, including the expression syntax for multi-tag boolean logic, multiple property animations, common fault conditions, and a comparison against the WinCC 7.x behavior engineers expect.
1. Problem Statement
A typical requirement is: "If Tag_AlarmActive is TRUE or Tag_WarningActive is TRUE, show the text 'Status: ATTENTION' on a red background; otherwise show the text on a green background." A second, similar requirement is to flash a label while a tag is TRUE. Both are trivial in WinCC 7.x's Dynamic Dialog, but the property dialog in TIA Portal HMI screens only shows the option to bind the background color to a single tag by default. The Animations pane exposes the missing functionality and is the recommended configuration path documented in the TIA Portal Help.
2. Prerequisites
- TIA Portal V12 SP1 Update 4 or later. The Animations pane has existed since TIA Portal V12 and is fully supported in V13, V14, V15, V15.1, V16, V17, V18, and V19. Newer versions (V18/V19) add IntelliSense inside the expression editor.
- HMI device class must be one of: WinCC Runtime Professional (PC-based, single-station or distributed), or — for the older Advanced track — WinCC Runtime Advanced with a VB script. The Animations pane is not shown for Comfort Panels, KTP panels, or Basic Panels.
- Project > HMI tags must contain the tags to be referenced. The expression editor will only autocomplete tags that exist in the HMI tag table; PLC tags are surfaced if the connection is online, but for offline editing, mirror them as HMI tags.
- For the runtime side, the WinCC RT Professional license must be installed on the target PC; the standard PC RT license (6AV2 105-....) is sufficient. See the SIMATIC HMI catalog for the exact article number when ordering.
3. Runtime Edition Feature Matrix
| Feature | Basic Panel | Comfort Panel | RT Advanced | RT Professional |
|---|---|---|---|---|
| Tag-based background color | Yes (single tag, 0/1) | Yes (single tag, 0/1) | Yes | Yes |
| Range-based color (value ranges) | Yes (limited) | Yes | Yes | Yes |
| Bool expression with multiple tags | No | No | No (use VB script) | Yes (Animations tab) |
| Multiple properties in one animation (background + text color + flashing) | No | No | Limited | Yes |
| VB / C / VBScript for complex logic | No | No | Yes (VBScript) | Yes (VBScript, C, ANSI-C) |
Source: SIMATIC TIA Portal WinCC Engineering — entry page and the HMI device manual for each panel class. The Animations pane for RT Professional is documented in the TIA Portal Help under Editing HMI screens > Animating screen objects > Animate screen object properties.
4. Step-by-Step Configuration Procedure
- Place a text object on the screen. In the project tree, expand the HMI device and double-click the target screen to open it. From the toolbox, drag a Text field (or Symbolic I/O field if the text content is also dynamic) onto the canvas.
- Select the text object by clicking it once. The Properties inspector on the right side of the TIA Portal shows the static properties (Text, Font, Color, etc.).
- Open the Animations pane. At the bottom of the Properties inspector, switch from the Properties tab to the Animations tab.
- Add a new animation. Click the Animate property drop-down. From the list, pick Background color (or Background colors in some V18/V19 builds). The animation row is added to the table.
-
Choose the trigger source. In the new row, click the trigger column. The dialog exposes a choice between:
- Tag — bind to a single HMI tag (1 = state 1, 0 = state 0). This is the default in older TIA Portal versions.
- Expression — enter a free-form boolean expression. This is the option needed for multi-tag logic.
- Set the result type. When Expression is selected, set the result type to BOOL. The expression must evaluate to a boolean value.
-
Enter the expression. The expression editor opens. Type the boolean expression, e.g.
"Tag_AlarmActive" OR "Tag_WarningActive". Auto-complete (Ctrl+Space) lists all available HMI tags. Standard boolean operators areAND,OR,NOT,XOR; comparison operators==,!=,<,>,<=,>=are allowed when comparing to integer or real literals. - Add the property to the animation. Click Add property in the animation row and confirm Background color in the dialog. The row now shows two configuration cells for Value TRUE and Value FALSE.
- Assign the colors. Click the swatch in Value TRUE and pick the alert color (for example, red, RGB 255/0/0). Click the swatch in Value FALSE and pick the normal color (for example, green, RGB 0/200/0).
- Add additional properties to the same animation (optional). Click Add property again and choose Text color or Flashing. All properties in the same animation are driven by the same boolean expression result — this is the cleanest way to color text and background consistently when a tag changes state.
- Compile and download. Right-click the HMI device and choose Compile > Software (rebuild all). Then transfer the project to the runtime. The WinCC RT Professional Launcher logs "Compilation finished" on success.
- Start runtime and verify. Toggle the tag in the PLC or in the HMI tag simulation table. The background should swap on the next screen update cycle (typical 250 ms polling).
5. Expression Syntax for Multi-Tag Conditions
The expression editor uses TIA Portal's standard expression grammar, which is a subset of the language used by the faceplates and by the C-like script editor. The result of every animation expression must be coercible to the type of the property it drives. For boolean color/visibility/flashing animations the result must be BOOL.
| Logical form | Expression | Notes |
|---|---|---|
| Single tag | "HMI_Tag_Alarm" |
Tag must be BOOL for a boolean animation; any type for a numeric animation. |
| OR of two tags | "HMI_Tag_Alarm" OR "HMI_Tag_Warning" |
Both tags BOOL. |
| AND with NOT | "HMI_Tag_Run" AND NOT "HMI_Tag_Stop" |
Useful for "running and not stopping". |
| Numeric comparison | "HMI_Tag_Speed" > 1500 |
Integer tag compared to literal. |
| Combined | ("HMI_Tag_Speed" > 1500) AND ("HMI_Tag_Mode" == 2) |
Parentheses encouraged to control precedence. |
| String match | "HMI_Tag_State" == "RUN" |
Tag is STRING; comparison is case-insensitive in TIA V17+. |
Identifier quoting: Tag names with spaces or non-standard characters must be enclosed in double quotes. Tag names that are valid C identifiers (letters, digits, underscores; not starting with a digit) can be written without quotes. The expression editor accepts both forms.
Type coercion: A non-zero integer or real is treated as TRUE, zero is FALSE. A non-empty STRING is TRUE, empty string is FALSE. For most production code prefer explicit comparisons (== 0, == "") for readability.
6. Practical Example: Two Tags, Three States
When the requirement is "Alarm > Warning > Normal" (three states, two tags), the Animations pane alone is not enough because it only switches between two values per property. The cleanest implementation is to add two animations on the same object — one for Alarm and one for Warning — and accept the second animation's TRUE state as a higher-priority overlay. TIA Portal evaluates animations top-to-bottom; the last animation that fires overrides the earlier ones. The recommended ordering is:
- Animation 1: trigger
"Alarm"(or expression), property Background color. Values: TRUE = red, FALSE = green. - Animation 2: trigger
"Warning" AND NOT "Alarm", property Background color. Values: TRUE = yellow, FALSE = (leave default — the first animation's color will show through).
The PLC programmer ensures Alarm and Warning are mutually exclusive (or alarms override warnings upstream), so the second animation only fires when only the warning tag is set.
7. Multiple Property Animations on a Single Object
To make a label flash red-and-white on a critical alarm, add the same animation row and click Add property three times:
- Property 1: Background color — TRUE = red, FALSE = gray.
- Property 2: Text color — TRUE = white, FALSE = black.
- Property 3: Flashing — TRUE = on, FALSE = off.
All three properties share the same boolean expression and update atomically. This is preferable to separate animations because the trigger is computed once per cycle.
8. Comparison: WinCC 7.x vs TIA WinCC Professional
| Capability | WinCC 7.x Dynamic Dialog | TIA WinCC Professional Animations |
|---|---|---|
| Multi-tag boolean expression in a single line | Yes (built into Dynamic Dialog) | Yes (Expression radio in trigger) |
| Result type defined inline | Yes (Binary, Analog, Bit) | Yes (BOOL/INT/REAL/STRING chosen explicitly) |
| Multiple TRUE/FALSE branches per property | Limited (range-based for analog) | No — two states per animation; use stacked animations for more |
| Direct VB/C code for complex logic | Yes (C actions in V6/V7, VB later) | Yes (VBScript or ANSI-C on events) |
| Reusability | Yes (Dynamic Wizard, libraries) | Yes (faceplates, library master copies) |
Engineers familiar with WinCC 7.x will find TIA Professional's Animations pane equivalent for the common 1-tag and 2-tag cases. The TIA version wins on IntelliSense and on combining multiple properties in one row.
9. VB Script Alternative (Runtime Advanced and Professional)
For logic that the expression editor cannot express (e.g., string parsing, time windows, multi-step state machines), use a VBScript procedure bound to the Property change event of the text object, or a global cycle script. Example for RT Advanced/Professional:
' VBScript, attach to the text object's "Property change" event
Dim alarm, warn
alarm = SmartTags("HMI_Tag_AlarmActive")
warn = SmartTags("HMI_Tag_WarningActive")
If alarm = True Then
HmiRuntime.Screens("Main").ScreenItems("txtStatus").BackColor = RGB(255, 0, 0)
HmiRuntime.Screens("Main").ScreenItems("txtStatus").ForeColor = RGB(255, 255, 255)
HmiRuntime.Screens("Main").ScreenItems("txtStatus").Text = "ALARM"
ElseIf warn = True Then
HmiRuntime.Screens("Main").ScreenItems("txtStatus").BackColor = RGB(255, 200, 0)
HmiRuntime.Screens("Main").ScreenItems("txtStatus").Text = "Warning"
Else
HmiRuntime.Screens("Main").ScreenItems("txtStatus").BackColor = RGB(0, 200, 0)
HmiRuntime.Screens("Main").ScreenItems("txtStatus").Text = "OK"
End If
HmiRuntime object model is the VBScript object hierarchy of WinCC Runtime Advanced and Professional. The exact property names (BackColor, ForeColor) match the WinCC Comfort/Advanced script reference. For RT Professional, the script interface is identical at the object level, but the screen object access is also possible through the HMIRuntime object.10. Common Configuration Errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Animations tab is greyed out or missing | Target system is Comfort/Basic Panel, or RT Advanced with the optional Animations feature disabled in the device configuration | Right-click HMI device > Properties > Runtime settings; verify WinCC RT Professional. For RT Advanced, ensure the "Animation Designer" add-on is licensed. |
| No "Expression" option in the trigger | Trigger cell not clicked after the row was added | Click the trigger cell in the animation row, then choose Expression. |
| Compiler error "Tag 'X' is not declared" | Tag name is misspelled or lives in a different HMI tag table that is not in scope | Add the tag to the HMI tag table of the active device, or fully qualify with the connection name. |
| Expression always evaluates to FALSE | Tags are BOOL but quoted as strings with the wrong symbol, e.g. "HMI_Tag" on a STRING tag in PLC; type mismatch on comparison |
Inspect each tag's data type in the HMI tag table; adjust expression or the tag's type. |
| Color does not change at runtime | HMI tag is not being updated (PLC connection down), or the update cycle is too long | Check the connection status in the WinCC RT diagnostic view; reduce the tag's acquisition cycle from 1 s to 250 ms. |
| Background flickers between two values | Two animations on the same property fire on the same tag | Consolidate the logic into one expression, or remove the redundant animation. |
11. Verification Procedure
- Offline simulation (PLCSIM + WinCC RT). With TIA Portal and SIMATIC S7-PLCSIM on the same PC, start PLCSIM, load the PLC program, then start the HMI runtime from the TIA Portal toolbar. Watch the text object in the runtime window. Toggle the simulated PLC tag in PLCSIM's watch table; the background must change within one tag acquisition cycle.
- Online tag forcing (RT Professional). In the runtime, press Ctrl+Alt+P to open the diagnostic pane. Force the HMI tag to 1, then 0, and observe the color swap. This proves the animation is bound correctly even if the PLC side has a connection issue.
- Compile log inspection. After Compile > Software (rebuild all), open the "Compile output" window. A clean compile shows no warnings. "Unused tag" or "Type mismatch" warnings indicate the expression references something the compiler could not resolve.
- Runtime diagnostics (RT Professional). In the WinCC Explorer (for the older WinCC 7.x runtime) or in the RT Diagnostics view in TIA Portal (for RT Professional V17+), the Tag simulation panel shows the current value of every HMI tag. Confirm the tag driving the expression changes value at runtime.
- Performance check. Place a stopwatch in the script of an event that triggers when the color changes, or use a chronograph script. The expression is re-evaluated on each acquisition cycle. If the cycle is 100 ms and the screen is heavy, you may see a 100–250 ms latency between PLC state change and the HMI update. Lower the acquisition cycle for the relevant tags if a faster response is required.
12. Performance and Best Practices
- One expression, many properties. Always prefer adding multiple properties to a single animation row over creating parallel animations, because the boolean expression is computed once per cycle.
- Tag acquisition cycle. Default 1 s is fine for status displays; tighten to 250 ms for alarm texts and operator-relevant signals. Avoid 100 ms for more than a handful of tags because it stresses the OPC UA / S7 connection.
- Avoid deeply nested expressions. The expression editor handles parentheses well up to about ten levels; for deeper logic move to a faceplate type with internal tags and a structured state variable.
- Prefer HMI tags over PLC tags in expressions. HMI tags can be polled even when the PLC is offline (showing the last good value), and they are easier to test with the tag simulator.
- Document the expression. TIA Portal stores the expression in the project XML. Add a comment in the screen's name or in the project's documentation tool. This is invaluable for the next engineer who inherits the project.
- Test multi-state with stacked animations. For three or more states, use stacked animations on the same property. Always order the animations from lowest to highest priority in the Animations pane — the last animation wins.
13. Frequently Asked Questions
Why is the Animations tab missing on my text object in TIA Portal?
The Animations tab is only available for WinCC Runtime Professional (and partially RT Advanced with the Animation Designer add-on). If the HMI device in the project tree is a Comfort Panel, KTP, or Basic Panel, the Animations tab is replaced by the simpler Properties > Appearance > Dynamic dialog, which cannot evaluate multi-tag expressions. Switch the HMI device to a PC-based WinCC RT Professional target, or use a VBScript on a scheduled event.
Can I bind a background color to the result of an arithmetic expression, not just a boolean?
Yes, but the animation must be configured as a numeric range, not a boolean. Set the trigger to Expression with result type INT or REAL, then define color ranges (e.g., 0 = green, 1 = yellow, 2 = red). This is the same mechanism used in WinCC 7.x's "Range" type dynamic dialog and is documented in the TIA Portal Help under Animating screen objects > Animate screen object properties > Color ranges.
How do I make a text object flash while a tag is TRUE?
Add a new animation, choose Flashing as the property, set the trigger to Expression, and enter the boolean expression (for example "HMI_Tag_AlarmActive"). Set the flash period to 500 ms in the animation's properties. Optionally add Background color as a second property on the same animation row so the flash is also color-coded.
Why does my expression always evaluate to FALSE even though the tag is TRUE in the watch table?
Three common causes: (1) the tag in the expression is a different name from the one in the watch table — verify spelling and case in the HMI tag table; (2) the tag's data type is INT (0/1) but the expression treats it as BOOL — wrap with a comparison, e.g. "HMI_Tag" == 1; (3) the HMI tag is not updating because the PLC connection is offline — open the connection diagnostics in the runtime to confirm.
Is the expression editor in TIA Portal V12 the same as V19?
The core feature set has been stable since V12 SP1: Animations tab, trigger = Expression, result type = BOOL, multiple properties per row. Later versions added IntelliSense, color-range animations, and a richer type system. If you maintain a V12 project in V18/V19, the expressions are forward-compatible; the only thing to watch is tags that have been renamed or removed during refactoring.
14. Summary
Setting a dynamic text background in TIA Portal based on one or more tags requires three things: a WinCC Runtime Professional target, the Animations tab of the text object, and a boolean expression with the result type BOOL. Once the trigger is set to Expression, multiple properties (background color, text color, flashing) can be bound to the same boolean result. For three or more states, stack multiple animations; for logic the expression editor cannot express, drop down to VBScript on a property-change event. The TIA Portal Help at SIMATIC TIA Portal documentation and the SIMATIC HMI product pages at SIMATIC HMI contain the full reference for every animation property.