Documentation search search close
CONTENTS
https://www.speedgoat.com/help/slrt/page/icon_documentation.jpg
v10.0.1.x for R2026a
View other versions

IO602 Usage Notes

IO602 Usage Notes — Usage information about the I/O module

CAN Read Strategy

The "CAN Read" block reads one message from one channel of the module input queue. The "Data present" output port shows if there are more messages available in the queue.

The CAN receiver requires a do-while construction to ensure that all messages in the buffer are read at a given sample step. It is important to estimate the number of messages expected so that the correct sample time of the do-while subsystem is selected. The sample time of the subsystem is defined by Simulink inheritance rules: if the subsystem does not have input ports, it will inherit the fundamental sample time of the model. Alternatively, the sample time of the subsystem can be controlled by adding an input port. The sample time of the block connected to the input port is inherited by the subsystem.

The do-while construction iterates the CAN Read operation until the receiver buffer is empty (this information is provided by the Data present port). In the same subsystem, we can filter the messages required by the application.

The sample time must be chosen in order to avoid buffer overflow during a sample step. Furthermore, if multiple messages with the same Message ID are received, only the most recent messages will appear in the do-while subsystem output. To read all messages with a certain ID, the do-while subsystem must be run faster than the frequency of the message(s) in question.

For example, if Message ID 100 is expected with a frequency of 10 ms, and all these messages must be read, the do-while subsystem sample time must be faster than 10 ms, for example, 5 ms.

If there are other messages in the line, a check must be carried out to ensure that there is no message overflow; for example, with a buffer size of 501 messages (IO612), if 500 messages are expected within 500 ms, a sample time of 500 ms or slower may lead to the messages in the buffer being overwritten.

Top Level View

Inside the While Iterator Subsystem

The "Sample Time" input port defines the rate at which the subsystem is executed. Otherwise it will run on the base rate.

Initialization and Termination CAN Messages

The IO602 Setup driver block allows you to define CAN messages to be sent during initialization and termination of the real-time application. The driver block can send messages at each application start and stop. 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 the CAN layers are not directly supported, the model can usually communicate with these 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® structure 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 these driver blocks and their help for additional information about this basic concept.

The CAN Setup block-specific field names are:

  • Channel: Selects the CAN channel on which the message is sent. Valid values are either 1 or 2 (double)

  • Protocol: Defines the protocol type of the message to be either "CAN" or "CAN-FD". The permitted data range is automatically adjusted to be [0 8] byte for "CAN" or [0 64] byte for "FD". Use a character vector with this parameter

  • BRS: Defines if the fast data baud rate should be used for CAN-FD. Valid values are either 0 for standard baud rate or 1 for fast data baud rate (double)

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

  • Identifier: Defines the identifier of the message. The value (scalar) 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. The limits depend on the selection made for the Protocol parameter.

  • Pause: Defines the amount of time, in seconds, that the Setup block waits after a 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 the idle times.