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.

Comments
gbusletta
Member
Member
on

This vi doesnt seem to work:

I get the following error

error code 116

Flattened String To Variant in TDMS variant conversion.vi->TDMS read front panel controls.vi->TDMS example main.vi

Ashish_Naik_NIUK
NI Employee (retired)
on

are you just running the example? what type of control are you trying to read/write from?

Ashish Naik
Automotive Business Development Manager
National Instruments UK
gbusletta
Member
Member
on

just running the example....extracted the zip file and opened the project. Ran the TDMS example main.vi

Was this incorrect?

Ashish_Naik_NIUK
NI Employee (retired)
on

no this is correct. When running the example, did you write a tdms file first, and then re-run the main vi with the read option selected?

Ashish Naik
Automotive Business Development Manager
National Instruments UK
gbusletta
Member
Member
on

yes I ran with the enum set to write first then re-ran it with the enum set to read and selecting the same file that I wrote to originally.

Is it working on your end? what version of labview are you running? Are there some add ons that are required for writing and reading to tdms files?

Ashish_Naik_NIUK
NI Employee (retired)
on

I have spotted the reason for the error message.. The reason for the error 116 message is the zip file is saving to tdms file version 1.0 rather than 2.0.. 2 changes are needed. On the TDMS Open in the TDMS example main.vi (save to file case) and the TDMS read front panel controls.vi change the constants to 2.0.

**I shall upload a new zip that fixes this error soon**

Ashish Naik
Automotive Business Development Manager
National Instruments UK