[Stateflow] The question about extra time step during transition

10 visualizzazioni (ultimi 30 giorni)
Hello. I'm a newbie to stateflow in Simulink. Around 2-3 days ago, I figured out someting making me confused a little bit. I set the sample time in Model Configuration Paremeters to 0.01 sec, as shown in Fig 1. Fig 2. to Fig 3. shows the working process at each time step of the system written by myself, which consists of 3 parellel parent states. All of them are related to time counters (timer1, timer2 and timer3, which are local variables).
*Note that T is executing time, shown at the lowest of each picture.
Fig 1. Sample time setting in Configuration Parameters (0.01 sec)
Fig 2. T = 0.000 sec
Fig 3. T = 0.010 sec
Fig 4. T = 0.020 sec
Fig 5. T = 0.030 sec
Fig 6. T = 0.040 sec
According to the Fig 5., when T = 0.030 sec and all values of timer counters (timer1, timer2 and timer3) already reached to "3", there were only the buttom parent state, "Sys3_condition_action", that moved itself from "Off" state to "On" state, although all transitional conditions between "On" and "Off" were simultaneously satisfied by their corresponding timer counts (equal to 3). While the upper and middle parent states, Sys1_during and Sys2_cyclic_updating respectively, would move to "On" state in the next time step, at T = 0.040 sec (shown by Fig 6.).
At the first, I thought that all parents state should work in the same manner (all transitions should occur at T = 0.030 sec). But in fact, it's not what I understand. Could someone explain to me why they worked differently?
Best Regards.

Risposte (1)

Sahas
Sahas il 5 Ago 2024
As per my understanding you would like to know the reason behind the execution order of the three parallel states where "Sys3_condition_action" moved itself to the “On” state at time-step T = 0.03 before the “Sys1_during” and “Sys2_cyclic_updating” which moved to the “On” state at time-step T = 0.04.
The first two parallel states follow a “direct transition”. Stateflow checks the “transition condition” first to decide whether to execute the transition. If the condition is met, the transition occurs in the same time step. If the condition is not met, it goes back to the previous state to execute it’s “State during” action.
In the third and fourth states, where a “junction” is involved, Stateflow updates the value of the variables in the “condition action” first and then checks the “transition condition”. If the conditions are met, the transition happens in the same time step.
To confirm this property of “junctions”, I added one more parallel state, “Sys4”, which was a copy of "Sys3_condition_action". I observed that “Sys3_condition_action” and “Sys4” were executing in parallel transtioning to the “On” state at time-step T = 0.03
To see the “value update first” property of “junctions”, I modified the “condition actions” of “Sys1_during” and “Sys2_cyclic_updating” to “timer1>= 2” and “timer2>=2”, respectively, as provided in the image and observed their values at time-step T = 0.03.
I was able to see that all four states reached the “On” state simultaneously at time-step T = 0.03. This was because “Sys1_during” and “Sys2_cyclic_updating” updated their value at time-step T = 0.02, checked their “condition action” at time-step T = 0.03, and immediately transitioned. Whereas “Sys3_condition_action” and “Sys4” updated their value at time-step T = 0.03 itself and then transitioned.
I hope this resolves the query.
For further information, please refer to the following MATLAB documentation links:
https://www.mathworks.com/help/stateflow/ug/what-do-semantics-mean-for-stateflow-charts.html -- Provides a basic understanding of the technical key words used in Stateflow charts.
https://www.mathworks.com/help/stateflow/ug/chart-initialization-and-entry-actions.html -- Shows the progression of events in Stateflow charts during entry in a state.
https://www.mathworks.com/help/stateflow/ug/chart-exit-actions.html -- Shows the progression of events in Stateflow charts during exit from a state.

Categorie

Scopri di più su Complex Logic in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by