WinCC Alarm Control: Animating Button Flash on Active Alarms

David Krause10 min read
SCADA ConfigurationSiemensTutorial / How-to
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

Overview

The Siemens WinCC Alarm Control displays process messages with state, priority, and acknowledgment columns. Operators frequently need an at-a-glance indicator outside the alarm window: a header button, a screen-level graphic, or a toolbar icon that flashes whenever at least one unacknowledged or active message exists. WinCC provides two complementary mechanisms to surface that information to a tag, and either mechanism can drive the native Flashing property of any graphic object:

  1. Group Status Tag - a 32-bit DWORD inside AlarmLogging that encodes the current state of every message in a configured group or message class.
  2. GMsgFunction() - a WinCC global C-script function called automatically on message events (come, go, acknowledge) that lets you write a custom tag or trigger an animation.

Both approaches are valid in SIMATIC WinCC V7.5 SP2 and later, as well as in WinCC Professional (TIA Portal) V17 and newer. The configuration path differs in dialog labels, but the underlying tag, event, and animation model is identical.

Prerequisites

  • WinCC Explorer project loaded in WinCC V7.x or TIA Portal with a WinCC Professional runtime.
  • An Alarm Logging editor with at least one configured message class (e.g., Error, Warning) and at least one single message or limit-value message.
  • A button or graphic object on a process picture where flashing should occur.
  • An internal tag of type WORD or BOOL created in the tag management to drive the animation.
  • For VBS: Microsoft VBScript runtime registered with WinCC (default installation).
Important: A button acknowledge in the Alarm Control is purely an HMI-side operator action. Acknowledging a message in WinCC does not clear the PLC bit that raised it. The flashing indicator therefore should reflect the alarm state, not the acknowledge state, unless you deliberately choose to do so.

Method 1 - Group Status Tag (Recommended for Simple Cases)

The Group feature in Alarm Logging exposes a packed status DWORD that summarizes all messages belonging to the group. WinCC evaluates the DWORD on every message state change, so the value is always live.

Status Tag Bit Layout

Bit Meaning Typical Use
0 Messages present, not acknowledged, currently active (came in) Highest priority indicator
1 Messages present, not acknowledged, currently inactive (went out without ack) Pending attention list
2 Messages present, acknowledged, currently active Acknowledged but still active
3 Messages present, acknowledged, currently inactive Cleared queue
4-31 Reserved / message-class specific extensions Vendor-defined

If you only need a single boolean that is 1 whenever any active or unacknowledged message exists, evaluate bit 0, or test the DWORD against zero.

Configuration Steps

  1. In the WinCC Explorer tree open Alarm Logging.
  2. Right-click the Message Classes node (or any user-defined group) and select Properties.
  3. Switch to the Group Messages tab.
  4. Click Add to create a new group (for example GRP_ProcessErrors).
  5. Check Status Tag and select an existing internal tag, or create one named Tag_AlarmStatus of type DWORD.
  6. Click OK and assign every single message that should drive the indicator to the group. This can be done per-message on the Properties > Groups tab, or in bulk using the message class assignment editor.
  7. Compile Alarm Logging (File > Compile or F7).

Wiring the Tag to the Button Flash

  1. Open the process picture containing the button in Graphics Designer.
  2. Select the button object and open Properties > Miscellaneous.
  3. Set Flashing to Yes.
  4. Open the Flashing Background dynamic dialog and bind it to a tag trigger.
  5. Select the property Background Flashing On (or Flashing State) and configure a C-action or direct tag link:
    BOOL bFlash = (GetTagDWord("Tag_AlarmStatus") > 0); return bFlash;
  6. Configure Flash Frequency to a comfortable rate, typically 500 ms on / 500 ms off for operator-attention level alarms.

Method 2 - GMsgFunction() for Custom Logic

When the group-status semantics do not match your use case - for instance, you need to fire only on messages from a specific source, area, or priority - use GMsgFunction(). This is a C-script callback invoked by the WinCC message system on every state transition. The signature is:

void GMsgFunction(DWORD dwMsgServiceID, DWORD dwMsgID, DWORD dwMsgState, DWORD dwMsgNr, char* lpszMsgText, char* lpszMsgName)

Parameter Reference

Parameter Description
dwMsgServiceID Service provider ID (always MSG_SERVICE_ALG for Alarm Logging)
dwMsgID Internal message number assigned at compile time
dwMsgState Bitwise OR of message state flags
dwMsgNr User message number from configuration
lpszMsgText Pointer to formatted message text
lpszMsgName Pointer to message name / class

dwMsgState Bit Definitions

Constant Value Meaning
MSG_STATE_CAME_IN 0x00000001 Message active, not acknowledged
MSG_STATE_GO_OUT 0x00000002 Message cleared, not acknowledged
MSG_STATE_ACK 0x00000004 Operator acknowledged the message
MSG_STATE_RESET 0x00000008 Message reset (cleared and acknowledged)
MSG_STATE_COMING 0x00000010 Message appeared (CAME_IN OR GO_OUT transition)
MSG_STATE_GOING 0x00000020 Message leaving active state
MSG_STATE_CHANGE 0x00000100 State changed (operator or process)
MSG_STATE_PROCESS 0x00000200 Process-acknowledged state

Sample GMsgFunction Implementation

// GMsgFunction.c - placed under "Standard Functions" in C-Editor
#include "apdefap.h"

void GMsgFunction(DWORD dwMsgServiceID, DWORD dwMsgID, DWORD dwMsgState,
                  DWORD dwMsgNr, char* lpszMsgText, char* lpszMsgName)
{
    static DWORD s_dwActiveCount = 0;

    // Came-in transition: increment counter
    if (dwMsgState & MSG_STATE_CAME_IN)
    {
        s_dwActiveCount++;
    }
    // Going-out transition: decrement counter
    if (dwMsgState & MSG_STATE_GOING)
    {
        if (s_dwActiveCount > 0) s_dwActiveCount--;
    }
    // Optional: skip process-acknowledged messages
    if (dwMsgState & MSG_STATE_PROCESS) return;

    // Drive an internal tag that the button flash listens to
    SetTagDWord("Tag_AlarmFlash", s_dwActiveCount);

    // Direct boolean for simple blink
    SetTagBit("Tag_AlarmFlashBit", (s_dwActiveCount > 0));

    // Suppress unused-parameter warnings
    (void)dwMsgServiceID;
    (void)dwMsgID;
    (void)dwMsgNr;
    (void)lpszMsgText;
    (void)lpszMsgName;
}
Compile and register: GMsgFunction is a global function, not a project function. It is defined once in the C-Editor under Standard Functions > Internal. After editing, press F7 to compile. WinCC will not call the new logic until the runtime is restarted (or the Alarm Logging subsystem is recompiled at runtime in V7.4+ with the appropriate licensing).

Method 3 - VBScript Approach (WinCC Professional / TIA Portal)

In WinCC Professional (TIA Portal), the C-script language is replaced by VBScript. The same effect is achieved by attaching a VB action to a tag trigger in Alarm Logging:

  1. In the TIA Portal project tree, open HMI Tags and create an internal tag Alarm_Flash of type Bool.
  2. In the alarm editor, open Settings > Acknowledgement concept and ensure Single acknowledgment is selected (or the variant matching your process).
  3. Open the message class or message itself and switch to the Events tab.
  4. Add a VB action on the Come event:
    SmartTags("Alarm_Flash") = True
  5. Add a VB action on the Go event:
    SmartTags("Alarm_Flash") = False
  6. Bind the button's Flashing property to Alarm_Flash.

For an aggregated count (more than one active message) use a global VBScript module:

' Module: AlarmAggregator
Dim gActiveCount : gActiveCount = 0

Sub OnAlarmCome()
    gActiveCount = gActiveCount + 1
    SmartTags("Alarm_Count") = gActiveCount
    SmartTags("Alarm_Flash") = True
End Sub

Sub OnAlarmGo()
    If gActiveCount > 0 Then gActiveCount = gActiveCount - 1
    SmartTags("Alarm_Count") = gActiveCount
    If gActiveCount = 0 Then SmartTags("Alarm_Flash") = False
End Sub

Button Flashing Property Configuration

The button object on the process picture is configured identically for all three methods. The flashing visualization in WinCC uses two on/off periods and an optional alternating background color.

Property WinCC V7 (Graphics Designer) WinCC Professional (TIA)
Enable flashing Properties > Miscellaneous > Flashing = Yes Properties > Animations > Flashing
Frequency Flash Frequency (Slow=1 s, Medium=500 ms, Fast=250 ms) Flashing rate in ms
Color Flash Background Color + Flash Foreground Color Background flashing color
Trigger tag C-action on Flashing State returning BOOL Tag or expression on the animation trigger

Verification Procedure

  1. Open WinCC Runtime in simulation mode (Start > Runtime or F5 in Graphics Designer).
  2. Trigger a configured alarm using the alarm control's right-click Acknowledge simulation or by forcing the underlying PLC tag in PLCSIM / S7-PLCSIM.
  3. Confirm visually that the button starts flashing within one update cycle (default 250 ms).
  4. Acknowledge the alarm in the Alarm Control and verify that the button continues to flash if you bound the trigger to any active message, or stops flashing if you bound it to unacknowledged active messages only.
  5. Reset the alarm source and confirm the flash terminates.
  6. Inspect the tag value with the WinCC Tag Simulator or with GetTagDWord() in a test script to confirm numeric values match expectations.

Troubleshooting Matrix

Symptom Likely Root Cause Corrective Action
Button never flashes Tag trigger not wired to Flashing State property Re-open button properties and bind the BOOL tag to the Flashing dynamic
Button always flashes Group Status Tag bound to wrong message class / group Verify the group membership in Alarm Logging and recompile
Flash stuck after acknowledgement Trigger bound to MSG_STATE_CAME_IN OR MSG_STATE_GO_OUT instead of MSG_STATE_CAME_IN only Re-evaluate dwMsgState in GMsgFunction and use the bit that clears on acknowledge
GMsgFunction not invoked C-function not compiled or runtime not restarted Compile in C-Editor (F7), stop and restart WinCC Runtime
VBS syntax error on compile SmartTags() used outside the global VBS module Define aggregator variables in a global module, not in picture scripts
Tag value shows 0 even with active alarm Group Status Tag assigned to a different message class than the active message Open the message properties and verify the Group assignment
Counter overflows on rapid alarms DWORD wraparound from spurious CAME_IN/GO_OUT pairs Debounce the trigger or use the pre-built Status Tag instead of a manual counter

Edge Cases and Field-Notes

  • Single-message group: If the group contains exactly one message, the Status Tag behaves like a 1-of-N indicator. This is the simplest deployment for a "button blinks when there is any problem" requirement.
  • Acknowledge semantics: WinCC distinguishes operator acknowledgment (clears the HMI flag) from process acknowledgment (PLC-driven). Bind to operator acknowledge if the operator is the source of truth; bind to process acknowledge if the PLC must confirm.
  • Redundancy: On a redundant WinCC pair, the Group Status Tag is replicated by the internal alarm logging redundancy. No additional configuration is required for the flashing tag.
  • Performance: GMsgFunction is called on every state change for every configured message. Keep its body under a few hundred microseconds; avoid logging or I/O inside the callback.
  • Tag licensing: Internal tags do not consume WinCC power tags. Group Status Tags also do not consume power tags. Only PLC-bound tags count toward the tag license.
  • Cross-picture use: An internal tag defined once in the tag management can be referenced from any number of pictures. A single Group Status Tag can therefore drive flashing indicators on every screen.
  • WebNavigator / WinCC Unified: In WinCC Unified V17, the equivalent of GMsgFunction is a JavaScript function bound to the alarm control's Events configuration. The same Status Tag mechanism is supported but is configured under Alarms > Alarm groups in the Unified Comfort Panel editor.

FAQ

What is the simplest way to make a button blink on any active WinCC alarm?

Create a Group in Alarm Logging, enable the Status Tag (DWORD), assign every alarm to that group, and bind the button's Flashing State C-action to GetTagDWord("Tag_AlarmStatus") > 0. Bit 0 of the DWORD is set whenever an unacknowledged active message exists.

Why does my button keep flashing after I acknowledge the alarm?

The trigger is bound to "any active message" rather than "unacknowledged active message." In GMsgFunction, use the dwMsgState bit MSG_STATE_CAME_IN (0x01) for unacknowledged-active, or use the Group Status Tag bit 0, which clears on operator acknowledgment.

Does acknowledging an alarm in WinCC clear the PLC bit that caused it?

No. WinCC acknowledgment is an HMI-side operator action only. The PLC tag that triggered the alarm is unaffected until the process condition is removed. Acknowledging only affects the alarm state visualization.

Can I count the number of active alarms in VBScript instead of C?

Yes. Define a global VBScript module with two Sub-routines (OnAlarmCome, OnAlarmGo), wire them to the message class events in the TIA Portal alarm editor, and increment or decrement a module-level counter. The counter is then written to an internal tag the button flash listens to.

What is the difference between the Group Status Tag and GMsgFunction()?

The Group Status Tag is a pre-built DWORD that WinCC maintains automatically for a configured group of messages - no scripting required. GMsgFunction() is a user-defined C callback invoked on every message state change, used when you need custom filtering, custom tag writes, or logic that the Status Tag does not expose. For a simple blink indicator the Group Status Tag is sufficient; for custom aggregation or routing use GMsgFunction().

Back to blog