Overview
This code show that you can use more advanced State Machines Architecture in designing my user interface
Description
State machines implement a state diagram in LabVIEW and are most commonly used when programming user interfaces. When creating a user interface, different user actions send the user interface into different processing segments. State machine constantly monitors the user to determine which state to implement next in polling fashion.
For example, a program using state machine architecture is needed in controlling a vending machine. A vending machine is not a linear process because it needs to react to the user actions. Did the user put in 20 pence? Then add £0.5 to the total. Did the user put in 5 pence then 20 pence? Then add £0.05 before adding £0.20. The order in which things are done is not always the same, thus a linear programming structure does not meet our needs. Also, some steps may be skipped (what if they never use a dime?) others may be repeated many times (waiting for the next coin). We need a state machine to outline the various states and transitions associated with a vending machine and programmatically decide which thing to do to react to various user actions.
A visual vending machine in the Gym selling bottles of energy drinks has been created in LabVIEW using state machine architecture as shown in the attached example program. The 50p, 20p and 10p coins can be added in any order and the “vending machine” will return you the correct amount of change.
Requirements
- LabVIEW 2013 (or compatible)
Steps to Implement or Execute Code
- Run VI
Additional Information or References
VI Block Diagram
**This document has been updated to meet the current required format for the NI Code Exchange.**