State Machines are not difficult! – A FSM tutorial
By David Stonier-Gibson, SPLat Controls
Do you need an easy way make your programs respond to events or user actions in ways that can vary depending on past events, or history ?
Maybe you are programming one of the following:
- Machine controllers
- Robotics
- 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.
Stop press
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
Buy a SPLat for $29.00
Program your own Finite State Machine using a SPLat Controller for only $29.00.
The EC1 “EasyOne”, a 32-bit fully featured SPLat Controller with USB and true multi-tasking is a easy way to learn and a cheap way to build your project.
