Making simple work of complex functions David Gibson, SPLat Controls Pty Ltd |
||||
|
This web page contains an introduction to the article. The whole article is available as an Adobe Acrobat pdf file.
Click here to download pdf file (274K).
The State Machine, or more accurately, Finite State Machine (FSM), is a device and a technique that allows simple and accurate design of sequential logic and control functions. Whether you are designing computer programs, sequential logic circuits or electronic control systems, using State Machine methods you will be able to make your designs more sophisticated than before, and with ridiculous ease. This article is intended as an easy to read introduction to the subject, and is based on over 20 years of on-the-job self-teaching. I will introduce you to the basic concepts of state machines from the point of view of engineering or programming. I will then give you some programming examples using Basic and a low cost micro-PLC (the SPLat programmable controller), and expand the concepts into a simple model for multitasking in programmable controllers. For the hardware minded I have also covered hardware implementation of state machines. One of the most fascinating things about FSMs is that the very same design techniques can be used for designing Visual Basic programs, logic circuits or firmware for a microcontroller. Many computers and microprocessor chips have, at their hearts, an FSM. In disciplines other than engineering and programming FSM concepts are used for pattern recognition, artificial intelligence studies, language and behavioural psychology. And yet, the basic concepts are easy to understand and immensely powerful. The idea behind the FSM is that a system such as a machine with electronic controls can only be in a limited (finite) number of states. Consider some simple systems that you encounter every day: a door may be open or closed; a light may be on or off; a light bulb may be on, off or broken; a cassette player may be playing, stopped, rewinding or fast forwarding. Notice I refer to these things as systems. Perhaps it's a little strange to call a door a system. Not so if you are designing an automatic door controller! You might also wonder at the choice of two states for a light but three states for a light bulb. The point here is that you need to identify all those states of the system that are important for the task at hand. If you are designing an emergency lighting system then the "broken" state of the bulb is of vital importance to you. Hence, for an automatic door operator "Open" and "Closed" are probably insufficient. In that case it might be appropriate to add "Opening:", "Closing", "Locked" and, heaven forbid, "Stuck". The first step in any FSM design is to identify the significant states of the system; you need to include all the important states but avoid including unnecessary states. Hence, the door may be "Opening" or "Closing", but "3/4 open" or "1/4 closed" would most likely be overkill. |
||||
|
|
||||
| Thank you for reading this introduction to my article. The whole article is available as an Adobe Acrobat pdf file. Click here to download pdf file (274K). | ||||
|
|
||||
| ©Copyright 1996-1999 SPLat Controls Pty Ltd. All rights reserved. Reproduction in part or full without written permission is prohibited. |