- 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.
how to make sending CAN data until end time in simulink?
1 view (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
Harimurali
on 10 Nov 2023
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:
Please refer to the following documentation for more information about the “From Workspace” block:
0 Comments
More Answers (0)
See Also
Categories
Find more on Vehicle Network Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!