Overview: Expression Constraints in WinCC Comfort Animation
Siemens Comfort Panels — including the SIMATIC TP1900 Comfort (15.4" TFT, 1280 × 800, 16 million colors, order number family 6AV2 124-1MC01-0AX0) configured under TIA Portal V21 with WinCC Comfort V21 — support a rich animation system covering visibility, appearance, motion, flashing, and direct value-driven properties. Each animation maps a configurable expression to a target property such as visibility, position, or color.
Although the WinCC Comfort animation editor exposes multiple operators and references, the underlying expression parser in WinCC Comfort / WinCC Advanced is intentionally restricted: a single animation event evaluates a single expression against one or more tags, but it does not perform Boolean composition. There is no inline Boolean operator (AND, OR, NOT) inside the animation configuration dialog itself.
This is by design. The expression syntax for animation in WinCC Comfort is a simplified algebraic DSL, not a general-purpose scripting environment. Operators such as =, <>, >, <, >=, <=, +, -, *, /, and bit access (%X0) are accepted; multi-tag Boolean composition is not. When a developer needs the equivalent of Visibility = (TagA == 1) AND (TagB == 1), the composite result must be computed outside the animation dialog and the animation bound to the precomputed Boolean tag.
The three practical engineering solutions are:
-
PLC aggregation — combine
TagAandTagBin the PLC program into a single derived Boolean and expose it as a normal HMI tag. The animation binds to that tag directly. - HMI-side script aggregation — keep both raw tags as internal HMI tags, then attach a VBScript to the value-change event of one or both source tags. The script reads the source tags and writes a derived Boolean to an internal tag, which the animation references.
- Tag-multiplexed animation — for very simple panels, drive two stacked objects with separate single-tag animations, using z-ordering to approximate the AND. This approach is fragile and not recommended for production.
For TIA Portal V21 with Comfort Panels, the PLC aggregation path is preferred because the panel polls the PLC at a fixed acquisition cycle and the derived tag is treated like any other Boolean. The HMI script path is the right answer when the source tags live entirely on the panel (e.g., HMI-internal flags, recipe variables, or local area pointers) and no PLC connection is appropriate.
Prerequisites and Environment
Before implementing either solution, verify the engineering environment matches the runtime constraints:
| Component | Required | Notes |
|---|---|---|
| TIA Portal | V21 (or V18 / V19 / V20 with compatible panel image) | Comfort panels remain supported through TIA V21; check the TIA V21 release notes for any device-image updates. |
| Configuration software | WinCC Comfort V21 (bundled with TIA Portal V21) | Required to author screens for the TP1900 Comfort. |
| Runtime image | Comfort Panel image ≥ V18.x for TIA V21 panel support | Verify via HMI device properties → "Image version". |
| Panel | SIMATIC TP1900 Comfort (6AV2 124-1MC01-0AX0 or current order number) | 15.4", 1280 × 800, 16M colors; PROFINET and MPI/PROFIBUS interfaces. |
| PLC | S7-1200 / S7-1500 / S7-300 / S7-400 with PROFINET or MPI/HMI connection | Tag aggregation runs as standard PLC logic. |
| HMI tag options | Internal HMI tags enabled if HMI-script path is selected | Project tree → HMI Tags → Show internal tags. |
| Scripting | Panel runtime settings → "Scripts" enabled | WinCC Comfort installs with scripting enabled by default; confirm if the project template was copied from another device. |
For background on the TIA Portal / WinCC Comfort platform, see the Siemens SIMATIC TIA Portal product page and the Siemens Industry Online Support portal.
Why Direct Boolean Expressions Are Not Supported in WinCC Comfort Animations
The animation expression field in WinCC Comfort parses a token stream against a fixed grammar. The grammar accepts:
- Numeric literals (
0,1,100,0.5) - Tag references (
'TagName'or"TagName") - Comparison operators (
=,<>,>,<,>=,<=) - Arithmetic operators (
+,-,*,/) - Bit access for Word/DWord tags (
%X0,%X1, …)
It does not accept:
- Boolean literals (
TRUE,FALSE) - Logical operators (
AND,OR,NOT) - Parenthesized Boolean groups
- Function calls (no
fnName(...)in the expression field)
Therefore an attempt to enter something like 'TagA' AND 'TagB' in the animation "Expression" field fails at parse time with a configuration error visible in the inspector, and the project download will be rejected.
This restriction is not an oversight; the parser intentionally omits Boolean composition because the result of the expression is reinterpreted as a number when bound to a non-Boolean property (e.g., position, size, color, angle). Allowing Boolean operators would introduce ambiguity (e.g., 0 AND 1 versus 1 AND 2). Pre-computing the Boolean and binding the animation to a 0/1 tag keeps the runtime unambiguous and lets the same expression grammar serve both Boolean and numeric targets.
Solution 1: PLC-Side Aggregation (Recommended)
This is the canonical, deterministic, and lowest-overhead approach. The PLC combines the source tags once, and the HMI reads the result as a standard Boolean tag. The animation reduces to a single-tap compare against the derived tag.
SCL pattern (S7-1200 / S7-1500)
// SCL: derive composite visibility flag for HMI animation
// Source tags from plant: bPermissive_A (Bool), bPermissive_B (Bool)
// Derived tag exposed to HMI: "HMI_Visibility_OK"
IF "bPermissive_A" AND "bPermissive_B" THEN
"HMI_Visibility_OK" := TRUE;
ELSE
"HMI_Visibility_OK" := FALSE;
END_IF;
LAD pattern (S7-1200 / S7-1500)
| Segment | Element | Operand / comment |
|---|---|---|
| 1 — branch 1 | --[ ]--[ ]--( )-- |
bPermissive_A in series with bPermissive_B driving output coil HMI_Visibility_OK
|
| 1 — branch 2 | --[ ]--[ ]--/( )-- |
NOT bPermissive_A in parallel with NOT bPermissive_B driving a reset coil for the same tag |
HMI configuration steps
- Add a new Boolean tag
HMI_Visibility_OKin the HMI tag table with connection to the PLC address (e.g.,%DB50.DBX0.0). - Open the screen object whose visibility must depend on both tags.
- Open Properties → Animations → Visibility → Add.
- In the Expression field enter:
'HMI_Visibility_OK' = 1 - Set the Value field:
Visible = 0(Hidden when the expression is true) orVisible = 1(Visible when true), depending on the desired polarity.
This is the configuration Siemens itself documents in the WinCC Comfort manual under the "Visibility animation" reference section.
Solution 2: HMI-Side Script Aggregation with Value-Change Event
Use this path when the source tags live only on the HMI side (internal HMI tags, area pointers, recipe variables) and a PLC connection is unavailable or unnecessary. The runtime host on Comfort Panels is the WinCC Comfort VBScript engine, which exposes the global HMIRuntime object.
Step-by-step implementation
-
Create three HMI tags:
-
TagA_Internal— Bool, internal, "Update on value change" enabled -
TagB_Internal— Bool, internal, "Update on value change" enabled -
AndResult_Internal— Bool, internal, "Update on value change" enabled
-
-
Create a project function: Project tree → Scripts → Project functions. Add a function
fnCalculateAndResult.' fnCalculateAndResult ' Reads TagA_Internal and TagB_Internal, writes AND result to AndResult_Internal Sub fnCalculateAndResult() Dim oTagA, oTagB, oResult Set oTagA = HMIRuntime.Tags("TagA_Internal") Set oTagB = HMIRuntime.Tags("TagB_Internal") Set oResult = HMIRuntime.Tags("AndResult_Internal") oTagA.Read oTagB.Read oResult.Write (CBool(oTagA.Value) And CBool(oTagB.Value)) Set oTagA = Nothing Set oTagB = Nothing Set oResult = Nothing End Sub -
Attach the function to value-change events:
- Select the source of
TagA_Internal(e.g., a button or an incoming tag from the PLC) and configure the "Value change" event to callfnCalculateAndResult. - Repeat for the source of
TagB_Internal.
- Select the source of
-
Bind the animation: configure the visibility animation on the target object exactly as in Solution 1, using
'AndResult_Internal' = 1.
Why value-change and not a scheduled task
A common mistake is to wire the script to a 500 ms cyclic event. This works but burns CPU and increases tag-bus traffic. Event-driven execution only runs when there is something to evaluate. The Comfort Panel scripting engine supports both event-driven and scheduled scripts; for derived booleans driven by user input or incoming tag updates, event-driven is preferred.
Debugging helpers
While commissioning, add temporary logging inside the script to trace execution:
' Debug: write a 1 to AndResult_Internal every time the script runs
HMIRuntime.Trace "fnCalculateAndResult fired, A=" & oTagA.Value & " B=" & oTagB.Value
HMIRuntime.Trace writes to the HMI diagnostic log accessible via Start → HMI Diagnostics → Trace on the TP1900 Comfort. Remove the trace line before production release.
Solution 3: Indirect Tag Approach (When Scripting Is Not Available)
In rare configurations — for example, on a TIA Portal runtime license that disables scripting on the panel — the only option is to combine two animations on stacked objects:
- Object A: visibility animation
'TagA' = 1(visible when TagA is true) - Object B: identical appearance, placed at the same coordinates, with visibility animation
'TagB' = 1
The desired AND effect is approximated by making object B visible only when both tags are true. This is brittle because z-order, partial transparency, and overlapping hit zones all interfere, and any property other than visibility (color, position) requires more objects still. This method is documented here only for completeness; production projects should use Solutions 1 or 2.
Tag Type and Update Behavior Considerations
The Comfort runtime distinguishes between two update modes for HMI tags:
- Cyclic continuous: the panel polls the PLC at the configured acquisition cycle and writes the new value to the local image. Default cycle is 1 second.
- Update on value change: the runtime subscribes to the change event and updates only when the value actually differs from the last cached value.
For the PLC aggregation solution, both modes work because the PLC writes the derived Boolean every cycle. For the HMI script solution, the source tags must be configured with "Update on value change" enabled; otherwise the script never fires and the derived Boolean remains stale.
| Tag | Recommended update mode | Reason |
|---|---|---|
| Source TagA (PLC) | Cyclic continuous | Standard PLC polling |
| Source TagB (PLC) | Cyclic continuous | Standard PLC polling |
| Derived Boolean (PLC output) | Cyclic continuous | Standard PLC polling |
| Source TagA_Internal (HMI) | Update on value change | Event-driven script trigger |
| Source TagB_Internal (HMI) | Update on value change | Event-driven script trigger |
| AndResult_Internal (HMI) | Update on value change | Written by script, read by animation |
Performance and Polling Best Practices
The TP1900 Comfort uses the same ARM-based panel image as other large Comfort panels. Its VBScript engine has limited throughput (low single-digit-millisecond response per script call for trivial logic, but tens of milliseconds for scripts that touch many tags). Keep these rules in mind:
- Compute once, animate many times. Pre-compute the Boolean in the PLC and reference it from every dependent animation. Never duplicate the same AND evaluation in 12 animation events.
- Match acquisition cycles to plant response. A safety interlock does not need 100 ms polling; an operator faceplate animation does not need 2 s polling. Default 1 s is appropriate for visibility.
- Avoid function-call scripts in property animations. WinCC Comfort does not allow custom functions inside animation expressions. The animation must reference a tag. Pre-compute the value in a script and write it to that tag.
- Limit log triggers. If the same value-change event is used to log data, split the work into two events: a short script for the Boolean write and a scheduled task for the log.
- Prefer PROFINET over MPI/PROFIBUS for new installations on the TP1900 Comfort. PROFINET offers faster and more deterministic polling, reducing the visible latency between a PLC write and the animation update.
Cross-Platform Context: Expression Animation Beyond WinCC
The general concept of binding a computed expression to an animated property is implemented differently across HMI / SCADA and UI platforms:
- Windows.UI.Composition.ExpressionAnimation (Microsoft WinUI / UWP) accepts free-form expressions evaluated each frame against a CompositionObject's properties. The expression itself is a string passed to the system compositor, which performs the math on the GPU. Reference: Microsoft Learn — ExpressionAnimation Class.
- CSS animations (web) use keyframes and timing functions; live expression evaluation per frame is generally delegated to JavaScript. Reference: MDN — animation CSS property.
- WinCC Comfort evaluates expressions against tag values on a fixed acquisition cycle (not per frame), with a restricted algebraic grammar as described above.
The structural difference explains why WinCC Comfort requires pre-computed booleans where WinUI can compose them on the compositor. WinUI defers composition to the GPU each frame; WinCC Comfort evaluates expressions once per cycle against a tag snapshot, so multi-tag Boolean operations must be pre-resolved outside the expression parser.
Verification
After either solution is downloaded, walk through this commissioning checklist:
- Force values in the PLC (watch table) and confirm the derived Boolean tracks the AND result within one acquisition cycle.
-
Use HMI Diagnostics (Start → HMI Diagnostics → Tags) on the TP1900 Comfort to inspect
HMI_Visibility_OKorAndResult_Internalin real time. -
Toggle each source independently:
- TagA = 1, TagB = 0 → object hidden
- TagA = 0, TagB = 1 → object hidden
- TagA = 1, TagB = 1 → object visible
- TagA = 0, TagB = 0 → object hidden
- Cycle the panel power and confirm the visibility state matches the post-reset state of the source tags.
- Log the derived Boolean to a trace for a full process cycle to confirm no glitch events.
- Reload the project in the engineering station and confirm no compile warnings about unused tags (a common audit finding when an aggregation tag was deleted but the animation reference was not).
- Disconnect the PLC link and confirm the visibility behavior falls back to a safe display state (configure a system event for connection loss).
Troubleshooting Matrix
| Symptom | Likely cause | Fix |
|---|---|---|
| Animation shows red "Configuration error" in inspector | Boolean operator (AND/OR) used in expression field |
Pre-compute Boolean externally; bind single tag |
| Object never appears despite both tags being true | HMI tag acquisition cycle set too long | Reduce cycle to 500 ms–1 s |
| Object flickers in and out | Source tag toggles faster than HMI cycle | Add PLC-side hysteresis or filter the derived tag |
| Script does not fire on input change | Source tag is "Cyclic continuous", not "Update on value change" | Switch acquisition mode to value change |
| VBScript runtime error on panel | Typo in tag name or missing internal tag | Check HMI log; verify tag names match exactly |
| Derived Boolean stays at last value after power cycle | Internal HMI tag persistence is OFF | Enable "Retain" on internal tag if state must survive reboot |
| Tag not visible in HMI tag table | "Show internal tags" filter disabled | Enable the filter or move tag to a non-internal class |
| Compile error: "Tag does not exist on PLC" | HMI tag points to wrong DB address after program change | Reconnect HMI tag to current PLC address |
| Script fires but writes wrong value | Boolean coercion mismatch (0 vs 1 string) |
Wrap with CBool() explicitly in VBScript |
| Performance lag on screen open | Too many animation events bound to the same Boolean | Reduce animation count; reuse the same Boolean tag |
| Object visible during PLC connection loss | No fallback animation on connection-loss event | Configure system event to hide the object when the PLC is unreachable |
Standards and Safety Note
HMI visibility animation is purely a UX mechanism. It is not a safety-rated function. Where the Boolean result reflects a safety interlock, observe the relevant machinery safety standards (e.g., ISO 13849-1 for mechanical safety, IEC 62061 for electrical safety, IEC 61508 for functional safety) and route the safety decision through a safety PLC (e.g., SIMATIC F-CPU S7-1500F / S7-1200F) with the appropriate Performance Level (PL) / Safety Integrity Level (SIL). The HMI should mirror the safety output for operator information, but it must never be the source of truth.
For TP1900 Comfort in a process-control context, validate the entire faceplate against the operator's task list under normal and degraded modes. The animation must remain meaningful when the PLC connection is lost: configure a "Connection lost" system event to drive the derived Boolean to a safe display state.
Frequently Asked Questions
Can I write TagA AND TagB directly in the WinCC Comfort animation expression field?
No. The WinCC Comfort expression parser only accepts comparison and arithmetic operators against tag references. Compute the AND result in the PLC or in an HMI VBScript and bind the animation to that derived Boolean tag using 'DerivedTag' = 1.
Is the HMI VBScript path supported on the TP1900 Comfort running TIA Portal V21?
Yes. Comfort panels configured under WinCC Comfort V21 include the VBScript engine. Enable scripting per panel in the runtime settings (Device Configuration → Runtime → Scripts) and use the HMIRuntime.Tags(...) object for read/write operations.
How fast does the derived Boolean propagate from PLC to TP1900 Comfort?
By default the HMI acquisition cycle is 1 second; it can be reduced to 100 ms with care. PLC aggregation therefore adds at most one HMI cycle of latency on top of the PLC OB1 cycle. For sub-200 ms response, switch to PROFINET IRT and reduce the cycle to 100 ms.
Why does my VBScript fire only once even though the input tag changes?
The source tag is set to "Cyclic continuous" acquisition, which only triggers a value-change event when the value actually differs from the cached value. Confirm the source tag acquisition is set to "Update on value change" and that the event is wired to the script in the screen object, not just to the tag itself.
Can I avoid scripting entirely on the TP1900 Comfort?
Yes. Compute the AND in the PLC (SCL or LAD) and expose a single Boolean tag to the HMI. This is the preferred solution for production code because it is deterministic, auditable, independent of the VBScript engine, and survives panel reboots without retain-bit configuration.