SPLat Logo

Finite State Machines - Make light work of complex functions

NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map

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.

VB.NET - Introduction

The program winds up quite a bit more complex in VB.NET than in SPLat. There are two reasons for this:

  1. There is quite a bit of extra stuff required simply to build a user interface that represents the real-world.
  2. The event triggered nature of VB lead forces a program structure that is more convoluted. VB great for data handling and neat user interfaces (GUIs) but is not designed for FSMs.

There are two main aspects of the VB.NET program: A visual form, and the actual program code.

Heater dialog box

The form serves, in this case, as a substitute for the real-world apparatus that we imagine the program to be controlling, namely a tank of fluid that must be maintained at a temperature of about 85°C. The form is what we see on the computer screen, and interact with.

The program code is, well, the program. It does the work that implements the required state machine functionality.

I have kept the form design dead simple, so you should be able to replicate it with a minimum of fuss. With the VB.NET visual form designer it is basically a drag and drop operation.

Figure 9 shows the form while the program is in state 1 (heating). A gadget in the middle lets you adjust the temperature reading to simulate the effect of the heater. The circle to the left of the alarm reset button will turn red if the alarm trips. The current state number and remaining time until timeout are show at the bottom, for diagnostic purposes.