Are there other timer predicates than after() and before() in Simulink finite state machines?

4 ビュー (過去 30 日間)
I am currently learning how to model timed finite state machines with Stateflow.
I understand from the documentation that the only conditions available on a transition w.r.t. to timers (such as before(), after() and at()) all refer to the time elapsed since the originating state of the transition on which the timer is present was entered.
Is is possible to start a timer say in state A, let the timer run over several states, and check later in a state B if the value of the timer is greater or lower than a threshold?
Thanks,
Arnaud

採用された回答

Ryan G
Ryan G 2013 年 4 月 8 日
編集済み: Ryan G 2013 年 4 月 8 日
EDIT: I just realized you can get the simulation time from within stateflow. You can grab the simulation time when you enter the state and subtract that from the time when you exit the state to determine the time.
You could create a parallel state chart that is effectively a timer.
In a state within the timer you would loop using the after functionality and use a new variable to add seconds to the timer based on how you define the after logic. Every iteration is like a tick of the clock.

その他の回答 (2 件)

Siddharth
Siddharth 2013 年 4 月 10 日
Assign the simulation time to a variable when you enter state A (y1), then assign the simulation time to another variable in state B (y2). Subtract the 2 variables (y2 - y1). To get the simulation time from the beginning of the simulation, choose the approach based on the action language that you are using from the last entry in the table below:

Arnaud Dury
Arnaud Dury 2013 年 4 月 12 日
Thanks a lot for your answer.
My question was really about the existing timing predicates that can be used on a guard in a Stateflow, without resorting to API calls to get the simulation time for instance.
I understand from your answer that they are limited to after(), before() and at() relating to the moment the originating state of transition was entered, but a parallel state can indeed be used in this situation to act as a timer over several states, thanks for the suggestion.
Am I interpreting you right?
Best regards,
Arnaud
  1 件のコメント
Ryan G
Ryan G 2013 年 4 月 12 日
If you get it to work, then you are interpreting me correctly! I tried this out and Siddharth let me know that simulation time was the other option. I used both methods and they both work.

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

カテゴリ

Help Center および File ExchangeSyntax for States and Transitions についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by