Stateflow Stop Button

조회 수: 16 (최근 30일)
MathWorks Support Team
MathWorks Support Team 2017년 10월 25일
편집: MathWorks Support Team 2023년 4월 13일
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일
편집: 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