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

15 次查看(过去 30 天)
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

采纳的回答

Jan Houska
Jan Houska 2024-7-11
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 个评论
Jan Houska
Jan Houska 2024-7-17
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
友基
友基 2024-7-21
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.

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by