Click here to Skip to main content
15,794,593 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I am working on making my own programmer for 8-bit micros and am wondering if their is anything more flexible than the default finite state machine.

I have used FSM's for 16x2 LCD menus and things that generally are set in stone as they are not the easiest to add too some times. I want to be able to easily add new programming algorithms and have full exception handling which I believe may be quite difficult to handle with a simple FSM.

Are their any alternative out there? I have used QM and such tools from [^] but they generate quite obscure code and I really don't learn anything when I go that route.
Sergey Alexandrovich Kryukov 14-Jul-11 0:27am    
Do you need alternative to FSM (this answer cannot be answered without description of your application) or alternative implementation of FSM?
Trevor Johansen 14-Jul-11 0:40am    
I'm open to different versions of FSM's or something completely different.

What I am implementing is a simple enough state chart but their is error checking and redundancy added to each state and if their are errors the system needs to branch into an alternate state set to discover and/or correct the problem.

I have done simple state machines such as user menus where everything is set in stone and their are no issues with things failing. Theirs not a whole lot of info on FSM's so most of what I know I learned from here:

Your arguments in favor if Finite-state machine sound very reasonable. If you don't like the tool you tried to use I would suggest you develop your own framework, perhaps much more compact, less general and closed to your application field. Also, you can exclude code generation and rely on manual coding, but still based on FSM which can add strictness to your design and maintainability to your code.

The concept of FSM is fairly simple to be translated into programming domain in more or less straightforward development process. See[^].

[EDIT] Look at my article Enumeration Types do not Enumerate! Working around .NET and Language Limitations[^]. In this article I provide implementation of Cartesian Square indexed by enumeration (enumeration type represents a set of states of FSM) and describe a FSM built over the Cartesian Square.

Share this answer
ThatsAlok 14-Jul-11 2:42am    
nice link!
Sergey Alexandrovich Kryukov 15-Jul-11 4:31am    
Thank you.
R. Erasmus 15-Jul-11 4:28am    
good suggestion
Sergey Alexandrovich Kryukov 15-Jul-11 4:32am    
Thank you, R.
Trevor Johansen 15-Jul-11 11:50am    
I was hoping to find a framework to work from as the ones I have written on my own are not robust enough.
It's on my to-do list. ;)

For educational research I would recommend looking at the lecture notes at Rice University. They are very good at explaining NFAs and DFAs.

You might look at The Boost Statechart Library [^] for ideas.
Share this answer
Trevor Johansen 15-Jul-11 11:51am    
Thanks for the heads up on the Boost::FSM. It is open and has all the features I was looking for I believe.

Do they make a Java equivalent of the Boost library do you know?
John R. Shaw 15-Jul-11 12:42pm    
Not exactly, but there are lots of java libraries out there - try search for "java statechart".

I found this
Trevor Johansen 15-Jul-11 13:20pm    
I found this awesome website: and it has a very clean FSM implementation. Should be applicable to C++ and Java, It is much more robust than my FSM and has a better interface.
John R. Shaw 15-Jul-11 13:32pm    
Cool! Thanks for the link. It looks like you found what you were looking for.
I have worked with Qt's State Machine Framework. It is a well built framework and fairly easy to understand, but maybe it is just too much to depend on the full Qt framework for just the State Machine.
Share this answer
Trevor Johansen 15-Jul-11 11:52am    
I have used it to and its handy for things like quick user menus but I prefer not to rely on a closed source project.
mav@octaval 15-Jul-11 15:44pm    
Qt is not closed source. Is open source, with LGPL license.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900