Preventing False Falling-Edge Executions of WinCC Global Script Popups in PCS 7
In SIMATIC PCS 7 WinCC, a Global Script or C-action triggered by a digital tag executes on every change of that tag—both rising edge (0 to 1) and falling edge (1 to 0)—because the 'Tag Trigger' mechanism evaluates state alterations rather than binary TRUE conditions. If a popup window appears on both 0-to-1 and 1-to-0 transitions, it is because the script logic lacks an explicit boolean condition before invoking the window display function. To ensure the popup opens strictly on a rising edge (TRUE), wrap the display command inside an 'if (GetTagBit("tag_name"))' conditional block and return 0 in the else branch to exit silently on the falling edge.
Table of Contents
- Executive Summary
- Architecture and Fundamental Mechanics
- Step-by-Step Implementation Procedure
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Executive Summary
Human-Machine Interface engineering in SIMATIC PCS 7 WinCC often requires launching automated modal popups, operator confirmation prompts, or emergency notices across OS Client screens when an automation controller triggers an alert bit. A widespread programming defect occurs when an engineer configures a WinCC Global Action with a Tag Trigger on a boolean tag: while the popup correctly appears when the tag becomes TRUE (1), it unexpectedly pops up a second time when the controller resets the tag back to FALSE (0). This double-triggering confuses operators and disrupts active monitoring. This article explains how WinCC Tag Triggers evaluate binary signal transitions, contrasts C-script versus VBScript execution engines, and provides verified code implementations for rising-edge execution.
Architecture and Fundamental Mechanics
WinCC Event Triggering Engine, Tag Trigger Mechanics, and Edge Evaluation:
- How WinCC Tag Triggers Function:
- In WinCC Explorer, Global Script actions (C-actions and VBS actions) can be assigned cyclic timers (e.g. 1 sec, 250 ms) or Tag Triggers.
- When a Tag Trigger is configured on a WinCC tag (e.g.
gs_alarm_active), the runtime data manager monitors the tag value via event-driven notification from the communication channel. - Crucial Architectural Rule: The trigger event is defined as 'Upon Change' ($Tag_{new} \neq Tag_{old}$).
-
Consequently, the script engine is invoked BOTH when the tag transitions from
0 -> 1AND when it transitions from1 -> 0. -
Why the Popup Appears on the Falling Edge:
- If the C-script or VBScript contains unconditional window management commands (such as
SetVisibleorOpenScreen), the script executes those display instructions on every trigger cycle, regardless of whether the bit became TRUE or FALSE. -
To execute logic strictly on the rising edge, the script must explicitly inspect the tag's instantaneous boolean value at the start of execution.
-
C-Script Implementation Pattern:
- In ANSI-C, the standard API function
GetTagBit("TagName")returns1(TRUE) or0(FALSE). -
Using an
if (bstate) { ... } else { return 0; }structure ensures that when the tag transitions to0, the function terminates immediately without executing the visual popup logic. -
Multi-Client Broadcast Considerations:
- Running Global Scripts on OS Servers executes on the server console, not on operator client stations.
- To open popups across distributed OS Clients, the script must run within the client's local graphic context (such as
@screen.pdlor a background picture window) triggered by the local tag manager.
Step-by-Step Implementation Procedure
-
Correcting the ANSI C-Script Global Action:
* In WinCC Explorer, open Global Script -> C-Editor.
* Open the project action responsible for the popup (e.g.ShowAlarmPopup.pas).
* Replace the unconditional code with the following rising-edge evaluation logic:
```c
#include "apdefap.h"
void OnTagTrigger(char* lpszTagName)
{
BOOL bState = FALSE;
// Read the current state of the trigger tag
bState = GetTagBit("gs_popup_trigger");// Only execute popup display if the bit is TRUE (1) if (bState == TRUE) { // Set Picture Window to visible SetVisible("@screen.pdl", "PictureWindow_Popup", TRUE); SetPictureName("@screen.pdl", "PictureWindow_Popup", "AlarmNotice.pdl"); } else { // Optional: close popup when bit resets, or simply exit // SetVisible("@screen.pdl", "PictureWindow_Popup", FALSE); return; }}
`` * Compile the script (Compileicon) and verify0 Errors, 0 Warnings`.
* Save the action. -
Alternative VBScript Implementation:
* In WinCC Explorer, open Global Script -> VBS-Editor.
* If using VBScript, implement the equivalent check:
vbscript Sub OnTagTrigger() Dim bState bState = HMIRuntime.Tags("gs_popup_trigger").Read If bState = True Then HMIRuntime.Screens("@screen").ScreenItems("PictureWindow_Popup").Visible = True End If End Sub -
Verify Tag Trigger Configuration in Global Script:
* Open the Action Properties -> Triggers tab.
* Confirm that the trigger type is set to Tag ongs_popup_triggerwith Cycle set to Upon change.
Verification
- Activate WinCC Runtime.
- In the controller or WinCC Tag Management, toggle
gs_popup_triggerfrom0to1:
* Confirm that the popup window appears immediately on screen. - Close or acknowledge the popup window.
- Toggle
gs_popup_triggerfrom1to0:
* Confirm that the popup does NOT reopen, proving that falling-edge execution has been eliminated.
Limitations and Operational Precautions
Global Actions running in WinCC OS Server background do not possess a user interface and cannot display popups directly on OS Clients; popups intended for operator clients must be configured within the screen hierarchy (@screen.pdl or @Overview1.pdl) on the clients. Avoid rapid flickering of the trigger bit in the PLC, as multiple rising edges within milliseconds can spawn stacked windows.
Engineer FAQ
Why does my WinCC script run when the tag turns off (0)?
Because WinCC Tag Triggers execute on any value alteration ('Upon Change'), which encompasses both 0-to-1 and 1-to-0 transitions.
How do I make a C-script run only when a bit is 1?
Check the tag value at the beginning of the script using if (GetTagBit("tag")) and return immediately if the value is 0.
What is the difference between Tag Trigger 'Upon Change' and cyclic triggers?
'Upon Change' triggers event-driven execution only when the tag value changes, whereas cyclic triggers execute continuously at a fixed time interval.
Can I close the popup automatically when the bit turns 0?
Yes, place SetVisible("@screen.pdl", "PictureWindow", FALSE); in the else branch of the script.
Do global C-scripts run on OS Clients?
Client-specific scripts run on OS Clients if Global Script Runtime is enabled in the client's WinCC Computer Properties Startup tab.
Technical References
- SIMATIC WinCC V7.4 / V7.5 Scripting: VBS, ANSI-C, VBA Manual
- SIMATIC PCS 7 OS Process Control System Manual
- Siemens Industry Online Support - WinCC Tag Trigger Programming (Entry 22534571)
Related Articles
- Triggering Digital Tags and AS Logic on WinCC Alarm Acknowledgment in SIMATIC PCS 7
- Impact of Renaming CFC Charts on WinCC OS C-Scripts, VBScripts, and Tag Triggers in PCS 7
- Preventing OS Compilation from Overwriting Custom Picture Resolutions in PCS 7
- Troubleshooting WinCC Bar Graph Display Inactive with Yellow Warning Triangle in PCS 7
Related Tags
- WinCC Scripting
- Global Script
- Tag Trigger
- C-Script
- GetTagBit
- Falling Edge
- Pop-up Window
- PCS 7 V9.0