Example Code

Coke Machine State Machine

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Description

 

The State Machine is one of the fundamental architectures LabVIEW developers frequently use to build applications quickly. State Machine architecture can be used to implement complex decision-making algorithms represented by state diagrams or flow charts.

 

State Machines are used in applications where distinguishable states exist. Each state can lead to one or multiple states, and can also end the process flow. A State Machine relies on user input or in-state calculation to determine which state to go to next. Many applications require an "initialize" state, followed by a default state where many different actions can be performed. The actions performed can depend on previous and current inputs as well as states. A "shutdown" state can then be used to perform clean up actions.

 

This vi uses State Machine architecture to perform the functions of a Coke machine.

 

You can also see a vi that performs the same function that uses produce consumer architecture at https://forums.ni.com/t5/Archive-TKB/Producer-Consumer-Example-Coke-Machine/ta-p/3504030

 

Justin Parker
National Instruments
Product Support Engineer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
stevem181
Active Participant
Active Participant
on

The link to the producer consumer version is broken:

 

http://decibel.ni.com/content/docs/DOC-2145

 

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------