- Entry Actions: Statechart entry actions are executed when entering a state. To reset counters when re-entering a measuring state, you can use entry actions. In the entry action of the measuring state, reset the relevant counters to their initial values.
- Transition Actions: If you have specific conditions under which a state transitions to another state, you can use transition actions to reset counters. Before transitioning from the measuring state, set the counters back to their initial values.
- State Hierarchy: Consider organizing your statechart into a hierarchy that clearly represents the different stages of the process. This can make it easier to manage transitions and reset conditions.
Is there a way to reinitialize an enabled subystem that is controlled by a statechart every time it is entered?
3 views (last 30 days)
Show older comments
I have a main state chart that triggers a couple of enabled subsytems based on which state is currently active in the subsystem. As an example: A subsystem reads sensor data (using the Simulink Support Package for Arduino). The measured values are subjected to a couple of algorithms (to detect CRC errors, stationarity of the signal etc.) and based on the result of these algorithms the statechart may transfer to another state in the statechart. These algorithms are implemented using numerous counters. These counters should be reset when reentering the measuring state again.
I am having a hard time implementing these counters. So far I've tried using resettable one-step delays (z^-1) and resetting the counter value externally (from the statechart) when entering the measuring state (In state chart entry: reset_counter = 1;). However, the counter values are not reset once reentering the measuring state. (For example: If the counter has reached its max. value resulting in exiting this state, the state is exited again as soon as it is reentered.)
I've tried the Reinitalize Blocks but I think they are not supported in my case.
0 Comments
Answers (1)
Vidip Jain
on 31 Aug 2023
I understand you are having a hard time implementing these counters and their values are not reset once re-entering the measuring state.
Resetting counters and states when re-entering a state in a Simulink statechart can sometimes be challenging due to the asynchronous nature of statechart execution and the interaction between subsystems. It's important to ensure that counters are properly reset when needed, and that state transitions are managed correctly.
Here are some steps and considerations to help you achieve the desired behaviour:
Refer to this documentation for more information: https://www.mathworks.com/help/stateflow/gs/actions.html
0 Comments
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!