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 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