Stateflow: Event guards on a loop with super step semantics switched on not behaving as I want
4 次查看(过去 30 天)
显示 更早的评论
I have a timer which controls an events that is sent out at a particular frequency. I have a loop with one transition guarded by an event in the receiving statechart. I want to transition the event do a load of stuff in the chart, get back to the transition with the event guard and wait for the next clock tick/event. this doesn't happen in super state transition mode, the model doesn't stop at the event guard. How do I make the system stop at the event guard whilst using super step semantics? Probably some subtelty I am missing, think there must be some property of the event/ type of event guard I can use to do what I want without any trickery!
Thanks for any tips/ solutions
Richard
0 个评论
回答(1 个)
Riya
2025-8-13
Hi Richard,
I understand that you are trying to use an event guard on a loop in a Stateflow chart with super step semantics enabled, and you want the chart to “wait” at the event guard until the next clock tick/event. However, with super step semantics turned on, the model does not stop at the event guard as expected.
When running a similar setup, I observed that this happens because super step semantics executes transitions repeatedly within the same simulation step until the chart reaches a stable state. If your event is still considered active during that step, the guarded transition will immediately fire again instead of waiting.
To resolve this, you should introduce a delay or store the event in a local flag so the transition only becomes valid in the next simulation tick. Kindly refer to the following example approach using a local flag:
Step 1: Create a local data variable in the chart, for example:
eventFlag
with an initial value of “false”.
Step 2: In the state that receives the event, add an “on eventName:” action:
eventFlag = true;
Step 3: Now, guard your loop transition using:
[eventFlag]
Step 4: After processing the event in the target state, reset:
eventFlag = false;
Alternatively, if you prefer not to use a flag, you can enforce a simulation step delay in the transition guard (temporal logic method):
[after(0, tick) && eventName]
This ensures the transition will only be valid in the next tick, even with super step semantics enabled.
For further reference on “super step semantics” and “temporal logic” operators, kindly refer to the documentation below:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!