Support : Knowledge base

Knowledge Base

Welcome to OPAL-RT’s Knowledge Base

OPAL-RT offers a repository of support information for optimal use of its technology.

Loading…

Please note that OPAL-RT knowledge base is not fully optimized for mobile platforms.

For optimal experience, use a desktop computer.

Reference Number: AA-01806// Views: AA-01806// Created: 2019-12-28 07:28:06// Last Updated: 2019-12-28 07:29:38
HowTo
How to receive a message with a Kvaser CAN card

To learn about CAN basics, how CAN IO is set up in RT-LAB, and how to send a message, please view the following article: How to send a message with a Kvaser CAN card

This article assumes you have the basic knowledge covered in that article. We will use the same message for an example but configure it for reception.

Receiving a CAN message with RT-LAB

To receive a message with RT-LAB you will need to configure the message in the IO interface.

In RT-LAB, open your CAN IO interface, and select the message you want to configure for reception.




1. Set the mode to Reception

2. Make sure that the CAN ID matches that of the message you want to receive. Remember that on a decentralized CAN Bus, all nodes see all traffic, but they simply throw out the messages they aren’t set to receive. In RT-LAB, the CAN ID is the filter that determines if the message is received.

3. The Kvaser CAN card receives the messages from the CAN Bus at the arbitration bit rate that the channel is set to. 



These messages are then loaded into the model at each time step. The buffer size determines how many messages/frames are received during each time step. If the buffer size is set to more than one, then the set number of buffers will appear in the configuration tab each containing a connection point for all the signals.




4. The Data field needs to match that of the transmitted message. Each signal value will be interpreted by the bits in the positions represented here.

5. Same as number 4.

6. The Dataviewer for CAN is new to RT-LAB 2019.2. This enables you to view and record the messages without having to make a connection in the model.

If you use the promiscuous mode the CAN ID option will disappear, and the signals will be updated with whatever message/frame is received on the bus. It will not filter out the messages.



Monitoring CAN Messages/Frames

Now that your message is configured for reception in the IO interface, you have two options on how to monitor and log the data.

You can use the Dataviewer or make connections in the model to an OpInput block. Note that with both methods you still need to enable reception of that message. Use the OpOutput block per the transmission article to enable reception of the message/frame.

For more information on how to use the Dataviewer, see the following article: How to use the Dataviewer to monitor real-time bus traffic


To make connections in your model, an OpInput block is required for each signal.



The OpInput block in the model will send the data received on the Simulink line as a type double. You can send this data to a console, record it, or perform other operations on it. You also have the option to receive frame and bus status and flags.

To make a connection from an OpInput block to a point in your CAN IO configuration, use the same drag and drop method as with the transmitted signals (see related article).

On the configuration tab, notice that there are two types of points that you can connect to, the red and blue ones.



The red signals are outputs from the model and can only be connected to an OpOutput block.

The blue signals are inputs to the model and can only be connected to an OpInput block.

Note in the reception message, the enable is red as it still needs a connection from an OpOutput to enable the reception of the message.


Once the connections are made, you can now load the model and monitor a CAN Bus.