필터 지우기
필터 지우기

How can I use sample time internally in Stateflow

조회 수: 14 (최근 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?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Complex Logic에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by