CAN message in simulink

1 次查看(过去 30 天)
shiyad A
shiyad A 2020-3-20
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 CenterFile Exchange 中查找有关 Vehicle Network Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by