Documentation Center

  • Trial Software
  • Product Updates

Chart

Implement control logic with finite state machine

Library

Stateflow®

Description

A finite state machine is a representation of an event-driven (reactive) system. In an event-driven system, the system responds to an event by making a transition from one state (mode) to another. This action occurs as long as the condition defining the change is true.

A Stateflow chart is a graphical representation of a finite state machine. States and transitions form the basic elements of the system. You can also represent stateless flow charts.

For example, you can use Stateflow charts to control a physical plant in response to events such as a temperature and pressure sensors, clocks, and user-driven events.

You can also use a state machine to represent the automatic transmission of a car. The transmission has these operating states: park, reverse, neutral, drive, and low. As the driver shifts from one position to another, the system makes a transition from one state to another, for example, from park to reverse.

A Stateflow Chart can use MATLAB or C as the action language to implement control logic.

This block diagram represents a machine on an assembly line that feeds raw material to other parts of the line. It contains a chart, Feeder, with MATLAB as the action language.

If you double-click the Feeder block in the model, the chart appears.

For a tutorial on this model, see Model Event-Driven System.

Data Type Support

The Chart block accepts input signals of any data type that Simulink® supports, including fixed-point data and enumerated data types. For a description of data types that Simulink supports, refer to the Simulink documentation.

Floating-point inputs pass through the block unchanged. Boolean inputs to charts that use MATLAB as the action language pass directly as Boolean outputs. Boolean inputs to charts that use C as the action language are treated as double type.

You can declare local data of any type or size.

Parameters and Dialog Box

For a description of the block parameters, see the Subsystem block reference page in the Simulink documentation.

Characteristics

Direct Feedthrough

Yes

Sample Time

Specified in the Sample time parameter

Scalar Expansion

N/A

Dimensionalized

Yes

Zero-Crossing Detection

Yes, if enabled for continuous-time systems.

For more information, see When to Enable Zero-Crossing Detection.

Was this topic helpful?