WinCC VBS Object Flashing: Configure Indirect Tag Triggers
Flashing graphic objects in Siemens WinCC Runtime (Comfort Panels, TIA Portal HMI, WinCC Professional / WinCC RT Advanced / WinCC RT Enterprise) is normally a property-driven animation that the runtime engine evaluates on a fixed internal cycle. When the trigger tag is delivered through indirect addressing (multiplexing) or when the trigger source is itself a VBS expression, the runtime continues to evaluate the VBS even when the underlying Boolean state has not changed. On large screens with many flashing objects this can result in a visible 2-second system tick, callback saturation, and a perceptible slowdown of the entire HMI process image.
This reference explains the mechanics of the Flashing Background Active property, the FlashBackColor, FlashForeColor, FlashRate, and Flashing object attributes, the role of HMIRuntime.Tags and the ScreenItems collection, and—most importantly—how to reconfigure the default trigger so that the VBS function only fires upon change instead of being polled on a fixed acquisition cycle.
1. Problem Definition
You want a circle (or any HMI object) on a WinCC screen to flash while a Boolean tag is 1 and remain steady when the Boolean is 0. The tag is reached through an indirect address (a multiplexer / index-based pointer), so it cannot be wired to the standard Flashing property dialog directly. You place a VBScript on the Flashing Background Active event of the object, and the flashing visually works, but:
- The VBS is invoked approximately every 2 seconds regardless of the trigger tag state.
- Runtime performance degrades when the screen contains many flashing objects (cascading callbacks, increased tag polling).
- You cannot simply bind the indirect tag to the standard Flash variable field of the property dialog because the field expects a static tag name, not a pointer.
2. Prerequisites
- Siemens TIA Portal V16 or later (V17 / V18 / V19 supported) with WinCC Comfort / WinCC Professional configured.
- Target runtime: SIMATIC Comfort Panel (TP/KTP series), IPC with WinCC RT Advanced, or WinCC RT Professional.
- A defined Boolean trigger tag (e.g.
Sel_A, address area DB / Merker / Process tag, data typeBool). - A screen object of type Circle (or any object that exposes the Flashing group: Rectangle, Ellipse, Polygon, Symbolic IO field, Button, Text field).
- Indirect address configured either as a multiplex tag in the HMI tag table, or a manual pointer built from a base tag + index in VBS.
- Engineering access to the runtime security settings (VBS execution must be allowed; default in TIA Portal projects).
3. Default Flashing Behavior in WinCC
Every screen object that supports visual feedback has a Flashing property group in the Properties pane:
| Property | Description | Default |
|---|---|---|
| Flashing | Master switch: enables / disables flashing for the object. | No flashing |
| Flash variable | Static HMI tag (Bool) that drives the flash; 1 = flash active. |
None |
| Flash rate | Period of one on/off cycle (slow 2 s / medium 1 s / fast 0.5 s). | Slow (2 s) |
| Flashing Background Active | VBS / C event fired on every acquisition tick while flashing is active. | Empty |
| Flashing Foreground Active | VBS / C event fired when the foreground should swap colors. | Empty |
| FlashBackColor / FlashForeColor | Object properties that hold the alternate color pair (or are written by VBS). | System colors |
| FlashColorOn / FlashColorOff | Two-color palette used by the runtime engine when no VBS overrides them. | Green / Red |
When the dialog-driven flow is used (static Flash variable + Flash rate), the runtime swaps the configured FlashColorOn / FlashColorOff on its own internal timer, and there is no VBS overhead. The VBS events only exist to override the colors dynamically.
4. VBS Implementation: Flashing via HMIRuntime.Tags and ScreenItems
When the trigger tag is reached through an indirect address, the only practical way to evaluate the pointer in script is to use the HMIRuntime.Tags collection, read the pointed-to value with the .Read method, and push it into the object's FlashBackColor property. The minimum working snippet is:
' --- Place on Flashing Background Active of object CircleX ---
Dim objCircFlashTrig, objCirc
Set objCircFlashTrig = HMIRuntime.Tags("Sel_A") ' Bool variable for trigger
Set objCirc = ScreenItems("CircleX") ' Circle object
objCirc.FlashBackColor = objCircFlashTrig.Read()
What this does line by line:
-
HMIRuntime.Tags("Sel_A")returns a Tag object reference. The Tag is a wrapper that caches the read value in the local runtime buffer; it does not re-fetch from the PLC on every property access. -
objCircFlashTrig.Read()returns the current Boolean state ofSel_Aas a Variant. -
objCirc.FlashBackColoris the dynamic color used by the flasher. Assigning a non-zero value enables the alternate background; assigning0disables the swap. WinCC converts the Boolean to a numeric color index in this single property write.
Flashing property set to Flashing active and a valid Flash rate. The VBS only controls which color is shown; the engine controls the rhythm.5. The Indirect Address Problem
Indirect addressing in WinCC takes two common forms:
-
Multiplex tag: declared in the HMI tag table as
Pointertype, where a source tag is read at runtime and a target tag is exposed. The HMI only sees the target; the pointer is resolved server-side. -
Manual index lookup: VBS reads an index tag, builds a string tag name such as
"DB100.DBB" & (idx * 2), and callsHMIRuntime.Tags(name).Readdirectly.
The Flashing Background Active event is a VBS slot. Whatever you write in it is executed on the configured acquisition tick. The default acquisition for events tied to a property is the project's Update cycle (commonly 2 s for HMI tags). That is why the script appears to fire every 2 seconds. It is not the flash rate (which is purely visual); it is the data update rate of the property the VBS is bound to.
6. Switching the Default Trigger to On-Change
The runtime offers two acquisition modes for any property / event:
| Mode | Behavior | Typical Use | CPU cost |
|---|---|---|---|
| Cyclic (default) | Evaluated every acquisition cycle (e.g. 2 s). | Slow-changing analog values, hour meters. | Continuous |
| On change | Evaluated only when the tag's value changes. | Digital state transitions, alarms, triggers. | Event-driven |
To make the VBS fire only when the indirect trigger actually flips:
- Open the Properties of object
CircleX. - Navigate to Properties > Flashing > Flashing Background Active.
- In the right-hand editor, click the small cycle / trigger icon (often a clock symbol) that opens the acquisition dialog.
- Switch from Cyclic to On change.
- Bind the trigger to the real (non-multiplexed) Boolean tag that the indirect pointer ultimately resolves to.
1 -> 0 -> 1) from your PLC logic each time the pointed-to value mutates, and you use that synthetic tag as the property's On change trigger. WinCC will then invoke the VBS exactly once per transition, not on a 2-second timer.7. Working Code: Complete Reference
7.1 Simplest pattern – static tag, on-change trigger
' Place on Flashing Background Active of CircleX
' Trigger: HMIRuntime.Tags("Sel_A") configured as On change in the property dialog
Dim oTrig, oCirc
Set oTrig = HMIRuntime.Tags("Sel_A")
Set oCirc = ScreenItems("CircleX")
oCirc.FlashBackColor = oTrig.Read
7.2 Multiplex / pointer pattern
' Index = HMI tag (Int) selecting which element of array to monitor
' The PLC holds an array DB100.DBB[0..99]
Dim idx, sTag, oVal, oCirc
idx = HMIRuntime.Tags("Index").Read
sTag = "DB100.DBB" & (idx * 2) ' build pointer name
Set oVal = HMIRuntime.Tags(sTag)
Set oCirc = ScreenItems("CircleX")
If oVal.Read = 1 Then
oCirc.FlashBackColor = RGB(255, 0, 0) ' red while tag = 1
Else
oCirc.FlashBackColor = 0 ' steady while tag = 0
End If
7.3 Synthetic trigger pattern (recommended for large screens)
' PLC toggles "Trig_Pulse" each time the pointed-to value mutates.
' Bind Flashing Background Active of CircleX to Trig_Pulse, mode = On change.
Dim oTrig, oCirc
Set oTrig = HMIRuntime.Tags("Trig_Pulse")
Set oCirc = ScreenItems("CircleX")
' Toggle the flash each edge so the visible rhythm is independent of PLC rate
If oCirc.FlashBackColor = 0 Then
oCirc.FlashBackColor = RGB(0, 255, 0)
Else
oCirc.FlashBackColor = 0
End If
7.4 Optional: setting both colors inside the same VBS
If you want the foreground (text / border) to swap as well, repeat the assignment for FlashForeColor:
oCirc.FlashBackColor = RGB(255, 255, 0) ' yellow background on flash
oCirc.FlashForeColor = RGB(0, 0, 0) ' black foreground on flash
If you do not write either property, the runtime falls back to the values configured in FlashColorOn / FlashColorOff in the property dialog.
8. Property Reference
| Property / method | Type | Read / Write | Purpose |
|---|---|---|---|
| HMIRuntime.Tags(name) | Collection member | R | Returns the Tag wrapper for a configured HMI tag. |
| Tag.Read | Variant | R | Returns the current runtime value (Bool → -1/0, Int → numeric). |
| Tag.Write value | Sub | W | Pushes a value back to the PLC (respects acquisition cycle). |
| ScreenItems(name) | Collection member | R | Returns the runtime object handle for any named screen item. |
| Circle.FlashBackColor | Long (BGR color) | R/W | Alternate background color used while flashing. |
| Circle.FlashForeColor | Long (BGR color) | R/W | Alternate foreground color used while flashing. |
| Circle.FlashRate | Enum | R/W | 0 = slow (2 s), 1 = medium (1 s), 2 = fast (0.5 s). |
| Circle.Flashing | Bool | R/W | Master enable; set True for the engine to drive the swap. |
| RGB(r,g,b) | Function | — | Builds a Windows color long from R/G/B triples (0–255). |
9. Performance Optimization Strategy
The original 2-second callback is the data update cycle of the HMI tag, not the visual flash period. To eliminate the constant polling load, apply the following in order:
- Switch the trigger to On change on the Flashing Background Active event. This is the single highest-impact change.
-
Cache the Tag and ScreenItems references outside the VBS using module-level variables, or read them once on the Open screen event and store them on a global dictionary. Every
HMIRuntime.Tags(name)call performs a name lookup in the tag collection. - Prefer the static Flash variable where possible. If the indirect tag is one of a known small set (e.g. 8 alarms), declare 8 real Boolean tags at project compile time, point the flash property at the right one from a value-driven dynamic dialog, and drop the VBS entirely.
-
Group multiple flashes under a single common parent that owns a master
Flashing = 0disable. DisablingFlashingon a parent group stops the engine from invoking the event on children. - Reduce acquisition rate only as a last resort; lowering the project update cycle degrades the whole HMI, not just the flashing objects.
10. Verification Procedure
- Compile and download the project to the panel or PC runtime.
- Open the screen containing
CircleX. Start the runtime tag simulation (Tools > Tag simulation in TIA Portal) and forceSel_Ato1. - Confirm the circle begins flashing at the configured Flash rate. Color should be the value written to
FlashBackColor. - Force
Sel_Ato0. Flashing should stop within one tick. - Open the runtime diagnostics (Control Panel > System > Runtime diagnostics or the Performance indicator in WinCC RT Professional). The VBS invocation count for the object's event should drop from one call every acquisition cycle to one call per actual state change.
- Watch the CPU load of the HMI process. On a representative screen with 20 flashing objects, the typical reduction is 15–40 % of the scripting thread's CPU when switching from cyclic to on-change triggering.
11. Troubleshooting Matrix
| Symptom | Likely cause | Fix |
|---|---|---|
| VBS fires every 2 s, performance drops. | Default cyclic acquisition on Flashing Background Active. | Switch the event's trigger to On change; bind to the real tag or a synthetic trigger pulse. |
Circle never flashes even though Sel_A = 1. |
Flashing master property is disabled, or FlashRate is 0. |
Enable Flashing in the property dialog and set a non-zero flash rate. |
| Flash color is the default green/red regardless of VBS. | VBS writes FlashBackColor but the runtime uses FlashColorOn / FlashColorOff because the master Flashing toggle is on a different path. |
Set FlashColorOn / FlashColorOff in the property dialog OR clear the dialog values so the VBS becomes authoritative. |
| Indirect tag pointer returns wrong value. | Tag name built with wrong byte offset or wrong DB number. | Validate sTag string in the TIA Portal HMI tag table; confirm bit / byte alignment in the PLC DB. |
"Object required" runtime error on ScreenItems("CircleX"). |
Object name misspelled, or the script runs on a screen that does not contain CircleX. |
Verify the object name (case-sensitive) and ensure the screen is the active one when the event fires. |
| Tag read returns stale value. | Acquisition cycle of the tag is longer than the flash rate. | Lower the tag's acquisition cycle to ≤ 1 s, or move to event-driven acquisition if the source is a discrete bit. |
| Flashing works in the engineering preview but not on the panel. | VBS execution disabled by runtime security, or project compiled without the VBS option. | Enable VBS in Runtime settings > Security; recompile and re-download. |
12. Frequently Asked Questions
Can the VBS be bound directly to a multiplex / indirect tag in the Flash variable field?
No. The Flash variable dialog expects a static HMI tag name. The standard way to combine indirect addressing with flashing is to drive the Flashing Background Active event from VBS, read the indirect tag through HMIRuntime.Tags(name).Read, and write the result to FlashBackColor.
Why does the VBS execute every 2 seconds even though I never call it from a timer?
Because the Flashing Background Active event is bound to the project's default Update cycle (typically 2 s for HMI tags). The runtime polls the bound trigger on that cycle and re-invokes the script. Switching the trigger to On change in the property dialog stops the polling.
Do I need to set FlashColorOn and FlashColorOff from VBS as well?
Only if you want the colors themselves to be dynamic. Otherwise, configure the two colors in the property dialog and let the runtime engine handle the swap; the VBS just decides which moment the swap is enabled by writing FlashBackColor to a non-zero value (or 0).
Is there a CPU or runtime cost difference between using VBS and using the dialog-driven Flash variable?
Yes. The dialog-driven path is a native engine call with no scripting overhead. VBS adds a per-tick interpreter cost that scales with the number of flashing objects. Use the dialog path whenever the trigger can be named statically; use VBS only when the trigger must be resolved through an index / pointer.
What is the recommended acquisition rate for a flashing object on a Comfort Panel?
For purely visual flash, leave Flashing + Flash rate at their defaults and bind the trigger to the underlying Boolean at On change. For VBS-driven color overrides, set the trigger's acquisition to On change and keep the tag's data update cycle at 1 s or slower to minimize polling.