Example Code

Create a polyVI to be a selector for constants 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

Download All

Overview
Problem: You have a set of named constant values. You want to be able to drop those values on a block diagram and select among them with a name, like a ring. But you want the values to be modifiable later. And you want a double data type that rings and enums don't support. Or you want sparse values, also unsupported. Possible solution? Create a poly VI. Each instance VI is an inlined subVI that just outputs one of the constant values. Put those instances in the polyVI, turn on the polyVI selector ring and you essentially have what you're looking for.

Problem... building all of that is a pain. Solution... this scripting code.


Description
An LLB saved in LV 2013 that you run to create your polyVI and its instance Vis

representing constants.


Requirements

Software:

  1. LabVIEW 2013(or compatible)


Steps to Implement or Execute Code

  1. Create a directory on disk where you want the polyVI and its instance VIs to be created.
  2. Open "Make Constants.vi" and put that path in the control on the front panel.
  3. Fill in your named constants in the array. You can change the data type of the array if you want (it is Double right now). Just change it on the front panel... no other code changes are needed.
  4. Run the VI.
  5. Drop the newly created polyVI on a block diagram.

 

Additional Information or References
VI Block Diagram

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