Initialization and Termination CAN Messages

The CAN Setup driver blocks for the supported CAN boards allow you to define CAN messages to be sent during initialization and termination of the real-time application. The driver blocks send these messages once at the beginning of each application run and once before an application run is stopped. The main purpose for sending these messages is to initialize or terminate other CAN nodes on the network, such as CANopen or DeviceNet nodes. Even if those CAN layers are not directly supported, the model can usually communicate with those nodes with standard CAN messages, provided the nodes are initialized. The initialization and termination fields of the Setup blocks are intended for this purpose.

You define the initialization and termination CAN messages by using MATLAB® struct arrays with CAN specific field names. This approach was also used for the RS-232 and general counter driver blocks found in the Simulink® Real-Time™ I/O library. Refer to those driver blocks and their help for additional information about this basic concept.

The CAN Setup block-specific field names are the following:

  • Port — Selects the CAN port over which the message is sent. Valid values are either 1 or 2 (double).

  • Type — Defines whether the message to be sent is of type standard or extended. Valid values are either 'Standard' or 'Extended' (character vectors).

  • Identifier — Defines the identifier of the message. The value (scalar) itself must be in the corresponding identifier range (standard or extended).

  • Data — Defines the data frame to be sent out along with the CAN message. The length of the row vector defines the data frame size.

    • If the CAN message data type is a CAN_MESSAGE data type, the value of the frame size vector must match the Length parameter of the connected CAN Pack block.

    • If the CAN message data type is a double, this field defines the data frame to be sent out along with the CAN message. The value must be a row vector of type double with a maximum length of 8. Each element of the vector defines 1 byte. In this case, the first element defines the data for byte 0 and the eighth element the data for byte 7. Each element can have a value from 0 through 255 (decimal).

  • Pause — Defines the amount of time, in seconds, that the Setup block waits after this message has been sent before sending the next message. Valid values are 0–0.05 seconds. Some CAN nodes need time to settle before they can accept the next message. For example, the node must settle when the previous message puts it in a new operational mode. Use this field to specify those idle times.

Was this topic helpful?