Simulink arduino : compile unmodified code at every run
5 次查看(过去 30 天)
显示 更早的评论
I'm using an arduino MEGA 2650 + simulink model in external mode with the "Simulink Arduino package".
It works fine.
However, simulink is compiling and building the code at every simulation.
For instance, if you run 3 simulations in a row, without any changes (no block have been moved, all the parameters remains the same, etc) it will compile the model 3 times!!
This is long and causes problem for my application : simulation duration is 3 seconds, and compilation time is about 30 seconds.
So to perform 10 simulations, it takes 5 minutes instead of 1 minute (30 second first compilation + 10x3s simulations duration)
How can I ask Simumulink to reuse code if it hasn't been modified?
2 个评论
Naga
2023-10-13
Could you please elaborate on the specific intention behind running the model many times.
回答(1 个)
Siraj
2023-11-3
Hi!
It is my understanding that you are using an Arduino MEGA 2650 with Simulink in external mode. You are facing an issue where the Simulink model is being compiled and built every time you run a simulation, even if there are no changes to the model. This is causing a significant increase in simulation time.
One possible solution you can consider is utilizing the Model Reference feature in Simulink. Model referencing allows you to include one model within another by using a model block and you can take advantage of the Accelerator mode. In this mode, the C-code for the referenced model is generated only once and won't require re-compilation unless there are structural or dependency changes. This approach can help reduce simulation time by avoiding unnecessary code generation and compilation when there are no modifications to the model.
To learn more about model references and how to effectively use them in Simulink, you can refer to the following link:
For more information on optimizing simulation workflows in Simulink you can refer to the following link.
It covers various techniques, including model referencing, to modularize models and improve simulation speed. Additionally, it provides guidance on leveraging the Simulink cache effectively to reduce simulation time by reusing compiled code.
Hope this helps.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modeling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!