S7-1200 SCADA Loss Detection: Watchdog Tag and Auto WiFi Reset

David Krause14 min read
S7-1200SiemensTechnical Reference
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

1. Problem Overview

Distributed remote sites that rely on Wi-Fi backhaul for SCADA telemetry are exposed to a recurring failure mode: the S7-1200 station controller remains fully operational, but the wireless link to the central SCADA server drops. Because the PLC has no way to know that the higher-level system is no longer requesting data, it never raises a station-level alarm, and field crews must travel to each site to power-cycle the Wi-Fi antenna.

This reference implements a one-way watchdog handshake between WinCC V7.5 SP2 and the SIMATIC S7-1200 station. The SCADA server cyclically toggles a heartbeat tag; the PLC monitors the tag for change. If the tag fails to toggle inside the configured time window, the PLC raises a digital output that drives a relay coil to remove and re-apply power to the Wi-Fi antenna. After a cooldown period the watchdog arms itself again, providing a self-healing remote station.

Functional scope: The handshake detects loss of the SCADA-to-PLC application path (server down, network outage, WinCC runtime stopped, antenna hung). It does not detect a PLC CPU stop or PROFINET cable failure; for those events use the S7-1200 diagnostic interrupts and the SF LED evaluation covered in the SIMATIC S7-1200 Programmable Controller System Manual.

2. Prerequisites

Component Specification Notes
S7-1200 CPU CPU 1214C DC/DC/DC, 1215C DC/DC/DC, or 1217C DC/DC/DC Firmware V4.2 or higher recommended for full TIA Portal V17+ support
TIA Portal V17, V18, or V19 with S7-1200 HSP STEP 7 Basic; SCL optional but recommended for structured logic
SCADA SIMATIC WinCC V7.5 SP2 (Update 7 or later) Global Script Runtime must be licensed and enabled
Protocol SIMATIC S7-1200 driver channel (TCP/IP, ISO-on-TCP) OPC UA is also valid; only the variable name changes
Wi-Fi antenna 12 V DC or 24 V DC powered industrial AP/bridge Confirm cold-boot time; typical 30-90 s
Output relay SPDT, 24 V DC coil, ≥ 5 A contact rating Use a snubber or flyback diode on the coil
Wiring Shielded 24 V DC, dedicated circuit breaker Keep antenna supply separate from PLC supply
Verify the WinCC station running V7.5 SP2 has the Global Script Runtime enabled in the WinCC Explorer under Computer → Startup. Without this service, VB and C actions are not executed. See the WinCC V7.5 documentation set at the Siemens Industry Online Support portal.

3. Architecture: One-Way Watchdog Handshake

The handshake is intentionally one-way: only the SCADA writes, only the PLC reads. This makes the design tolerant of asymmetric failures (e.g., PLC can still see the antenna, antenna cannot reach the server).

WinCC V7.5 SP2 Cyclic VB Action trigger 20 s Heartbeat Tag SCADA_HB (UINT) S7-1200 Channel TCP/IP ISO-on-TCP S7-1200 Station Heartbeat FB edge-detect + TON Comm OK flag %M100.0 Reset Pulse %Q0.0 (5 s ON) Field Relay 24 V coil Wi-Fi Antenna toggle drive power

4. WinCC V7.5 SP2 - Cyclic Heartbeat Action

Create a 16-bit unsigned integer tag named SCADA_HB mapped to a writable DB word on the S7-1200 (in this example, DB100.DBW0). In the WinCC Tag Management, confirm the tag is configured with the correct S7-1200 connection and address; WinCC V7.5 SP2 uses the SIMATIC S7-1200/1500 channel unit.

In WinCC Explorer, open Global Scripts → C-Actions (or VB-Actions), right-click and select New → Action. Configure the trigger as a cyclic trigger with a 20-second interval. Paste the following VB-Action into the editor:

' WinCC V7.5 SP2 - SCADA Heartbeat Toggle
' Trigger: cyclic, 20 s
Dim objTag
Set objTag = HMIRuntime.Tags("SCADA_HB")
objTag.Read
Dim curVal, newVal
curVal = CLng(objTag.Value)
newVal = curVal + 1
If newVal > 65535 Then
    newVal = 0
End If
objTag.Write newVal
Set objTag = Nothing

Save the action and verify it appears under the cyclic trigger list. Confirm the action executes by reading the tag in the WinCC variable diagnostics; the value must increment once per 20 seconds. Reference the WinCC V7.5 scripting entry at Siemens Support entry 109792622 for the full HMIRuntime object model.

Trigger selection: Do not tie the action to a screen open event. Use only the Standard cycle trigger so the heartbeat is independent of operator activity. If your WinCC project contains redundant servers, replicate the action on both servers; the active server writes the tag, the standby does not.

4.1 Optional: VB Action for Alarm Logging

Add a second cyclic VB action (1 s) that monitors a second tag (PLC_CommOK) sent from the PLC back to WinCC. When that bit clears, the action can fire an alarm using HMIRuntime.Trace for diagnostic logging:

' Alarm raise when PLC reports comm NOT OK for 30 s
Dim objAlarm
Set objAlarm = HMIRuntime.Alarms
Dim objTag
Set objTag = HMIRuntime.Tags("PLC_CommOK")
objTag.Read
If CLng(objTag.Value) = 0 Then
    objAlarm.CreateAlarm 1, 1, "Field station SCADA link lost", 0, 0, 0
End If
Set objTag = Nothing
Set objAlarm = Nothing

5. S7-1200 - TIA Portal Watchdog Implementation

The PLC side is built from three blocks: a data block, a function block containing the watchdog logic, and an OB1 rung that calls the FB.

5.1 Data Block DB100

Address Symbol Type Initial Value Description
DBW0 HB_FromSCADA UINT 0 Toggle value written by WinCC
DBW2 HB_LastSeen UINT 0 Last observed toggle value
DBW4 HB_Age_ms TIME T#0ms Elapsed time since last toggle
DBW8 HB_Timeout_ms TIME T#25s Time-out threshold
DBX10.0 CommOK BOOL FALSE TRUE while heartbeat is alive
DBX10.1 AlarmActive BOOL FALSE TRUE during the alarm state
DBX10.2 ResetPulse BOOL FALSE 5-s pulse to cycle antenna
DBX10.3 ResetLatched BOOL FALSE Latched to indicate at least one reset fired

5.2 Function Block FB_CommWatchdog (SCL)

Create FB_CommWatchdog using SCL for clarity. This block must be called from OB1 (or OB30 if you prefer a fixed 100 ms cyclic task).

FUNCTION_BLOCK "FB_CommWatchdog"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
VAR_INPUT
    i_Heartbeat : UINT;          // From DB100.DBW0 (WinCC toggle)
    i_Timeout   : TIME;          // Default T#25s
    i_Cycle     : TIME;          // OB1 call period, e.g. T#100ms
END_VAR
VAR_OUTPUT
    o_CommOK      : BOOL;
    o_AlarmActive : BOOL;
    o_ResetPulse  : BOOL;
    o_ResetLatched: BOOL;
END_VAR
VAR
    s_LastValue    : UINT;
    s_Age          : TIME;
    s_Init         : BOOL;
    s_PulseTON     : TON;        // 5 s reset pulse
    s_CooldownTON  : TON;        // 5 min re-arm
    s_AgeTON       : TON;        // re-trigger for age counter
END_VAR
BEGIN
    // Initialisation
    IF NOT s_Init THEN
        s_LastValue := i_Heartbeat;
        s_Age       := T#0s;
        s_Init      := TRUE;
    END_IF;

    // Edge detection on heartbeat
    IF i_Heartbeat <> s_LastValue THEN
        s_LastValue := i_Heartbeat;
        s_Age       := T#0s;
        o_CommOK    := TRUE;
        o_AlarmActive := FALSE;
    ELSE
        s_Age := s_Age + i_Cycle;
    END_IF;

    // Alarm condition
    IF s_Age >= i_Timeout THEN
        o_AlarmActive := TRUE;
        o_CommOK      := FALSE;
    END_IF;

    // 5 s reset pulse, with 5 min cooldown to prevent thrashing
    s_PulseTON(IN := o_AlarmActive, PT := T#5s);
    s_CooldownTON(IN := s_PulseTON.Q, PT := T#5m);

    o_ResetPulse := s_PulseTON.Q AND NOT s_CooldownTON.Q;

    // Latch for SCADA visibility
    IF o_ResetPulse THEN
        o_ResetLatched := TRUE;
    END_IF;
END_FUNCTION_BLOCK

5.3 OB1 Call

// OB1 - Main
"DB_Watchdog".i_Heartbeat := "HB_FromSCADA";
"DB_Watchdog".i_Timeout   := T#25s;
"DB_Watchdog".i_Cycle     := T#100ms;

"FB_CommWatchdog_DB"(
    i_Heartbeat  := "DB_Watchdog".i_Heartbeat,
    i_Timeout    := "DB_Watchdog".i_Timeout,
    i_Cycle      := "DB_Watchdog".i_Cycle,
    o_CommOK     => "CommOK",
    o_AlarmActive=> "AlarmActive",
    o_ResetPulse => "ResetPulse",
    o_ResetLatched=> "ResetLatched"
);

// Drive the antenna relay on Q0.0
"AntennaReset" := "ResetPulse";

// Mirror status back to WinCC
"HB_ToSCADA".CommOK      := "CommOK";
"HB_ToSCADA".AlarmActive := "AlarmActive";
"HB_ToSCADA".ResetLatched:= "ResetLatched";
Why use a UINT counter instead of a BOOL toggle: A counter exposes stuck-value scenarios that a boolean toggle cannot. If WinCC freezes a value at 1, a BOOL toggle stays at 1 and the watchdog would never see a change. With a UINT, the value must change by exactly the increment; a stuck value fails the check on the next cycle.

6. Hardware Output - Cycling the Wi-Fi Antenna

The ResetPulse signal is wired to a digital output module of the S7-1200 (for a 1214C the onboard %Q0.0 is sufficient). The output drives a 24 V DC relay whose contact breaks the L+ supply to the antenna. A second contact may be used to light a panel indicator.

6.1 Wiring Schematic

S7-1200 Q0.0 DC 24 V out Relay K1 24 V coil SPDT 5 A Wi-Fi AP 24 V DC Industrial AP L+ 24 V 24 V Common
Component Specification Rationale
Relay coil 24 V DC, ≤ 50 mA Within S7-1200 source output rating
Flyback diode 1N4007 across coil Suppresses back-EMF and prevents CPU fault
Contact rating ≥ 1.5× antenna steady-state current Industrial APs surge up to 2× at boot
Power supply Dedicated 24 V branch, 2 A min Isolate from PLC supply to ride through brief sags
Surge protection MOV or TVS across antenna input Outdoor antenna coax pickup

6.2 S7-1200 Output Rating Reference

Per the SIMATIC S7-1200 Programmable Controller System Manual, the digital outputs on a DC/DC/DC CPU source up to 0.5 A per channel at 24 V DC, derated to 0.3 A when grouped. The relay coil must stay below this limit; otherwise insert an interposing relay (Phoenix Contact PLC-OSC or equivalent) capable of switching the antenna supply.

7. Timing Parameters and Tuning

Select the four timing constants as a function of the application. The values below are starting points and must be tuned for the actual link and SCADA load.

Parameter Recommended Minimum Maximum Influence
WinCC toggle period 20 s 5 s 60 s Smaller value = faster detection, higher SCADA load
PLC timeout (HB_Age) 25 s 15 s 90 s Must be ≥ 2× WinCC period to tolerate one missed toggle
Reset pulse width 5 s 3 s 15 s Long enough to fully discharge AP bulk caps
Reset cooldown 5 min 1 min 15 min Allow antenna boot and reassociation before re-arming
OB1 cycle 100 ms 10 ms 200 ms Drives age counter resolution
Rule of thumb: Timeout ≥ 2 × WinCC period + network jitter. For a 20 s WinCC trigger with up to 4 s of network jitter, set the PLC timeout to 25 s. Setting the timeout too low causes false-positive resets when the Wi-Fi link momentarily pauses but recovers. Setting it too long delays intervention during genuine outages.

8. Commissioning and Verification

  1. Compile and download. In TIA Portal, compile the project and download the blocks to the S7-1200. Confirm the CPU transitions to RUN with no SF/BF LED activity.
  2. Verify the heartbeat writes. In WinCC, open the variable diagnostics (Tag Management → right-click the S7-1200 connection → Variable Diagnostics). Force an update on SCADA_HB and confirm the value increments every 20 s. Use the WinCC Online tag display to monitor.
  3. Verify the watchdog. In TIA Portal, place the PLC in Monitor & Modify on DB100. Confirm HB_Age_ms resets to 0 each toggle and CommOK stays TRUE.
  4. Simulate a SCADA outage. Stop the WinCC runtime. Within (timeout + 1 × cycle), confirm AlarmActive asserts and ResetPulse goes TRUE for 5 s.
  5. Confirm antenna cycle. With a multimeter on the antenna supply rail, verify 24 V → 0 V → 24 V transition during the reset pulse.
  6. Confirm recovery. Restart WinCC runtime. After one full toggle period, CommOK returns TRUE and ResetLatched remains TRUE until operator-acknowledged.
  7. Acceptance sign-off. Document the ResetLatched counter increments in the station logbook so field crews can audit auto-reset events.

9. Edge Cases and Field-Proven Caveats

9.1 Loss of WinCC Runtime vs. Loss of Network

The handshake cannot distinguish between the WinCC runtime crashing and the Wi-Fi link dropping. Both appear as a frozen heartbeat. This is intentional - the antenna reset cures the Wi-Fi case, and the WinCC case is harmless because the SCADA simply reconnects on its next polling cycle. Document this behaviour so operators do not interpret an antenna reset as a SCADA fault.

9.2 S7-1200 CPU Stop During SCADA Outage

If the CPU stops while SCADA is also offline, the relay coil de-energises and the antenna falls back to whatever state the relay uses as fail-safe (normally closed contact = continuous power). This is acceptable because no further automation can be performed until the CPU is recovered.

9.3 OB1 Cycle-Time Drift

The age counter increments by i_Cycle on each call. If OB1 is interrupted by long tasks (e.g., recipe block calls), the counter can drift. For deterministic behaviour, place the FB call in a cyclic OB30 with a fixed 100 ms period. Configure OB30 in Device configuration → Properties → System and clock memory → Cyclic interrupts.

9.4 Multiple Stations, One Heartbeat

Each of the eight water wells must have a unique SCADA_HB tag and a unique DB word on its respective PLC. Never share one heartbeat across stations - a single antenna failure would otherwise reset all eight sites, including healthy ones.

9.5 Stuck Value at 65535

The VB action wraps from 65535 to 0, which is still a transition and is correctly detected by the <> comparison. Do not use a comparison such as curVal + 1 = newVal on the PLC side; rely on <> which is robust against wrapping.

9.6 GPS-Synchronised Time Stamp

For diagnostic purposes, the PLC can stamp the last good heartbeat time into a DTL variable and mirror it to WinCC. This makes alarm correlation easier in the WinCC alarm log. Use the RD_SYS_T system function from the S7-1200 base library.

10. Troubleshooting Matrix

Symptom Likely Cause Diagnostic Step Corrective Action
ResetPulse fires repeatedly even though SCADA is online Timeout shorter than 2× WinCC period; or OB1 cycle drift Monitor HB_Age_ms in TIA Portal Raise Timeout to 30-40 s; move FB call to OB30
Antenna never cycles even when SCADA is offline Global Script Runtime disabled; VB action never fires Check WinCC Explorer → Computer → Startup Enable Global Script Runtime and reload project
CommOK never goes TRUE after commissioning First-call initialisation not triggered; or wrong tag address Monitor i_Heartbeat vs s_LastValue on first cycle Confirm DB100.DBW0 address; verify S7-1200 connection in WinCC
ResetPulse fires but antenna does not reboot Relay contact welded; or flyback diode missing Measure 24 V at antenna input during pulse Replace relay; install 1N4007 across coil
ResetLatched stays latched forever No operator acknowledgement logic Check HMI reset button Add WinCC button that writes FALSE to DB100.DBX10.3
CPU goes to SF on output driver Inductive load without flyback; or output overloaded Check SF LED; online diagnostics Install flyback diode; check load ≤ 0.5 A per channel
Tag value never updates in WinCC S7-1200 channel configured as read-only WinCC tag configuration Set tag to read/write; verify partner write access in DB properties

11. Operator HMI Display

Mirror the three PLC status bits back to WinCC and display them on the station faceplate:

  • CommOK - green indicator, steady on while link is healthy
  • AlarmActive - amber indicator, flashing during the cooldown
  • ResetLatched - red indicator, steady on after the first auto-reset, operator must acknowledge

This gives the operator immediate visibility of auto-recovery actions and forces acknowledgement so that the station logbook captures every intervention.

12. Variants and Extensions

12.1 Two-Way Handshake

If the SCADA needs to know that the PLC is in RUN, mirror a PLC RUN bit back to a PLC_Running tag and let the SCADA raise an alarm when it clears. This catches CPU STOP events that the one-way heartbeat cannot.

12.2 Multiple Reset Attempts with Escalation

Replace the single 5-minute cooldown with a counter that fires up to three reset attempts and escalates to a permanent alarm if the link does not recover. Use a CTU counter on ResetPulse rising edges; when the counter reaches 3, latch a HardFault bit and notify dispatch.

12.3 OPC UA Variant

For new WinCC projects using OPC UA, expose the heartbeat tag as an OPC UA writable variable on the S7-1200 OPC UA server (firmware V4.4+). The VB action remains identical except that HMIRuntime.Tags is replaced by the OPC UA channel name. Refer to the Siemens Industry Online Support S7-1200 OPC UA configuration guide for server-side setup.

FAQ

Can the S7-1200 detect SCADA communication loss without any WinCC-side script?

No passive detection is possible. The S7-1200 cannot observe that a higher-level system has stopped asking for data; it can only react when an expected change fails to arrive. The heartbeat handshake with a WinCC V7.5 SP2 VB action is the simplest robust implementation. Alternative architectures (PROFINET diagnostics, ISO-on-TCP keep-alive) require a programmable SCADA peer and do not work with simple polling clients.

What is the minimum S7-1200 firmware version for this design?

Firmware V4.0 supports all referenced instructions. For OPC UA exposure of the heartbeat, firmware V4.4 or higher is required on CPUs that support the OPC UA server feature (1215C, 1217C). Always confirm with the SIMATIC S7-1200 System Manual for the specific CPU order number.

How long should the WinCC toggle period be for an eight-station Wi-Fi network?

Use 20 s. Shorter intervals increase SCADA CPU load on the central server and risk coincident polling on the shared radio channel. Longer intervals delay detection. The PLC timeout must be set to at least 2× the toggle period plus observed network jitter; 25 s is a safe starting value.

Will the antenna reset damage the Wi-Fi equipment?

Industrial-grade APs tolerate hard power cycles at the rate used here (one cycle every 5 minutes, up to 3 cycles). Verify the equipment datasheet for hot-plug endurance. For consumer-grade equipment, increase the cooldown to 15 minutes and limit to a single reset before escalating to a permanent alarm.

What happens if both the SCADA server and the antenna fail simultaneously?

The handshake treats both failures identically: the heartbeat freezes and the PLC fires a reset pulse. If the antenna is the root cause, the reset restores the link. If the SCADA server is the root cause, the antenna reset is harmless and the link recovers as soon as the server is back. To distinguish the two, instrument the PLC to capture a timestamp and counters so post-incident analysis can correlate with WinCC alarm logs.

Back to blog