Overview
This document contains information and VIs to provide you with TDMS writing capability for the following:
- VxWorks, Mac OS, and Linux in LabVIEW, 7.1 and later
- Windows in LabVIEW 7.1-8.0.
Table of Contents
TDMS File Format
The TDMS file format is designed to write and read measured data at a very high speed, while maintaining a hierarchical system of descriptive information. Although the binary layout itself is simple, the optimizations TDMS enables by writing meta data incrementally lead to very sophisticated file configurations. The installed TDM Streaming application programming interface (API) in LabVIEW hides this complexity. However, the installed TDM Streaming API is available only for Windows and Phar Lap for the LabVIEW Real-Time Module, and requires LabVIEW 8.2 or later.
G TDMS VIs
Use the G TDMS VIs to complete the following actions:
- Write TDMS files on the VxWorks and Phar Lap real-time platforms
- Write TDMS files on every desktop operating system LabVIEW supports
- Write TDMS files in LabVIEW 7.1 or later
- Learn the internal structure of TDMS files
Note Equivalent functions for reading TDMS files on VxWorks, Mac OS, and Linux are not available at this time. You can read TDMS files on Windows using LabVIEW 8.2 or later, NI DIAdem 10.0 or later, or Microsoft Excel 2003 or later. You can download the TDMS Add-In for Microsoft Excel from the National Instruments Web site at ni.com (linked below).
The TDMS VIs available for download are G TDMS Open, G TDMS Write, G TDMS Close, and G TDMS Set Properties. G TDMS Write and G TDMS Set Properties are polymorphic VIs that allow you to write a large variety of data types to the file.
| Function | Description |
| G TDMS Open | Opens a .tdms file for writing. You also can use this function to create a new file or replace an existing file. Use the TDMS Close function to close the reference to the file. |
| G TDMS Write | Streams data to the specified .tdms file. The data subset to write is determined by the values you identify in the group name and channel name(s) in inputs. |
| G TDMS Close | Closes the .tdms file you opened with the TDMS Open function. |
| G TDMS Set Properties | Sets the properties of the specified .tdms file, channel group, or channel. The properties are written to a channel group or channel if you wire the group name or channel name inputs with values. If the group name or channel name inputs contain no values, the properties values become file-specific. |
The VI icon has a blue background, as seen in the following figure, and the VI name begins with G TDMS.
![]()
Refer to the Downloads section of this document to download the G TDMS VIs.
After you download the VIs, you can access the VIs from the labview\user.lib directory. Refer to the Adding VIs and Controls to the User and Instrument Drivers Subpalettes topic (linked below) in the LabVIEW Help for information about adding the VIs to the User Libraries palette.
Caveats and Recommendations
The following list describes some of the caveats and recommendations to consider when you download and utilize the G TDMS VIs.
-
The built-in TDM Streaming API in LabVIEW prevents a variety of problems that can occur if TDMS files are not properly structured. The G TDMS VIs in this document provide less protection. Refer to the TDMS File Format Internal Structure document (linked below) for more information about the composition of the TDMS file format and to learn how to optimize TDM Streaming writing and reading performance.
-
The G TDMS VIs do not create a .TDMS_INDEX file. The index file contains redundant information from the .tdms file that LabVIEW, NI DIAdem, and MS Excel use for high performance random access to data in .tdms files. LabVIEW 8.2 and other NI applications that natively support TDMS automatically generate the .TDMS_INDEX file when reading a file written by the G TDMS API.
-
Every time you write properties or data to disk, you create a new segment in the TDMS file. Every segment consists of a header section and a data section. The more segments you write, the more header information LabVIEW interprets when you load the file. An important recommendation is to keep the number of segments in the file as low as possible. For single-point data acquisition, accumulate multiple scans in an array before writing the array to disk. Avoid writing redundant properties or indexes. Write code so that header sections stay small and number as few as possible.
-
The G TDMS API technically allows you to write an arbitrary number of groups and channels to the file. The installed TDMS API in NI applications accepts up to 10,000 groups/channels. If you use 10,000 groups or channels, make sure the software and the machine you use for reading the file can process that number of objects.
-
The G TDMS VIs cannot share access to the same file with the installed TDM Streaming API in LabVIEW
Accessing the Help
There are no additional help files available in this document for download. Refer to the following topics in the LabVIEW Help for more information about TDM Streaming VIs and how to add the G TDMS VIs to the User Libraries palette.
File I/O with Binary Measurement Files
TDM Streaming VI and Functions
Adding VIs and Controls to the User and Instrument Drivers Subpalettes
Related Links
Developer Zone: Introduction to LabVIEW TDM Streaming VIs
Developer Zone: TDMS Add-In for MS Excel
Developer Zone: TDMS File Format Internal Structure
Reader Comments | Submit a comment »
Works.
After spending countless hours trying to
solve the problem of why the standard
write tdms file VI took 11ms to write 22 x
1 array of double (severly limiting
sampling speed), the VI in this library
takes just 5ms. For me, problem solved.
Thanks !
- Oct 15, 2012
both zipfiles were build for LV2010
both zipfiles were build for LV2010.
Please add te 7.x and 8.x versions
- Mar 28, 2011
gtdms_8.x.zip is LV 2010
The 8.x-version is actually a
labVIEW2010 version.
Please leave the 8.x untouched and add
a separate file ffor 2010
- Mar 28, 2011
labview 8.0 crash
After placing the gTDMS lib in the user library and trying to use this app the labview
crashes.
Can someone inform me on how to prevent
this?
-
dudib@alcielo.com
- Mar 02, 2011
Saving Waveforms is broken
Hi,
I use this VI-Based API to save DAQmx
Data in LabVIEW 7.1. When I try to save
the data as waveform, I get an error,
when I try to open the tdms file with
LabVIEW 8.5. Saving the data as 2D-
DBL works. It looks like creating the
index file breaks. After trying to open the
tdms file with 8.5, I cannot delete the
broken index file without closing first
LabVIEW 8.5.
Would be nice, if this will be fixed.
Marc
- Dec 17, 2008
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
