To download NI software, including the products shown below, visit ni.com/downloads.
Overview
The example VI shows how to add an event structure to the state machine in a way that allows the state machine to do what it needs to do while the user isn't pressing buttons, and handle button presses as they come in.
Description
The attached zip file contains a .lvproj with two 'main' VIs.
Main.vi contains a very basic state machine with an event structure in the same loop as the typical state-machine-case-structure. This is a fairly common arrangement for a program that contains fairly uncomplicated logic in each state. If the output of your program will not be damaged by the occasional interruption caused by the 'firing' of an event, this is a sane approach.
Main2.vi contains a very basic state machine with an event structure in a separate while loop. The instructions from the event structure are transmitted to the state machine by way of a queue. This setup is often seen where the state machine is in charge of the logic governing the operation of hardware.
Requirements
Steps to Implement or Execute Code
Additional Information or References
NI Snippet
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.