| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Stateflow |
| Contents | Index |
| Learn more about Stateflow |
You will build a Stateflow chart that maintains air temperature at 120 degrees in a physical plant. The Stateflow controller operates two fans. The first fan turns on if the air temperature rises above 120 degrees and the second fan provides additional cooling if the air temperature rises above 150 degrees. When completed, your Stateflow chart should look something like this:

As you can see from the title bar, the chart is called Air Controller and is part of a Simulink model called sf_aircontrol. When you build this chart, you will learn how to work with the following elements of state-transition charts:
Exclusive (OR) states. States that represent mutually exclusive modes of operation. No two exclusive (OR) states can ever be active or execute at the same time. Exclusive (OR) states are represented graphically by a solid rectangle:

The Air Controller chart contains six exclusive (OR) states:
PowerOn
PowerOff
FAN1.On
FAN1.Off
FAN2.On
FAN2.Off
Parallel (AND) states. States that represent independent modes of operation. Two or more parallel (AND) states at the same hierarchical level can be active concurrently, although they execute in a serial fashion. Parallel (AND) states are represented graphically by a dashed rectangle with a number indicating execution order:

The Air Controller chart contains three parallel (AND) states:
FAN1
FAN2
SpeedValue
Transitions. Graphical objects that link one state to another and specify a direction of flow. Transitions are represented by unidirectional arrows:
![]()
The Air Controller chart contains six transitions, from
PowerOn to PowerOff
PowerOff to PowerOn
FAN1.On to FAN1.Off
FAN1.Off to FAN1.On
FAN2.On to FAN2.Off
FAN2.Off to FAN2.On
Default transitions. Graphical objects that specify which exclusive (OR) state is to be active when there is ambiguity between two or more exclusive (OR) states at the same level in the hierarchy. Default transitions are represented by arrows with a closed tail:
![]()
The Air Controller chart contains default transitions:
At the chart level, the default transition indicates that the state PowerOff is activated (wakes up) first when the chart is activated.
In the FAN1 and FAN2 states, the default transitions specify that the fans be powered off when the states are activated.
State actions. Actions executed based on the status of a state.
The Air Controller chart contains two types of state actions:
entry (en) action in the PowerOff state. Entry actions are executed when the state is entered (becomes active).
during (du) action in the SpeedValue state. During actions are executed for a state while it is active and no valid transition to another state is available.
Conditions. Boolean expressions that allow a transition to occur when the expression is true. Conditions appear as labels for the transition, enclosed in square brackets ([ ]).
The Air Controller chart provides conditions on the transitions between FAN1.On and FAN1.Off, and between FAN2.On and FAN2.Off, based on the air temperature of the physical plant at each time step.
Events. Objects that can trigger a variety of activities, including:
Waking up a Stateflow chart
Causing transitions to occur from one state to another (optionally in conjunction with a condition)
Executing actions
The Air Controller chart contains two edge-triggered events:
CLOCK wakes up the Stateflow chart at each rising or falling edge of a square wave signal.
SWITCH allows transitions to occur between PowerOff and PowerOn at each rising or falling edge of a pulse signal.
![]() | The Stateflow Chart You Will Build | How the Stateflow Chart Works with the Simulink Model | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |