Stateflow Stop Button

16 views (last 30 days)
Is there a way to stop a simulation without leaving my Stateflow chart? Moreover, is there functionality for a push button or switch that will control a stop signal input to my chart?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 13 Apr 2023
Edited: MathWorks Support Team on 13 Apr 2023
Both of these requests can be accomplished as described below. The attached sample model, "stopStateflowExample.slx", provides an example for implementing these features.
1) Stop simulation within Stateflow diagram
This can be accomplished by creating a Simulink function in the Stateflow diagram that contains the "Stop Simulation" block connected to a constant block (with a positive value). When the logic of in the Stateflow diagram wants to stop the model, it simply calls this Simulink function. The attached model shows a simple implementation of this functionality.
The following documentation page gives further information on rules for using Simulink functions in Stateflow diagrams:
Run this command in MATLAB 2017a for documentation:
>> web(fullfile(docroot, 'stateflow/ug/simulink-functions-in-stateflow.html')
Or,
for latest release documentation please refer to:
2) Push button to stop simulation
Simulink includes a Push Button block in the Simulink > Dashboard library. This button can be connected to a constant block, such that when the button is pushed and held, the constant block changes its value. The input of the constant block is then used as an input to the Stateflow diagram to as a stop signal. This simple behavior is shown in the example model. Please refer to the following documentation page for more information on the Push Button block:
Run this command in MATLAB 2017a for documentation:
>> web(fullfile(docroot, 'simulink/slref/pushbutton.html'))
Or,
for latest release documentation please refer to:
Note that other blocks in the Dashboard library may be considered for this application, such as the Toggle Switch.

More Answers (0)

Categories

Find more on Control Simulations with Interactive Dashboards in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!