Stateflow Stop Button

16 次查看(过去 30 天)
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?

采纳的回答

MathWorks Support Team
编辑:MathWorks Support Team 2023-4-13
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Control Simulations with Interactive Dashboards 的更多信息

标签

尚未输入任何标签。

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by