From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Development Best Practices Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

State Machine Design Patterns Technical Manual and Exercises

Abstract

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.

Summary

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
Comments
Joonam
Member
Member
on

Thanky for updating one of nice materials.

CTA, CLA
SuninCNS
Adri_K.
NI Employee (retired)
on

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
MZS
Member
Member
on

thank you

Srikanth@Siri
Member
Member
on

Thank you for sharing the good material...

Srikanth Kandagatla
Jorge68
Member
Member
on

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

Thank you!!

carlos_camargo
Member
Member
on

Jorge,

Try this link, it is found on the right side of this page in the "More Like This" section, text alias: "Soda Vending Machine" https://decibel.ni.com/content/docs/DOC-20305

PrimaryKey
NI Employee (retired)
on

You can try this: https://decibel.ni.com/content/docs/DOC-43690

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
Contributors