State Machines are not difficult! - A FSM tutorial
Maybe you are programming one of the following:
- Machine controllers
- Games programs
- Transaction processing
- Communications protocols
- Puzzle solvers
The Finite State Machine (FSM for short, sometimes called Finite State Automaton) is a programming technique that can handle such situations very easily. The most complicated aspect of finite state machines is the name itself. .
The way I am going to do this is first of all to introduce you to a diagram that describes a finite state machine. That is in many ways the most important part, because it gives you a very powerful design tool. Then I will show you how to translate a State Diagram into program code. About 20 minutes from now you will have a powerful new tool in your programming arsenal.
Since I wrote this tutorial we have developed a FSM design and programming tool that represents FSMs as a table. This is an alternative way of looking at them, and for some people may be easier. The tool is called Tabula™. It can be used to design and specify FSM programs for any platform, and also to generate programs for our embedded controller. Visit the Tabula FSM programming page