Example Code

State Machine: Display State Data Using String Indicator Using LabVIEW

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

Overview

In some applications there may be a need to display data from different states of the state machine. For example, the data or indication of a successful test that was performed. If there are many such tests, then this could possibly lead to excessive Front Panel indicators. This method builds a string to display many different items from different state transitions in one convenient string display.

 

Description

This program uses a simple state machine architecture. A sub VI is used to build the string and each state can call upon this sub VI to update the string record. That record is stored by passing it through a shift register on each iteration. The program is fairly modular and can be easily modified by changing the sub VI or the typedef control used for the states.

 

Requirements

  • LabVIEW 2013 (or compatible)


Steps to Implement or Execute Code

  1. Download the appropriate project version.
  2. Open the project and State Machine.vi.
  3. Examine the code and run the VI.
  4. The program will stay idle until the Start button is pressed. While iterating through different states, the Processing light will be on and the Test Results indicator will be updating with the string data. After completion, it will default back to idle.
  5. Press the Stop button at any time for a safe shutdown (keep in mind that this is not event driven programming)

 

Additional Information or References

Front Panel

Front Panel Run.png 

VI Snippet of Block Diagram

1-322.png

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

David C

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

Tariff Impact Update Learn more