Example Code

TDMS Segment Reader 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

Code and Documents

Attachment

Overview

This example uses low level TDMS API to divide the channel into small chunks then adding them together in a while loop to increase performance

 

Description

TDMS files are binary files that are ideal for storing large amounts of test and measurement data, and automatically generate an index file to speed up reading the files. However, sometimes they can get extremely large and reading every piece of data in a channel isn't ideal to do with Express VIs. You might have something like 50,000 samples in a particular channel, which with an Express VI could be opening and closing your file 50,000 times and having your front panel lock up for a long time.

This is a basic example using the low level TDMS API in LabVIEW to divide the channel into small chunks, and then adding them together in a while loop. Technically the example can be further optimised for memory because building the waveform array in this way is using some temporary memory, whereas ideally you would initialise an array with a fixed size, and then replace a subset in every loop. Nonetheless, for the purpose of a basic example, the attached VI is sufficient and works efficiently.

 
Requirements

 LabVIEW Full Development System 2012 or compatible


Steps to Implement or Execute Code

  1. Select the path to the TDMS file to be used
  2. Enter the channels group name
  3. Enter the individual channel name to be retrieved
  4. Enter the number of samples to be read per loop
  5. Run the VI

 Additional Information or References

I have included a TDMS file with sample data. Notice that example.tdms_index is automatically generated by your computer.

VI Block Diagram

12200.PNG

 

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

 

Regards,


Imtiaz Chowdhury
Project Manager
Green Running / Austin Consultants

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

Comments
queese2
Member
Member
on

When I looked into the append waveform subvi I discovered a build waveform. Isn't it dangerous to use it in a while loop with a large TDMS File?

alpha1
Active Participant
Active Participant
on

I suppose it can be potentially a cause for an infinite (or at least very long) while loop, so a better option would be to also allow the user to stop the operation. In addition, it would be a good idea to implement a status bar with a status message and also a progress bar indicating how much of the loading is complete.

Regards,


Imtiaz Chowdhury
Project Manager
Green Running / Austin Consultants