Page 878 - Mechatronics with Experiments
P. 878
864 MECHATRONICS
defined as a good programming practice. Although this is strictly not required, it is a
good programming practice to clearly define which state will be activated under unclear
conditions, such as on power-up. A transition can support two different actions
a condition action, and
a transition action.
Transition labels are defined in the following syntax (Figure A.37),
event [condition]{condition_action}/transition_action
where event defines the event that triggers the transition, [condition] must be true in order
for the transition to take place. Then the two sets of actions are performed, if defined. You
can specify some, all, or none of the parts of the transition label. Use “...” to continue on
the next line in defining the transition labels.
Connection junctions are used to provide multiple branch paths for a transition
between more than two states. They are equivalent to if-elseif-else decision blocks (Fig-
ure A.37).
History junctions provide the information on the most recent active sub-state in a
super-state or a chart. When a transition occurs to a super-state which has its sub-states and
history junction, the transition occurs to the sub-state that was active most recently, as a
result of the history junction component in the model. The history junction remembers the
last active sub-state. In other words, the history junction overrides the default transition if
they both exist in the same state hierarchy (Figure A.37). The history junction applies only
at the hierarchy in which it is placed.
Conditions are boolean logical expressions that must result in a true or false result.
For a transition to occur, the transition condition must be TRUE.
Events and data are non-graphical components of the SF chart. Events are defined
using the menu item in the SF editor,
Stateflow > Add > Event
Events can be defined to trigger a SF chart, trigger a transition to occur, trigger an action to
be executed. Data is a signal or local information needed and logic operations are applied
to. Data need to be defined in SF charts using menu item in SF editor,
Stateflow > Add > Data
These non-graphical elements of a state can be viewed and displayed by using the Model
Explorer. To do so, point to the state, right-click, and select Explorer from the pop-up
menu.
Step 5: Define Triggers to the Stateflow Chart. A Stateflow chart can be executed
at a specified rate or can be triggered by an external signal. Triggers are defined as a part
of events. In Stateflow Editor, use
Stateflow > Add > Event > Input from Simulink ®
®
to define a trigger event from Simulink to the SF chart. The signal source and the conditions
at which it causes a trigger (i.e., rising-edge, falling-edge, or both) can be defined.