State machine



This explains how a state machine works. The machine can only be in one state at a time. The state can be connected to a logic port in the scheme by using a unique name for the state. The machine enters a new state if a condition is true. The condition is an output from the scheme.
There are 3 symbols in a state diagram: Init, State, Condition.
  • Init: This is the initial state, the start position, of the state machine. A state machine may only have one initial state.
  • State: This represent one state in a state machine.
  • condition: a connection with the schematic to change to another state.


The connection with the schematic works with: State output and State Input
  • State output: This is the Boolean representation of a state. The state and the state output are connected by their names.
  • State Input: This is the driving source for one (or more) conditions. The state input and the condition are connected by the same name.

Example

Here we use a state machine for a set (S1) / reset (S2) action. The simulator is used to see what happens. Of course this is easier with just one Set/Reset element but this is only to explain how it works. The first state is Init.



State on

When input S1 is true conditionS1 becomes true and the state changes into State On, the output L1 is on.



Return to init

To turn off L1 Press S2 the state becomes init again

Decisions

It is possible to go to different states by using more conditions. For a real example using a state machine look @ Alarm System