LabVIEW Development Best Practices Documents

Showing results for 
Search instead for 
Did you mean: 

State Machine Design Patterns Technical Manual and Exercises


Learn how to design reusable LabVIEW code with the state machine architecture. Through hands-on exercises, you will learn how to design state diagrams, implement LabVIEW state machines, add new states to existing state machines and change state transition logic.


Implementing state machine design patterns in LabVIEW leads to improved scalability and maintainability of applications over longer periods of time. State machines are used in applications where distinguishable states exist. Each state can lead to one or multiple states, and can terminate the process flow. A state machine relies on user input or transition logic to determine which state to go to next.

This technical manual demonstrates some of the most important concepts when designing state machine architectures in LabVIEW. You will complete exercises to demonstrate the importance of LabVIEW state machines including how to design state diagrams, implement a LabVIEW state machine, add new states to an existing state machine and change state machine transition logic.

LabVIEW Vending Machine

Provided with the technical manual is a LabVIEW applicaiton that will be used during the exercises. The LabVIEW Vending Machine Application is designed to accept change and distribute a soda when the change has reached the appropriate amount. This application was developed using a state machine diagram and LabVIEW state machine architecture. The LabVIEW Vending Machine application has the following requirements:

  • All Soda products are sold for 50 cents.
  • The machine only accepts nickels, dimes, and quarters.
  • Exact change is not needed.
  • Change can be returned at anytime during the process of entering coins.

LV Vending Machine FSM.png

Exercise Scenario

The LabVIEW Vending Machine application behaves in a manner to distribute a soda as soon as the deposited amount >= .50 cents. This is not the expected bahavior of a typical vending machine. A typical vending machine would behave in a manner such that a user can deposit as much money as desired and can then make a soda selection that will be delivered if the user has deposited enough money. The exercises will walk you through modifying the state machine to execute in a manner that is consistent with the updated state diagram model. This behavior will be conistent with the bahavior of a typical vending machine.

State Diagram2.png

Adri Kruger
National Instruments
LabVIEW Product Marketing
Member Joonam

Thanky for updating one of nice materials.

NI Employee

Absolutely! State Machines are one of the most clean software architectures that a LabVIEW programmer can implement, leading to easy maintainability of the code over longer periods of time.

Adri Kruger
National Instruments
LabVIEW Product Marketing
Member MZS

thank you

Member Srikanth@Siri

Thank you for sharing the good material...

Srikanth Kandagatla
Member Jorge68

Thank you, but where is The Vending Machine Event-Driven User, I want it for NI Academic Days, it's for the last exercise, here in Mexico.

Thank you!!

Member carlos_camargo


Try this link, it is found on the right side of this page in the "More Like This" section, text alias: "Soda Vending Machine"

Active Participant PrimaryKey
Active Participant

You can try this:

Best regards, Piotr

Certified TestStand Architect
Certified LabVIEW Architect