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!