フィルターのクリア

Simulink arduino : compile unmodified code at every run

5 ビュー (過去 30 日間)
Delprat Sebastien
Delprat Sebastien 2022 年 11 月 30 日
回答済み: Siraj 2023 年 11 月 3 日
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
Naga 2023 年 10 月 13 日
Could you please elaborate on the specific intention behind running the model many times.
Delprat Sebastien
Delprat Sebastien 2023 年 10 月 13 日
The intention: gaining time on unecessary operations. Compiling an already compiled code is useless.
First intention: record pressure signals every time the unstable wake behind a ahmed body in a wind tunnel flips "randomly" from one pos to the other.
Second, I work with students in a lab, they have to perform several test on a systems related to controler synthesis.
With some digital input conntect to buttons, they can choose the input signal to be applied at the input. With a potentimeter, they can tune some parameters (freq & amplitude). So basically, the Simulink program is designed such that they can perform several experiments with some physical input and without modifying the code. The "smoothness" of this approach is broken by unecessary compilations.
Last but not least, the more complex your model is, the more time it takes to compile and why would your do something again and again when you know that it is unecessary?

サインインしてコメントする。

回答 (1 件)

Siraj
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.

カテゴリ

Help Center および File ExchangeEvent Functions についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by