Example Code

IListbox: A System Multicolumn Listbox that displays LabVIEW objects with built-in behavior 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
The Status register vi lets you pass 32 TRUE/ FALSE states between sub vis. It is a simpe way to pass control from one vi to another or from one loop to another within a vi. Instead of having 32 global boolean variables you have only one sub vi.

 
Description
The Status register vi is a simple vi that holds a 32 bit unsigned value. You can instruct the vi to set or return any bit in the 32 bit value. You set a bit by calling the vi with a bit number (0 based) and a TRUE (set) or FALSE (clear) value. The bit value is returned as a TRUE or FALSE value. You can also read all bits as a singel 32 bit unsigned value.

The example includes a main vi and a sub vi. The main vi calls the sub vi at startup. The sub vi calls the Status register.vi periodically to check for instructions. When the user hits Start counter the main vi calles the Status register.vi instructing it to set bit 1 high. The status change is detected by the sub vi which will start counting.

You can expand the code by adding actions to the sub vi, e.g. let bit 2 reset the timer.

 

Requirements

Software:

  1. LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Open the Status register.llb
  2. Open the Main.vi
  3. Open the Sub vi 0.vi
  4. Run the Main.vi
  5. Hit Start counter and observe that the sub vi starts counting
  6. Hit Stop counter and the counting stops
  7. Hit Stop to abort execution. A message signals that both sections of code has terminated

 

Additional Information or References

VI Snippet

main.png

  **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.