SC1c Mod 2.B App-Manual 684 BB
SC1c Mod 2.B App-Manual 684 BB
B -2
STATEFLOW Systems know states too, but they are only ‘true’ (= active)
or ‘false’ (= inactive).
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 1 2.B - 2
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -3 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -4
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 3 2.B - 4
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -5 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -6
All graphical elements are embedded in a Chart directly. >> sflib % only LIB
All non-graphical elements (e.g. events, data, …) are stored in a Data Dictionary.
History Junctions
Default Transition
Connective Junctions
Zoom
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 5 2.B - 6
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -7 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -8
Saving:
A ‘Chart’ is saved as a *.mdl-file SIMULINK-file !
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 7 2.B - 8
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -9 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -10
“exclusive” “parallel”
(Right Mouse superstate) Beside the state name “State1” you find four different actions, starting
with the keywords: entry, during, exit and on event.
K12_1a_STATES/Chart
Below an example: LEGOROBOT
S1 SuperState
P1 1
P2 2
FORW ARD
S2
entry:
after(T_TURN, SysClock)
after(T_TURN,SysClock) dir_motor_left=1;
dir_motor_right=1;
touch_sensor_right
TURN_RIGHT
TURN_LEFT entry:
P3 3 entry: dir_motor_left=1;
S3 dir_motor_left=2; dir_motor_right=2;
dir_motor_right=1; exit:
exit: lamp=0;
lamp=0;
touch_sensor_left
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 9 2.B - 10
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -11 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -12
This action is executed if we come This action is executed as long If we need the state activity outside of the Chart – that means in SIMULINK -
into this state via a valid transi- as no transition off the state is va- we select the button ‘Output State Activity’ in the menu ‘Properties’ (Right
tion. lid. Mouse Click on ‘State1’):
State 1
S cope
K12_1_Label1/Chart What is displayed on Chart
screen, if we define the
K12_1_Label1.mdl
condition as:
State1/ [cSF == 0]
en: aSF = 3
[cSF == 3] ?
cSF = 0
ex: bSF = aSF*aSF
State2/ Here: integration step ‘1 sec’
en: aSF = 6
K12_1_Label1/Chart
Pri nted 30-Jul- 2004 20:02:34
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 11 2.B - 12
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -13 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -14
Transitions exist between two States or between States and Junctions. K12_1_Transition1/Chart
A transition is a graphical object that links one object to another. One end S1
of a transition is attached to a source object and the other end to a destina- Event_S2 [ a ==4] {b = 5} / c = 6;
tion object.
The source is where the transition begins and the destination is where the
transition ends.
S2
A transition label describes the circumstances under which the system
moves from one state to another.
K12_1_Transition1/Chart
It is always the occurrence of some events that causes a transition to take
place.
A transition can be provided with Labels. Such a Label describes the con- “c = 6” is assigned, if ‘Event_S2’ occurs and ‘a == 4’ is true.
dition the transition is valid ! This happens after the transition is valid and performed.
A Label can consist of: an Event
a Condition
a Condition Action
a Transition Action
Syntax:
Event [Condition]{ConditionAction}/TransitionAction
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 13 2.B - 14
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -15 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -16
c) Connective Junctions:
Default transition A connective junction is a point of decision.
State1 We can construct: - for-loops
H
K12_1_BasicElements.fig
Transistion of one source to two destinations:
Chart_12_junctA/Chart
S2
In STATEFLOW exist three different types of transitions:
1. ‘Standard Transition’
Connection between Source and Destination Objects.
A Standard Transitions is performed, if the total path is E_one
valid. (See examples above). S1
2. ‘Default Transitions’
We get this transition from menu ‘Default Transition Tool’ of
E_two S3
Graphical Editor. – Default Transitions don’t have a source.
If no Label (incl. a Condition) is used (like in the Chart above),
this transition is always analyzed but is only performed as long Chart_12_junctA.mdl
as no other state is active. This situation is given at very be- Pri nted 01-Aug-2004 20:44:42
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 15 2.B - 16
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -17 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -18
E_alpha
S3 S1
S1
E_one {i =0}
E_S1
[i<10]{i++;k = 2*k}
E_beta
S2
S2
E_S2
Chart_12_junctB.mdl
events.
Chart_12_junctB.mdl
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 17 2.B - 18
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -19 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -20
2.B.2.3. Chart Properties and Trigger Methods 2.B - 19 Inherited / Triggered Update Method:
Handling of events An explicit external trigger signal (from SIMULINK) is necessary.
This external signal is defined in Data Dictionary as an event;
A STATEFLOW Chart is executed only by arising of events. (additionally to define: rising, falling or either edge of trigger signal).
(Bear in mind: FSM = event driven !)
Events can be generated: internal Chart Menu Add Event Input from Simulink Rising Edge
implicit (e.g. by activating a state)
external
At beginning of a simulation the Chart is inactive (= calm). To start
the FSM we need at least one external event, produced mostly by a Default
Transition. This event wakes up the Chart.
The rules activating a Chart by an external event can be designed individually
for each Chart. This is called: Individual Chart Update Method !
We differentiate between three methods activating a Chart:
Inherited Method
Discrete Method
Continuous Method
This three methods are chosen from menu: File/Chart Properties:
Special case: Function Call:
Inherited is the Stan-
dard-Update-Method Normally SIMULINK controls the execution of all subsystems;
a Chart is a SIMULINK subsystem too.
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 19 2.B - 20
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -21 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -22
Example 1: Triggered Update Rising Edge Example 2: Triggered Update Either Edge
ScopeData
2
ScopeData
2
1.5
y
S cope
S cope 1
y
State1
State1 0.5
0.5
O ut 300 0
O ut 0 0 2 4
sec
6 8 10
0
0 2 4 6 8 10 Chart Display
Chart Display sec
Comments:
Comments:
o Chart is activated by a step signal Trigger signal from
SIMULINK (rising edge at t = 1 sec): o Chart is activated by a step signal Trigger signal from ‘step’
State1 becomes ‘active’, because of the Default Transition. SIMULINK (rising edge at t = 1 sec):
State1 becomes ‘active’, because of the Default Transition.
o The Chart remains in State1, because no second trigger takes place.
The Scope – showing State1 activity - remains always at “1”, beginning o At t = 2 sec a second Trigger Signal (Step1) takes place, here as with
at 1 sec. a falling edge (negative sign):
The Chart moves from State1 to State2 !.
o Variable bSF is not assigned ! We don’t leave State 1 !
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 21 2.B - 22
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -23 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -24
Example: Chart_13a
a) SIMULINK-Modell
Here the sampling time of the
SINE – referred to ODE45 – is
used. This time is variable because
of the ‘variable-step-integration’.
(here 0.2 sec). 15
State1 Scope
State2
In State3
Sampled Update Method: State4
Out 0.6
An implicit trigger signal of 150
Chart Display
SIMULINK is generated.
It has exactly the provided
rate. Chart_13a_NonGraph.mdl Integration step: 1 sec
Here Chart_12c.mdl:
Sampling time: 2 sec
(provided in menu
’Properties’) “In” is set to 15 or 150 by a manual switch.
“State1” till “State4” show the active states over time in a scope.
“Out” is a result of the Chart, transmitted to SIMULINK.
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 23 2.B - 24
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -25 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -26
Chart_13a_NonGraph/Chart
State3/
en: aSF = 3
Out = bSF*aSF
State1/
en: aSF = 1
cSF = 10 [cSF==0]
dConst E_one
bSF = In*aSF/dConst
ex: cSF = 0
State2/ State4/
en: aSF = 2 en: aSF = 4
Out = bSF*aSF Out = bSF*aSF
[bSF >1]{E_one} c) Scope
ScopeData
Chart_13a_NonGraph/Chart 1
Pri nted 04-Aug-2004 20:48:31 y1 0.5
0 f) Results
10 2 4 6 8 10
y2
0
-1
In = 15 In = 150
10 2 4 6 8 10
y3
0.5
0
aSF = 1 aSF = 1
10 2 4 6 8 10
y4
0.5
cSF = 10 cSF = 10
0
0 2 4 6 8 10
sec
dConst = 100 dConst = 100
d) Tool/ Explore (open: “Chart” = parent)
bSF = 0.1500 bSF = 1.5000
cSF = 0 E_one
cSF = 0
aSF = 3
aSF = 2
Out = 0.4500
Out = 3
aSF = 4
Out = 0.6000
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 25 2.B - 26
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -27 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -28
c) Chart
Example: Chart_13b
a) SIMULINK-Modell
Chart_13b_NonGraph/Chart
State3/
en: aSF = 3
Signal 1 Out = bSF*aSF
State1/
Signal Builder en: aSF = 1
cSF = 10 [cSF==0]
dConst E_one
15 Scope
bSF = In*aSF/dConst
State1 ex: cSF = 0
State2 State2/ State4/
In State3 en: aSF = 2 en: aSF = 4
Out = bSF*aSF Out = bSF*aSF
State4
[bSF >1]{E_one}
d) Scope
Out 0
150 ScopeData
Chart Chart_13b_NonGraph/Chart 1
Display
y1
Pri nted 04-Aug-2004 21:18:21
0.5
0
10 2 4 6 8 10
Chart_13b_NonGraph.mdl Integration step: 1 sec
y2
0
-1
10 2 4 6 8 10
y3
0.5
“State1” till “State4” show the active states over time in a scope.
y4
0
sec
“Signal1” is an triggered input from SIMULINK to the Chart.
The Chart is adjusted to ‘Tiggered’, so the Chart steps state
by state unter control of this triggered input signal. e) Tool/ Explore (open: “Chart” = parent)
b) Signal-1:
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 27 2.B - 28
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -29 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -30
In = 15 In = 150
aSF = 1 aSF = 1
cSF = 10 cSF = 10
cSF = 0 E_one
cSF = 0
aSF = 3
aSF = 2
Out = 0.4500
Out = 3
Local Variables: See above ‘Data: bSF’
Scope/ select: ‘Local’
Additionally: Type, Fixed Point, Limit Range,
etc.
Initialize from: ‘data dictionary’ or ‘work-
Declaration of variables or events: space’
Way 1: In graphical Editor of STATEFLOW variables and inputs/outputs Local Events: See above ‘Event: event’
(of/to SIMULINK) are added to the Chart by menu: Add | Data. Events without a connection to SIMULINK are
local (= Scope: ‘Local’)
Equivalent we add on events to the Chart by menu: Add | Event.
Input Events from Scope/ select: ‘Input from Simulink
Way 2: In STATEFLOW Explorer we choose the menu Add | Event or
SIMULINK: (Chart gets a triggered input. If more than
Add | Data.
one triggered input: vectorised input; ex-
In both cases a standard name is assigned (“event”, “data”). We ample: ‘Chart_13b’).
rename simply these names. Trigger edge: Rising, Falling, Either, Function
Using the shortcut-menu (right mouse/Properties) you can Call.
change all relevant features (see below). (N.B: an edge requires a pass through zero;
correct edges: ‘0 1’, ‘1 0’, ‘-1 1’;
incorrect edge: ‘1 2’.
Function Call: instantaneous operation; no
delay to next integration step.)
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 29 2.B - 30
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -31 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -32
Input Data from Scope: ‘Input from SIMULINK’. 2.B.3.1 Superstates 2.B - 34
SIMULINK: See below: “Sine_Input”. Simplify a chart
2.B.3.2 Boxes 2.B - 41
Output Data to Scope: ‘Output to SIMULINK’. To organize the chart
SIMULINK: See below: “Scope_Output”. 2.B.3.3 Subcharts 2.B - 42
Alternative to Superstates
Constants: Special type of a local variable. 2.B.3.4 Graphical Functions 2.B - 44
They can’t be changed by the Action Language flow diagrams
Temporary Variables: Temporary Variables exist only, if the parent
object is active.
Good example: Counter variables.
Example:
Pulse
Generator
Scope_Output
Sine_Input Scope
Chart
In1 Out1
Triggered Scope1
Subsystem
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 31 2.B - 32
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -33 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -34
To generate a superstate:
Generate a normal state in STATEFLOW editor.
Increase this state (by dragging / left mouse).
Insert new states into this increased state. The first one
becomes a superstate.
(By double clicking the grouping becomes visible).
? ?
? ? 1
? ?
2
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 33 2.B - 34
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -35 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -36
Constant
on_off
0
Constant1
Chart_21 a_Superstate/Chart
off_on
S1
S2
switch_12
On
on_of f
switch_1 2 On
on_off Chart
of f_ on Of f of f_ on
Of f
switch_21
switch_2 1
The states are controlled by 4 events, coming from SIMULINK: Event ‘on_off’ occurs again:
“S1.Off” = inactive “S1.On” = active.
Event ‘switch_12’ occurs:
“S1” = inactive “S2” = active
(in this connection it is irrelevant, whether ‘S1.On’ or ‘S2.Off’
is active; in any case S2 will be active).
Inside S2: “S2.Off” = active, because of Default Transistion.
Event ‘on_off’ occurs again:
“S2.Off” = inactive “S2.On” = active.
Event ‘on_off’ occurs:
“S2.On” = inactive “S2.Off” = active.
Event ‘switch_21’ occurs:
“S2” = inactive “S1” = active
Inside S1: “S1.On” = active, because of Default Transistion.
Starting the automaton, superstate S1 will be active because of the Default
Transition.
Now STATEFLOW decides, which internal state of S1 has to become Different states have not to model with a large number of single
active: Because of the Default Transition: S1.On; this state is active states, if we use a hierarchical structure:
if we enter S1. Excellent survey.
Simplified Chart.
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 35 2.B - 36
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -37 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -38
b) Example: EXCLUSIVE-States with HISTORY Junctions: d) Example: EXCLUSIVE-States with Inner Transistions:
The example is exactly the same as before. Only in superstate S2 we Problem:
installed a History Junction: H 1. An automaton has three states S1, S2 and S3. We go to one of these,
depending on the condition [cond]:
The History Junction provokes, coming back to S2 to start with the
IF (cond == 1) THEN S1,
last active state in S2.
IF (cond == 2) THEN S2,
The Default Transition is used only once, if S2 was not yet active. IF (cond == 0) THEN S3.
2. Initializing the automaton starts with state S3.
3. After the event ‘update’ all conditions have to be rechecked in order to
History change into a new state.
Chart_21 b_Sup erstatehistory/Chart
junction
S1
Solution A:
S2
switch_12 H Chart_21d_Innertransition1/Chart
On
on_off On
on_off
off_on Off
off_on Off
switch_21
[cond==1]
[cond==2]
S1 S2 S3
c) Example: EXCLUSIVE-States with Supertransistions:
S1
S2
update
On
on_off On
on_off
switch_21
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 37 2.B - 38
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -39 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -40
Super_S
update
[cond==1]
[cond==2]
S1 S2 S3 SIMULINK environment:
1
Constant
ignition
0
Constant1
Pri nted 08-Aug-2004 18:10:11
lights
switch
transition ‘update’ could be always valid, if Super_S is active.
0 Chart
stufe0
Say, we are in state S3 and the event ‘update’ occurs. We leave S3 and 1
via ‘update’ we come back to the decision point. stufe1
2
stufe2
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 39 2.B - 40
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -41 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -42
Boxes are visual units to organize a Chart. Inside of a chart you can create more other charts Subcharts
They are not real elements in a FSM. These subcharts have the same properties as the supercharts, only the visual ar-
rangement is different.
A lot of STATEFLOW elements can be assembled in a box.
To establish a Subchart make first a Superstate around all the objects you need.
The effect of boxes is only the turn of execution. A box has a higher
Mark this Superstate and change it by the Shortcut menu Make Contents / Sub-
priority than all other parallel superstates. This superstates have to placed be-
charted to a Subchart.
low or right in the chart.
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 41 2.B - 42
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -43 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -44
The Subchart Z2 s now a Child of main Chart. It opens by a double click. 2.B.3.4 Graphical Functions 2.B - 44
flow diagrams
Like in Superstates you can make Transitions into Subcharts (Supertransitions):
A graphical function is a flow diagram without states.
The graphical function can be called by all actions (e,g. Transitionsaction) and
you can use the results.
Fundamentally a graphical function is only apparent inside the mother object and
all other child objects.
To establish a graphical function you start with the icon ‘function’ = f( ).
In the label of the function you have to note the prototype.
Syntax:
y = f1(a1, a2 a3)
The return value y and the arguments have to be defined in the Data Dictionary.
Example:
You need the product of three parameters:
The essential advantage of Subcharts in comparison to Superstates is the effect, When you invoke the graphical function the formal parameter have to be replaced
that the content is masked in Subcharts. By minimizing the Subchart icon you can by numbers or by other defined variables; here m,n,k.
economise the place on your screen.
The variables m,n,k have to be defined in the Data Dictionary already !
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 43 2.B - 44
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -45 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -46
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 45 2.B - 46
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -47 Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -48
2.B.4.4 Unary Operators 2.B - 47 2.B.4.6 Variables and Events in Action Language 2.B - 48
see language C Broadcasting
~a NOT a (bitwise) Variables or events have to be in the same hierarchy. Otherwise STATEFLOW
!a Logical NOT cannot find the variables or events.
a++ Increment by one If you want to use a variable from an other mother object, you have to apply the
a-- Decrement by one full path:
a = expression Simple assignment A local variable x inside of State S1.Open is found by: S1.Open.x
a += expression a = a + expression
dto: -=, *=, /= Event broadcasting:
In Action Language you can start an event immediately. The event and his scope
has to be defined in the Data Dictionary.
In Action Language assignments we can use MATLAB functions. The result is o Directed Broadcast:
assigned to a variable in the Data Dictionary. only a special state will see your event
Example: In a Condition Action the variable a needs the value of sin(x) Example 1: Undirected Broadcast Synchronization of parallel states
Using variables from the STATEFLOW dictionary, use the ‘ml’-operator and C If event e1 occurs, we go from S1.A1 to S1.A2.
syntax:
Entering S1.A2 we start the undirected event e2 by the ‘entry statement’; so
[Cond == 1]{ a = ml(‘sin(%g)’,d1)}
we go from S2.A1 to S2.A2. - e1 and e2 are parallel now.
SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW SC1c_Mod_2.B_App-Manual_684b.doc Appendix 2.B MATLAB - STATEFLOW
2.B - 47 2.B - 48
Prof. H. Kull FSM - STATEFLOW App. 2.B 2.B -49