Simulink arduino : compile unmodified code at every run
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Naga
le 13 Oct 2023
Could you please elaborate on the specific intention behind running the model many times.
Réponses (1)
Siraj
le 3 Nov 2023
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 commentaires
Voir également
Catégories
En savoir plus sur Modeling dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!