Initialization and Termination CAN Messages

The CAN Setup driver blocks for the supported CAN boards allow the definition of CAN messages to be sent during initialization and termination of the real-time application (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. This is the case, for example, for CANopen or DeviceNet nodes. Even if those CAN application layers are not directly supported, communication with those nodes can usually be done over standard CAN messages as long as the nodes have been initialized. The initialization and termination fields of the Setup blocks are intended for this purpose.

You define the initialization and termination CAN messages using MATLAB® struct arrays with CAN specific field names. This is the same concept as 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 between 0 and 255 (decimal).

  • Pause — Defines the amount of time in seconds the Setup block waits after this message has been sent and before the next message defined in the struct array is parsed and sent. Valid values are between 0 and 0.05 seconds. Some CAN nodes need some time to settle before they can accept the next message, especially when the message just received puts the node in a new operational mode. Use this field to specify those idle times.

Was this topic helpful?