Finite State Machine
Definition
Section titled “Definition”A finite state machine is a model of a control system that describes the behavior of a control system using states, transitions, and actions.
The state stores information about the past, i.e. it reflects the input changes from the system start to the present moment.
A transition indicates a state change and is described by a condition that must be fulfilled to enable the transition.
An action is a description of an activity that is to be performed at a given moment. There are several action types:
- Entry action,
- Exit action,
- Input action and
- Transition action.
Depending on the actions used we have different finite state machine models, as for instance:
- Moore model (only entry actions) or
- Mealy model (only input actions).
Example - Microwave Oven control
Section titled “Example - Microwave Oven control”A state machine to control a microwave oven.
The oven has a Run push button to start (apply the power) and a Timer that determines the cooking period. Cooking can be interrupted at any time by opening the oven Door. After closing the Door cooking continues. Cooking is terminated when the Timer elapses. When the Door is opened a Lamp inside the oven is switched on; when the Door is closed the Lamp goes off.
The control system has the following inputs:
- Run push button - when activated starts cooking,
- Timer - while this runs the cooking is enabled,
- Door sensor - can be true (door closed) or false (door open).
And the following outputs:
- Power - can be true (power on) or false (power off),
- Lamp - can be true (lamp on) or false (lamp off). The knobs to set the power level and timeout values are irrelevant for the control algorithm structure. The behavior of the microwave oven control is determined by the Run push button, Timer and Door sensor.
Solution
Section titled “Solution”There is no one single solution for the control system. Depending on the state machine model employed the system may have different numbers of states. We show three possible solutions for the Microwave Oven control system.
Moore model
Section titled “Moore model”
Mealy model
Section titled “Mealy model”
Mixed model (Mealy + Moore)
Section titled “Mixed model (Mealy + Moore)”
The details of the state transition diagrams, and especially the actions are included in the state transition tables of the MWOven projects. To display the state transition table, you can either download StateWORKS Studio or take a look at the article Moore or Mealy model?