WinCC VBScript · Alarms · Event Diagnostics

WinCC VBScript Alarm and Event Handling

Extend configured WinCC alarms with contextual diagnostics, controlled navigation and traceable event records without replacing the standard alarm lifecycle.

Guide Overview

Supporting WinCC VBS GuideStudy time: 65 minutesDifficulty: Intermediate

What You Will Design

  • Standard alarm versus supplementary script responsibilities
  • Context-aware diagnostic navigation and event records
  • Trace, timeout and failure-handling checks

WinCC VBScript alarm and event handling

This guide explains where VBS can support alarm diagnostics, operator navigation and custom event records while WinCC Alarm Logging remains responsible for alarm state, timestamp, acknowledgment and archive behavior.

Alarm-system boundary: Do not replace configured process alarms, safety alarms or required acknowledgment records with custom scripts. Alarm priorities, lifecycle, shelving, acknowledgment and historian retention must follow the approved alarm philosophy and platform configuration.

1. Define the alarm lifecycle before adding VBScript

Every alarm should have a documented source, priority, message, operator response, acknowledgment rule and return-to-normal behavior. Configure these functions in WinCC Alarm Logging wherever possible.

RequirementPreferred WinCC mechanismPossible VBS support
Alarm state and timestampAlarm LoggingNone required
Alarm acknowledgmentConfigured alarm controlSupplementary navigation or context only
Alarm archiveAlarm archive or approved historianOptional secondary event record
Diagnostic guidanceAlarm text and helpOpen a related diagnostic view
Custom notificationApproved notification subsystemTrigger a bounded, reviewed action

2. Read alarm context from approved tags

When a supplementary action is required, read a small set of explicit context tags rather than reconstructing the entire alarm state in VBS.

Function ReadAlarmContext()
    Dim alarmActive, equipmentId, faultCode

    alarmActive = HMIRuntime.Tags("Alarm_Active").Read
    equipmentId = HMIRuntime.Tags("Alarm_EquipmentId").Read
    faultCode = HMIRuntime.Tags("Alarm_FaultCode").Read

    ReadAlarmContext = CStr(alarmActive) & "|" & _
        CStr(equipmentId) & "|" & CStr(faultCode)
End Function

Confirm tag quality and data type in the deployed release. The configured alarm remains authoritative even if this supplementary read fails.

3. Open contextual diagnostics without creating popup storms

A high-priority alarm may offer a button that opens the relevant equipment diagnostic view. Avoid opening repeated modal windows automatically for every state change.

Sub RequestAlarmDiagnostic(ByVal equipmentId)
    If Trim(CStr(equipmentId)) = "" Then
        HMIRuntime.Trace "Diagnostic request rejected: no equipment" & vbCrLf
        Exit Sub
    End If

    HMIRuntime.Tags("UI_SelectedEquipment").Write CStr(equipmentId)
    'Call the supported popup or picture-window method for this WinCC release.
    HMIRuntime.Trace "Alarm diagnostic requested for " & _
        CStr(equipmentId) & vbCrLf
End Sub

Use a validated equipment map and the navigation pattern described in WinCC screen navigation, faceplates and reusable instances.

4. Record a supplementary event with stable fields

A custom record may capture diagnostic context not contained in the standard alarm message. Use a stable schema and avoid storing sensitive operator information unnecessarily.

Sub TraceAlarmEvent(ByVal equipmentId, ByVal faultCode, ByVal actionName)
    Dim eventLine
    eventLine = "ALARM_EVENT|equipment=" & CStr(equipmentId) & _
        "|fault=" & CStr(faultCode) & _
        "|action=" & CStr(actionName)

    HMIRuntime.Trace eventLine & vbCrLf
End Sub

For durable records, use the configured alarm archive, historian or approved database. HMIRuntime.Trace is primarily a diagnostic aid, not a compliance archive.

5. Support acknowledgment without bypassing WinCC controls

Use the supported alarm-control acknowledgment function and configured authorization. A script may prepare context or navigate to the alarm control, but it should not create an undocumented parallel acknowledgment mechanism.

  • Require the configured role for acknowledgment.
  • Preserve alarm identity, original timestamp and acknowledgment timestamp.
  • Do not acknowledge alarms automatically merely because a popup was opened.
  • Test acknowledgment during communication loss and redundant-server changeover where applicable.

6. Design sounds and notifications conservatively

Custom sounds or external notifications must be bounded, rate-limited and aligned with the alarm philosophy. Repeated script triggers can create duplicate notifications or operator overload.

  • Trigger on a defined state transition, not every cyclic evaluation.
  • Record delivery success and failure separately from alarm acknowledgment.
  • Provide a supported silence or escalation workflow.
  • Do not transmit plant or operator data to external services without approval.

7. Handle event-script failures explicitly

An error in a supporting script must not suppress the configured alarm. Keep the action small, trace the failing operation and clean up external objects.

Sub RunAlarmSupportAction()
    On Error Resume Next
    Err.Clear

    Call TraceAlarmEvent("M101", 27, "OPEN_DIAGNOSTIC")

    If Err.Number <> 0 Then
        HMIRuntime.Trace "Alarm support error " & CStr(Err.Number) & _
            ": " & Err.Description & vbCrLf
        Err.Clear
    End If

    On Error GoTo 0
End Sub

Continue with WinCC VBScript error handling and diagnostics for reusable failure patterns.

8. Test alarm transitions and recovery states

Test conditionExpected result
Alarm arrivesConfigured alarm appears once with correct priority and timestamp
Supporting script failsAlarm remains visible and script error is traceable
Alarm clears before acknowledgmentLifecycle follows configured policy
Unauthorized acknowledgmentRequest is rejected and alarm remains active or unacknowledged
Communication lossBad-quality or connection alarm behavior is explicit
Alarm burstNo uncontrolled popup, sound or notification repetition

9. Commissioning checklist

  • Review the alarm against the site alarm philosophy.
  • Confirm WinCC Alarm Logging owns lifecycle and acknowledgment.
  • Verify supplementary scripts are transition-based and bounded.
  • Test every user role and abnormal communication state.
  • Confirm custom records do not conflict with the approved historian.
  • Document triggers, context tags, navigation targets and failure behavior.

10. Example: bottling-line filler fault

A filler motor overload creates a configured WinCC alarm with priority, timestamp and acknowledgment requirements. The operator can open a motor-specific diagnostic faceplate, while a supporting VBS action traces the equipment identifier and fault code. Clearing or acknowledging the alarm still follows the configured alarm lifecycle; the script does not reset the drive or bypass the PLC fault logic.

Frequently asked questions

Should VBScript create every WinCC alarm?

No. Configure process alarms through WinCC Alarm Logging. Use VBS only for justified supplementary behavior.

Can a script automatically acknowledge an alarm?

That is generally inappropriate unless explicitly required, authorized and supported by the approved alarm philosophy. Preserve the standard acknowledgment audit trail.

Is HMIRuntime.Trace an alarm historian?

No. It is useful for Runtime diagnostics. Use Alarm Logging, a historian or an approved database for durable records.

How can popup storms be prevented?

Prefer operator-requested diagnostics, trigger on transitions, check whether the view is already open and rate-limit supplementary notifications.

Get the WinCC VB Scripting syllabus

Request practical online, classroom or corporate training details.

Build reliable WinCC VBScript projects

Join practical online, classroom or corporate training.

Request Course Details
Verified learning pathway

Discuss WinCC VB Scripting Training

Explore practical WinCC VBS, SCADA, SQL reporting and industrial automation training options.

Content reviewed: 4 August 2026

☎ Call WhatsApp ✉ Email Enquire Now