Example Code

Simple State Machine: Concept demonstration in LabVIEW

Code and Documents

Attachment

Download All

Overview: This is simple State machine for the demonstration of state machine in LabVIEW concept

 

Description: Demonstration of the Concept of state machine

 

Hardware and Software Requirements: No Hardware required

 

Steps to Implement or Execute Code: Simple execute button press

 

Additional Information or References

 

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

Comments
altenbach
Knight of NI Knight of NI
Knight of NI
on
  • If you would place the LED indicator terminals after the case structure, you would not need local variables.
  • If you switch the state before the case when stop is pressed, you don't need the lower shift registers.
  • A +1 will rotate through the states. All you need is a single enum constant.
  • An example program should have the front panel and diagram aligned with the visible window area, not offset and partially hidden.
  • This entire thing could be done with much less code (code in image below does exactly the same thing).
  • Latch action booleans should use buttons, not switches on the front panel.
  • Typically, the color of structures should not be changed.
  • It makes no sense to spin the loop as fast as the computer allows.
  • In my example, the real state code would be in a separate case structure parallel to the second case structure. This way the right LED lights up at the same time when the state code starts executing.
  • ...

 

SimplerStates.png

Contributors