CAN protocol not working properly when Simulation pacing is not "real-time"

2 次查看(过去 30 天)
Hi all,
I'm prototyping something, and befor implementing it on my robot, I would like to test it on a simulink model.
As a starting point, I am trying to implement a very basic CAN protocol in one very simple simulink program (see attached file). As such it works, but if the simulation pace is increased weird things happen. I know it is possible to increase it without ruining the CAN protocol because in one of your examples it works (see: ">> openExample('vnt/CANConnectivityInARoboticsApplicationExample') " )).
Question 1: I would love to know what I should change in my simple program (see attached file) to make it work at fast pace.
Question 2: Assuming I build a Matlab App that communicates through a virtual CAN with a simulink model, what should I do to make it work (at a fast pace) too? (I guess something similar to the solution of my question 1)
Thank you in advance for your help and your time.
(Just in case: I know for real-time application the simulation pace should be real time, but for prototyping it's very convenient to get results faster :) )

回答(1 个)

Harimurali
Harimurali 2024-3-20
编辑:Harimurali 2024-3-25
Hi Aris,
I understand that you are trying to increase the simulation pace to prototype a CAN protocol before implementing it on your robot. I assume that you are doing this by setting the simulation pace using the Simulation tab and selecting Run > Simulation Pacing.
In simulink the model runs extremelly fast, that is, 1e6 tiimes faster than clock time. Setting the simulation pace to 1000 times means that it slows down the simulation and not actually make it faster. It is still faster than a second in real-time.
In this case, it is not possible to make a model run faster just for prototyping as this is dependant on other factors like the model simplicity, solver settings, parallel computation and cannot be achieved simply by setting the simulation pace of the model.
Simulink provides infrastrucure for effectively prototyping both hard and soft real time applications which you may refer to:
Please refer to the following example that shows how to run a CAN Communication Simulink model in Simulink Desktop Real-Time:

类别

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

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by