how to make sending CAN data until end time in simulink?

2 次查看(过去 30 天)
do you happen to know how to make sending CAN data until end time in simulink?
I make sending CAN data using .mat file but it has onaly 30sec.
I'd like to make sending CAN data around 70sec.
Could you please teach me how to make repeating .mat file untill end time?

采纳的回答

Harimurali
Harimurali 2023-11-10
Hi みほ,
I understand that you want to send CAN data using .mat file until the simulation ends in Simulink.
Please follow the below steps to implement a CAN communication Simulink model that sends CAN data using a .mat file till simulation end time:
  • Load the data to the base workspace from the .mat file using the “load” function in MATLAB.
  • Open a blank Simulink model and add the following blocks to the workspace:
  • “From Workspace” block from the “Simulink -> Sources library
  • “CAN Pack” block from the Vehicle Network Toolbox -> CAN Communication library
  • “CAN Transmit” block from the “Vehicle Network Toolbox -> CAN Communication” library
  • “CAN Configuration” from the “Vehicle Network Toolbox -> CAN Communication” library
  • Open the block parameter dialog box for the “From Workspace” block and set the following parameters:
  • Provide the variable name from the base workspace that is to be used as the data for CAN communication
  • Set the desired sample time
  • Uncheck the “Interpolate data” option
  • From the “Form output after final data value by” dropdown, choose “cyclic repetition”
  • Connect the “From Workspace” block to the input of the “CAN Pack” block.
  • Connect the output of the “Can Pack block” to input of the “Can Transmit” block.
  • Set the parameters according to the CAN device and channel.
  • In the Simulink toolbar, set the "Stop Time" to the desired end time of your simulation.
  • Click the "Run" button. The model will send the CAN data continuously until the simulation end time is reached.
Please refer to the following documentation for more information about the “From Workspaceblock:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by