Example Code

Programmatically save & read control values to/from TDMS files in 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 Report Generation Toolkit
  • LabVIEW

Code and Documents

Attachment

Description

 1. Overview

This VI Shows a method to save control configuration to a TDMS file, and how to retrieve the values saved in said file to write them back to a VI's front panel controls.

 

2. Description

This VI was created when running multiple series of test and measurement experiments. The function was created so the values from Front Panel controls could be saved into the same TDMS file as measurements, therefore allowing users to re-load these configuration settings into another test sequence. This keeps the front panel control data in the same TDMS file, without the need for a separate configuration file.

The values are obtained from the controls using an invoke node that calls the "Control Value: Get All" method, which returns an array of clusters containing the name and data of each control.

 

3. Requirements

  • NI LabVIEW Base Development System 2012 or compatible.

 

4. Steps to Implement or Execute Code

  1. Download the compressed file and extract its contents.
  2. Open the Save and read control values from TDMS files LabVIEW 2012 NIVerified.lvproj file
  3. Open "Save and read control values from TDMS files LabVIEW 2012 NIVerified.vi"
  4. Select "Save to File" in the control "Function".
  5. Write values on the Test controls.
  6. Run the VI.
  7. Select the path where the file will be saved.
  8. Reinitialize controls from the Edit menu.
  9. Select "Set from file" in the control "Function".
  10. Run the VI.
  11. Select the path where the file was saved.

 

5. Additional Information or References

 

Save and read control values from TDMS files Screenshot.PNG

 

**The code for this example has been edited to meet the new Community Example Style Guidelines.**

Ashish Naik
Automotive Business Development Manager
National Instruments UK

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