Example Code

Simultaneously Write and Read TDMS Data To/From The Same File

Code and Documents

Attachment

 

Overview

This piece of example code show you how to write to a TDMS file using 3 single point data channels, and at the same time read back from the file all the way up to the last data point saved in the same TDMS file.

 

 

Description

This example uses a multi loop architecture to perform these operations. The top loop saves the interleaved data to the TDMS file. While the bottom loop checks the number of samples in the file every 250mS and updates a slider to allow you to move through your recorded data.

You supply the offset (or window size) of the data you want to view from the latest read position indicated by the slider. For this reason the minimum value of the slider is always the size of the offset. Once your offset number of points is written to the data file the slider maximum will increase with the file size.

You can afterwards move the slider to move through the historical data.

 

 

Requirements

LabVIEW 2012 (or compatible)

 

 

 

Steps to Complete

1. Download the attached zip folder "TDMS Simultaneous Read and Write_LV2012_NI Verified" .

2. Extract the files and open the project called "TDMS Write and Read.lvproj"

3. Open the "TDMS Write and Read.VI" from the project explorer window.

4. Run the VI

5. Modify the offset and Samples to be displayed in the graph (Samples displayed = Samples in File - Offset). Note that you must modify the value of the Samples in File Control in order to see the updates on the graph
6. Stop execution

 

 

Additional Information or References

If you do not select a group name then you will receive error 4 (End of File) from the TDMS read VI after the first read event.

 

Block Diagram

BD.PNG

 

Front Panel

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

Comments
Active Participant
Active Participant
on

This example is broken. You swapped the "offset" and "count" inputs on TDMS Read.vi.

NI-hilator
Member
Member
on

Is there a reason for using interleaved writes?  Does this effect being able to read the TDMS file back concurrently?