SPLat Logo

Finite State Machines - Make light work of complex functions

NOTICE: We are updating our website. For product enquiries and orders please contact us directly.
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 - Code overview

Finite State Machine program listing

Figure 11 is a listing of the program that has been collapsed to give an overview of the various subs (in VB.NET subs used more frequently than functions, though the two are very similar)

I have grouped the 9 subs into logical groupings, to help you see the overall pattern.

Global variables

Two variables are declared (DIM'd) at the top of the program..

Event handlers

These are the subs that respond to the various events that can occur during the life and times of the FSM.

Outputs

I have chosen to locate the output simulation code in separate subs. This makes it easier if you want to change how an output is simulated. The two outputs are the heater and the alarm indicator.

State transitions

I have made a single sub that handles all the state transitions. It is called with the destination state number as its argument. It switches the global state number and performs all required actions. HelpTip

Timer management

My particular style of creating timeouts in VB is to use a timer control with a short interval and to count off Timer_Tick events.