Set step-time as variable in exported code

5 ビュー (過去 30 日間)
Jeff Hough
Jeff Hough 2019 年 1 月 25 日
コメント済み: TRONG LINH VU 2025 年 10 月 31 日 4:47
Hello,
I've developed a controller in simulink and am trying to export it as a pure C class using simulink coder for deployment on our microcontroller.
We are using a fixed-step solver in simulation, however, when the exported code gets used on our actual plant, the computation step-size may change depending on load of the processor.
My concern is this: say I have set the fixed-timestep as 0.05s in simulation (and therefore the exported code assumes it is being executed every 0.05s), but then the microprocessor somtimes executes after 0.1s, and somtimes after 0.03s, etc. I think this would cause some unwanted behaviours.
Is there a way to have simulink coder create a variable for step-time that we can adjust during runtime? That is, measure how long it has been since the last execution, and then fill in the variable during each execution.
For an analogy, in videogame programming the update functions usually include a dt paramater so we know how long its been since the last frame.
Thanks
  2 件のコメント
Jeff Hough
Jeff Hough 2019 年 1 月 25 日
The only solution I can find is to manually search and replace the step size in all the integrator blocks however that seems error prone.
TRONG LINH VU
TRONG LINH VU 2025 年 10 月 31 日 4:47
Wanted to follow up with this @MathWorks Support Team

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by