Posted by: Harold Ennulat | January 27, 2010

Finite State Machines: The Concepts Simplified

David Stonier-Gibson presents an interesting 20 minute tutorial on finite state machine (FSM) logic diagrams and how to implement them in code using SPLatBASIC and VB.Net.

“The Finite State Machine (“FSM” from now on) is a programming technique that can handle [a number of situations] very easily”, David states in the tutorial.

He also has a ladder diagram implementation of state machine diagrams.

As David himself notes, “The one disadvantage you may find … is that the state diagram really needs to be stored with the ladder diagram for future maintenance. The connection between the two can be lost unless you are working in a well controlled, disciplined environment. You must also enforce the discipline that the state diagram is always referred to for changes, and of course updated.”

Unfortunately this makes FSM or any diagram of the actual program of limited use.

Way back when, there was a product called ABC Flowcharter that allowed you put Basic programs in each block that you could drill in to.  I had thought that the PLC companies would jump all over this and integrate this into their own programming environments, but it never happened. 

Instead we have the IEC 61131-3 standard that has something called sequential function chart programming.  The Allen Bradley ControlLogix and Modicon Concept programming environments implement this in a 2 step way with the sequential function chart existing in one place and the code (in ladder usually) in another place, making it more awkward to use then one might like.  However the chart, while not the same as FSM, at least is part of the program and so wouldn’t get lost.

For further reading, Wikipedia has a good description of finite-state machines and StateWORKS: Going beyond the limitations of IEC 61131-3 which also recognizes additional limitations of implementing state logic designs in the PLC by concluding:

“Even the half-hearted in a sense “hidden” use of the state machine concept in PLC programming is a useful step forward from the intuitive way of programming by coding, into programming which is based on control system modeling. The way it is presented in the IEC example is still influenced by the “marker” way of thinking which makes it less attractive for PLC programmers. Missing a concept of a system of state machines limits the use of state machines in PLC programming to very simple examples.”


If you can read figure 8, then you already know the basics of FSM logic, at least according to David.  For those that can’t, try the tutorial.  I thought it was both fun and instructive.  Click to see an enlarged view of Fig 8.

Here is the link to the  discussion in the “Control Nerds” group in LinkedIn.  Linked in and group membership required.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: