xPC Target | ![]() ![]() |
Detecting Time-outs When Receiving CAN Messages
The Receive driver blocks for all CAN boards allow to output the timestamp at which the latest corresponding CAN message has been received. This information can be used to detect if another CAN node is still alive and therefore is sending CAN messages or is no longer alive and special action has to be taken. Assume that we expect a CAN message from another CAN node every 2 ms. If no new message is received within 10 ms the other CAN node is being considered faulty and the Simulink model (target application) has to proceed accordingly.
The CAN blockset in the xPC Target I/O block library provides a utility block called CAN Time-out Detection. This is a simple graphical subsystem (inspect it by looking under its mask) which uses the timestamp information to calculate the time-out condition.
A Simulink model using this block in conjunction with a Receive block could look as follows.
The dialog box of the CAN Time-out Detection block has one edit field and lets you define the time-out value in seconds. The output of the block will be 0 if no time-out has been detected and 1 otherwise. See as well the loop-back example for the CAN-AC2-PCI and CAN-AC2-104 boards (xpccanpci and xpccanpc104) which make use of this utility block as well.
![]() | CAN Bit-Unpacking Block | Model Execution Driven by CAN-Messages (Interrupt Capability of CAN Receive Blocks) | ![]() |