# Watchdog mechanism

Watchdog, CNC monitors PLC
Description | The CNC uses the data of this unit to monitor whether the PLC is still ready for operation.

## Notice

When the PLC is being monitored by the CNC, the PLC task in which the PLC life sign alive_rw is set must be executed with a higher priority than the two CNC tasks SDA and COM.
In order to prevent problems with CNC block supply in large PLC projects, it is also recommended to relocate the watchdog functionality to an extra PLC task and to only assign this task with a higher priority.

Data type | MC_WATCHDOG_UNIT
ST Path | gpCh[channel_idx]^.head.mc_watchdog
PLC operates functionality
Description | By setting this element to the value TRUE, the PLC signals to the CNC that it supplies the data for the watchdog functionality.
ST Element | .enable_w
Data type | BOOL
Value range | [TRUE = PLC supplies data for a watchdog monitor, FALSE]
Access | PLC writes
PLC signal
Description | CNC uses this element to determine whether the PLC is invoked cyclically. The CNC only checks this element if the element “PLC operates functionality” and “PLC present” have the value TRUE.
ST element | .alive_rw
Data type | BOOL
Value range | [TRUE = PLC signals that it was invoked, FALSE]
Access | CNC detects whether this element changes from FALSE to TRUE within the time specified by the element "Watchdog cycle time". The PLC application must therefore ensure that this element is set cyclically to TRUE within the "Watchdog cycle time".

The CNC sets the value to FALSE after detecting this value.

Signal “PLC is invoked cyclically”
Description | After the first rising edge at the element "Signal from PLC", the CNC sets this signal to TRUE. The signal remains TRUE until the CNC detects that PLC is no longer invoked cyclically. If this happens, the CNC sets this signal to FALSE. In addition, the CNC outputs the error P-ERR-270053. This means the controller must be restarted.
ST element | .alive_state_r
Data type | BOOL
Value range | [TRUE = PLC is invoked cyclically, FALSE = PLC has not reported anything within the watchdog time or no rising edge was as yet detected on the "PLC signal"]
Access | CNC writes
Watchdog cycle time
Description | Cycle time of the watchdog. The values for the watchdog cycle time must be greater than the PLC cycle time in order to allow practical monitoring of the PLC by the CNC.
ST element | .cycle_time_w
Data type | UDINT
Unit | 1 µs
Access | PLC writes

Watchdog, PLC monitors CNC
Description | The PLC uses the data of this unit to monitor whether the CNC is still ready for operation.

## Notice

When the CNC is monitored by the PLC, the PLC task which checks for the CNC life sign alive_rw must be executed at a higher priority than the two CNC tasks SDA and COM.
In order to prevent problems with CNC block supply in large PLC projects, it is also recommended to relocate the watchdog functionality to an extra PLC task and to only assign this task with a higher priority.

Data type | LC_WATCHDOG_UNIT
ST Path | gpCh[channel_idx]^.head.lc_watchdog
CNC signal
Description | The CNC writes TRUE in this element in every interpolation cycle to confirm that the CNC was invoked.
ST Path | .alive_rw
Data type | BOOL
Access | The CNC writes the value TRUE in every CNC cycle to confirm its readiness for operation. PLC detects whether this element changes from FALSE to TRUE within the time specified by the element “Watchdog cycle time”. The PLC sets the value to FALSE after successful detection.
Signal “CNC is not invoked cyclically”
Description | If the PLC detects that the CNC is no longer ready for operation, it sets this element to TRUE.
ST Path | .alive_state_w
Data type | BOOL
Value range | [TRUE = CNC is not invoked cyclically, FALSE = CNC is invoked cyclically]
Access | PLC writes
Watchdog cycle time
Description | The NC kernel writes the interpolator cycle time in this element. The values for the watchdog cycle time must be greater than the PLC cycle time to permit practical monitoring of the CNC by the PLC.
ST Path | .cycle_time_r
Data type | UDINT
Unit | 1 µs
Access | PLC reads