In short. A state machine describes a sequence as a set of states and the exact conditions for moving between them. It makes behaviour predictable, including what happens on timeout, fault or restart. Sequences written as loose rungs of logic hide dead ends that only show up in an emergency.
Elements
| Element | Meaning |
|---|---|
| State | A stable condition, such as Standby, Starting, On load, Fault |
| Transition | A move from one state to another |
| Guard | The condition that must be true for the transition |
| Action | What the controller does on entry, during or on exit |
| Timeout | Maximum time allowed in a state |
Design rules
- Every state has at least one exit, including a fault exit.
- Every state that waits has a timeout and a defined timeout action.
- Only one state is active at a time.
- Transitions depend on confirmed feedback, not on commands issued.
- A fault or emergency state can be entered from any state.
- Manual and automatic modes are explicit states or modes, not hidden flags.
Restart behaviour
After a controller power cycle, the machine should not assume it is in its last state. Read the real plant state, breaker positions and source health, then choose the correct state. Never close or open anything just because the program restarted. See PLC architecture.
Documenting
- State diagram with every transition numbered.
- Transition table listing guards and actions.
- Alarm for every timeout and refused transition.
- Cause-and-effect matrix linking to outputs. See cause and effect.
Testing
Test each transition: the normal path, the guard failing and the timeout. Also test illegal sequences, such as two commands at the same time. A coverage table that shows every transition tested is the evidence.
Illustrative example
A start-and-transfer machine has states Standby, Cranking, Running, Stabilising, Transferring, On generator, Retransferring, Cool-down and Lockout. The Stabilising state has a 30 second timeout; if source voltage is not acceptable, it moves to Lockout and alarms, instead of waiting indefinitely. Tests simulate a bad voltage and confirm the transition.
Why sequences are written as state machines
Control logic written as a tangle of latches is hard to test and harder to fix. A state machine has a defined set of states, a clear transition for each event and a safe response to anything unexpected.
| Element | Rule |
|---|---|
| States | Named, finite, one active at a time |
| Transitions | Each with a condition and a timeout |
| Actions | Entry, during and exit actions defined |
| Fault state | Reachable from any state |
| Reset | Deliberate and conditional |
Every step needs a timeout
A step that waits for a condition forever can hang the plant. Give each wait a timeout and a defined failure action. For example, waiting for breaker closed feedback: timeout 2 seconds, then alarm and revert to the safe state.
Example: generator start sequence
- Idle, ready.
- Pre-start checks (fuel, battery, no alarms).
- Crank, with attempt count.
- Run-up, wait for speed and voltage.
- Available, wait for close permissive.
- On load.
- Cool-down.
- Stop.
Test the state diagram
Walk through every transition in simulation, including events in the wrong order. Record the result. See ATS and AMF logic and cause-and-effect engineering.
The master engineering question
Is there any state from which the plant cannot leave, or any restart condition that could cause an unintended breaker operation?
What to send us
Send your sequence descriptions. Send your application details.
Questions engineers ask
Why not simple ladder logic?
It works for small tasks, but complex sequences become hard to verify.
Can a state machine be drawn from existing logic?
Yes. Reverse engineering often finds hidden states and gaps.
How many states are too many?
If a diagram cannot be understood on one page, split into sub-machines.
Do generator controllers use state machines?
Yes, internally; know their states when integrating.
This guide gives general principles. Confirm with a project design.
