← All exercises

Watchdog Alarm

medium

Raise an alarm if the heartbeat input fails to pulse within the timeout.

What it teaches

Timer reset by an external pulse (the heartbeat). If the timer reaches preset before the next pulse, the watchdog fires. Teaches retriggerable-timer semantics and the canonical "missing-pulse alarm" pattern used in comms and equipment health monitoring.

Inputs and outputs

TagTypeDefaultDescription
In_HeartbeatBOOLHeartbeat signal to monitor
Cfg_TimeoutDINT1000Watchdog timeout in milliseconds
Sts_AlarmBOOL1 when the heartbeat is lost, 0 when active

Required behavior

  • The internal timer resets whenever In_Heartbeat transitions from 0 to 1.
  • If the time since the last In_Heartbeat rising edge reaches Cfg_Timeout, Sts_Alarm becomes 1.
  • Sts_Alarm clears to 0 as soon as a new In_Heartbeat rising edge is detected.