Clear Filters
Clear Filters

How can we read CAN message through Kvaser's CAN Device by Packet Input block in Simulink Desktop Real-Time?

17 views (last 30 days)
I'm trying to read IMU output, 8byte, though a Kvaser Leaf Light HS V2. I've installed Kvaser's drivers and i can read data by software supplied with the IMU.
Now, I'd like to read the output data in MATLAB. I've installed Simulink Desktop Real-Time and use the Packet Input block.
Although we can choose a Kvaser's CAN Device in the Packet block's parameter, "Install new board", do we need the Vehicle Network Toolbox?
I noticed that the similar problem is posted in the link bellow, but the posted date is 2015. Is this situation still the same today?
https://jp.mathworks.com/matlabcentral/answers/194604-is-the-kvaser-leaf-light-hs-supported-by-both-vehicle-network-toolbox-and-real-time-windows-target

Accepted Answer

Jan Houska
Jan Houska on 11 Jul 2024
Hello,
to read raw CAN data, Vehicle Network Toolbox should not be needed. You will need to specify the output data types (decode the raw CAN data) manually by entering the data types in the block dialog. Please see the sldrtex_canio shipping example.
If you prefer to use the CAN_MESSAGE or CAN_MESSAGE_BUS data types and the Vehicle Network Toolbox block library to decode the received data, then of course a license of Vehicle Network Toolbox is needed. Please see the sldrtex_canmessage shipping example to see how this can be done.
Good Luck, Jan
  3 Comments
Jan Houska
Jan Houska on 17 Jul 2024
Hello,
the CAN IDs are entered as decimal, not as hexadecimal. Please use the "hex2dec" function to convert, for example, 31A would convert to 794. I cannot tell if your data is Big Endian or Little Endian, but you probably have this one correct. I think everything else is correct as well.
Good Luck, Jan
友基
友基 on 21 Jul 2024
Dear Jan,
Thank you for your kind support. Now I can read the IMU mesurements over CAN by the Packet Input block.
I have tried the following steps:
  1. Power on the IMU before starting MATLAB/Simulink.
  2. Execute the Kvaser Device Guide and check the Canlib Channel number for the KVASER LEAF LIGHT V2. This number is "CAN channel" in Packet input block.
  3. Input decimal number in the CAN message ID in the block.
Regards, T.T.

Sign in to comment.

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!