How can I use sample time internally in Stateflow

15 ビュー (過去 30 日間)
GK
GK 2019 年 6 月 15 日
コメント済み: Dana Schwanke 2022 年 6 月 27 日
Hello,
My fixed solver discrete type model has sample time of 20ms.
I want to use this sample time in Stateflow to start a counter and increment it in 20ms time.
How can I use this sample time in Stateflow?
Thank you.
Note: If sample time changes, the counter should take the updated sample time.

採用された回答

GK
GK 2019 年 7 月 4 日
Also I found another solution on the mentioned mathworks link:
https://in.mathworks.com/matlabcentral/answers/54995-how-to-access-fundamental-sample-time-value-within-a-simulink-model
  1 件のコメント
Dana Schwanke
Dana Schwanke 2022 年 6 月 27 日
The information at that link does not seem to answer the question of determining a chart's sample time from inside the chart. Could you please elaborate or post the code you discovered?

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

その他の回答 (1 件)

Krishna Anne
Krishna Anne 2019 年 6 月 17 日
At the init trigger of your SF diagram start an independent counter and increment it by 1 (loop around). This way even if your solver settings change will be aligned with the counts as that many time samples.
Also, please remember that this is not the real definition of sample time, Simulink only mimics as per your solver settings. See the documentation about solver carefully.
  1 件のコメント
GK
GK 2019 年 7 月 4 日
Hi,
It is not clear how to use the counter with incremeting 1 can be used as timer.
Where should I initialize the counter? Where should I increment the counter?
Also my timer starts incrementing only when external condition become true.
Could you elaborate?

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

カテゴリ

Find more on Complex Logic in Help Center and File Exchange

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by