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 - State transition handling

The sub listed below performs the switching from one state to another. It is called with the destination state number as an argument. It updates the global state number and the diagnostic state indicator. Then it does a Select Case on the new state number and performs the entry actions.

Private Sub SetState(ByVal NewState As Integer)
  'Switch to a nominated state, doing all the entry action stuff
  State = NewState   'Update the global state number
  Label2.Text = "State = " & State 'Diagnostic display
  Select Case State  'Actions depend on the state we are entering ...
    Case 0
    Case 1
    Case 2
  End Select
End Sub

This will turn off the heater (False argument). How that is done is a function of the HeaterOut sub.

This will turn off the alarm (False argument). How that is done is a function of the AlarmOut sub.

This will start the countdown (timeout) timer counting for 60 ticks. As each tick is 100mS, this will give a timeout of 6 seconds. Thats's a lot less than the 10 minutes called for in the state diagram ... but who want to sit staring at a computer screen for 10 minutes?