Skip to Main Content Skip to Search
Product Documentation

Detecting Timeouts When Receiving CAN Messages

The model in this topic supports the legacy double data type.

The Receive driver blocks for all CAN boards allow you to output the timestamp at which the latest corresponding CAN message was received. This information can be used to detect whether another CAN node is still active and therefore is sending CAN messages or is no longer active and special action must be taken. Assume that a CAN message is expected from another CAN node every 2 milliseconds. If no new message is received within 10 milliseconds, the other CAN node is considered faulty, and the Simulink model (target application) must proceed accordingly.

The CAN blockset in the xPC Target I/O block library provides a utility block called CAN Timeout Detection. This is a simple graphical subsystem (inspect it by looking under its mask) that uses the timestamp information to calculate the timeout condition.

A Simulink model using this block in conjunction with a Receive block could look as follows in the xpccanpci demo:

To change this model to use the CAN_MESSAGE data type, you can:

  1. Add a CAN Unpack block to the model.

  2. Connect the output of the receive block to the input of the CAN Unpack block.

  3. Double-click the CAN Unpack block.

  4. Select the Output timestamp check box.

    A Timestamp output port appears. Save and close the block dialog box.

  5. Connect the Timestamp output port to the inport port of the CAN Timeout Detection block.

  6. Save the model.

See xpccanpcis, a loopback example for the CAN-AC2-PCI board using CAN_MESSAGE data types for message storage.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS