CAN message in simulink

1 回表示 (過去 30 日間)
shiyad A
shiyad A 2020 年 3 月 20 日
回答済み: Harimurali 2024 年 2 月 7 日
hi,
I am facing a problem that How i can load base workbase message to my simulink vehicle network toolbox block CAN -transmit

回答 (1 件)

Harimurali
Harimurali 2024 年 2 月 7 日
Hi Shiyad,
The "From Workspace" block and the "CAN Pack" blocks can be used to load base workspace message to be used by the "CAN Transmit" block. Follow the below steps to do the same:
  • Store the data to be transmitted as part of the CAN message in a variable in the base workspace. The data should be in a format that the "From Workspace" block supports.
%For example
Data = [1 2 3 4 5 6 7 8];
% Create a time-structured data for the 'From Workspace' block
message_ts = struct('time', 0, 'signals', struct('values', Data));
  • Add "From Workspace" and specify the "message_ts" variable that is to be read from the workspace.
  • Connect the "From Workspace" block to the "CAN pack".
  • Specify the message name, CAN identifier, length etc. of the message in the block parameters dialog box of the "CAN Pack" block. The length specified should be equal to the number of data elements.
In this way you can transmit data from the base workspace as a CAN message in Simulink.
Refer the following documentations for information about:
  1. "From Workspace" block: https://www.mathworks.com/help/releases/R2023b/simulink/slref/fromworkspace.html
  2. "CAN Pack" block: https://www.mathworks.com/help/releases/R2023b/vnt/ug/canpack.html
  3. "can.Message" object properties: https://www.mathworks.com/help/releases/R2023b/vnt/ug/can.message-properties.html

カテゴリ

Help Center および File ExchangeVehicle Network Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by