FB_PcWatchdog

FB_PcWatchdog 1:

This functionality is only available on IPCs with the following mainboards: IP-4GVI63, CB1050, CB2050, CB3050, CB1051, CB2051, CB3051.

FB_PcWatchdog 2:

The function block FB_PcWatchdog activates a hardware watchdog on the PC. The watchdog is activated via bEnable = TRUE and the timeout time. The timeout time can range between 1 and 255 seconds. The watchdog is activated via bEnable = TRUE and tTimeOut >= 1 s.

Once the watchdog has been activated, the function block must be called cyclically at shorter intervals than tTimeOut, since the PC restarts automatically when tTimeOut has elapsed. The watchdog can therefore be used to automatically reboot systems, which have entered an infinite loop or where the PLC has become stuck.

The watchdog can be deactivated via bEnable = FALSE or tTimeOut = 0.

Notice

PC reboot

The watchdog must be deactivated before breakpoints are used, before a PLC reset or an overall reset, before a TwinCAT stop, before switching to Config mode or before the configuration is activated, because otherwise the PC would reboot immediately once the timeout has elapsed.

FB_PcWatchdog 3: Inputs

VAR_INPUT
    tTimeOut : TIME;
    bEnable  : BOOL;
END_VAR

Name

Type

Description

tTimeOut

TIME

Watchdog time, after which a restart is performed.

bEnable

BOOL

Enabling/disabling the watchdog.

FB_PcWatchdog 4: Outputs

VAR_OUTPUT
    bEnabled : BOOL;
    bBusy    : BOOL;
    bError   : BOOL;
    nErrId   : UDINT;
END_VAR

Name

Type

Description

bEnabled

BOOL

TRUE = watchdog activated, FALSE = watchdog deactivated

bBusy

BOOL

This output remains TRUE until the function block has executed a command.

bError

BOOL

This output is switched to TRUE as soon as an error occurs during the execution of a command. The command-specific error code is contained in nErrId. Is reset to FALSE by the execution of a command at the inputs.

nErrId

UDINT

ADS error code or command-specific error code of the last executed command. Is reset to 0 by the execution of a command at the inputs.

Example of calling the function block in ST:

PROGRAM MAIN
VAR
    fbPcWatchDog  : FB_PcWatchdog;
    tWDTime       : TIME := T#10s;
    bEnableWD     : BOOL;
    bWDActive     : BOOL;
END_VAR

IF bEnableWD OR bWDActive THEN
    fbPcWatchDog(tTimeOut := tWDTime, bEnable := bEnableWD);
    bWDActive := fbPcWatchDog.bEnabled;
END_IF

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

IPCs with the following mainboards: IP‑4GVI63, CB1050, CB2050, CB3050, CB1051, CB2051, CB3051

PLC Lib Tc2_System