Write To Measurement File Express VI
The simplest way to write to either a TDM or TDMS file is to use the Write To Measurement File Express VI from the File I/O palette. The only input needed for the VI is the DAQmx Task or the signals you are writing to disk, as shown in Figure 2.

Figure 2. You can wire data directly into the Write To Measurement File Express VI.
Within the configuration dialog of the Write To Measurement File Express VI, you can select to write to either a TDM or TDMS file. Also, you can use the configuration dialog to add properties to the file such as description, your own custom properties, or properties defined from the DAQmx Task, as shown in Figure 3.

Figure 3. After selecting to write to a TDM or TDMS file, you can also configure user-defined properties in the configuration dialog.
The Write To Measurement File Express VI is the simplest way to begin writing data to TDM and TDMS files. However, you have very little flexibility in the structure of the data written. To realize the full benefits of the TDM data model and write well-organized and documented data, you need to use data storage VIs and/or the TDM Streaming API.
Data Storage VIs
With data storage VIs, you can write data to either a TDM or TDMS file. The simplest form of writing measurement data with the LabVIEW data storage VIs is illustrated in Figure 4, where a data acquisition task generates an array of measurement values to the Write Data VI.

Figure 4. Data storage VIs document data at the channel level.
Notice that the Write Data VI has two inputs – name and unit – in addition to the signal input. You choose which additional information you wish to save through a configuration dialog that you access by double-clicking on the Write Data VI, similar to same process for the Write To Measurement File Express VI.
In Figure 4, all of the channels coming from the DAQ Assistant are given the same name and unit; however, the data storage VIs enumerate the channel name to prevent naming collisions. You can override the autoenumeration by passing an array of channel names to the name input or by using an individual Write Data VI for each channel, both of which are acceptable solutions. An additional benefit of the Write Data VI is that it automatically calculates the minimum and maximum values for each measurement array and saves them in the TDM or TDMS file.
Figure 4 outlines how the data storage VIs document data at the channel level. Figure 5 illustrates how you can use the Set Properties VI to save additional descriptive information at the file level.

Figure 5. Use the Set Properties VI to save additional descriptive information at the file level.
Figure 6 illustrates the simplest form of reading data using data storage VIs. Here, the Open Storage VI passes a file reference to the Read Data VI and then all data is read from the TDM or TDMS file into memory and displayed on a waveform graph.

Figure 6. The Open Storage VI passes a file reference to the Read Data VI and then all data is read from the TDM or TDMS file into memory and displayed on a waveform graph.
TDM Streaming API
Although data storage VIs are easy to use and flexible, they do not exhibit the same performance when writing data to disk that you achieve using the TDM Streaming API. The TDM Streaming API was designed to stream data to disk at high speeds and with a small disk footprint, which is why it is also ideal for writing data on a real-time system.
The simplest form of writing measurement data with TDM Streaming VIs is illustrated in Figure 7. In this example, the DAQ Assistant generates an array of measurement values and passes them to the Write Data VI.

Figure 7. Write data to a TDMS file at the channel level.
Notice that the Write Data VI has two inputs in addition to the signal input. In Figure 7, all of the channels coming from the DAQ Assistant are given the same group and channel name. If the group and channel name inputs are left unwired, they default to untitled.
Figure 8 shows the simplest form of reading data using TDM Streaming VIs. Here, the TDMS Open File VI passes a file reference to the TDMS Read File VI and then all of the data in the “Main Group” group is read from the TDMS file into memory and displayed on a waveform graph.

Figure 8. Read data back from a TDMS file.
The TDMS data model automatically creates certain properties when some data types are written. However, in many cases, you may want to create a property specific to your particular needs, such as unit under test, serial number, and test temperature. You can achieve this using the TDMS Set Properties VI, with which you can write properties at the file, group, or channel level, as shown in Figure 9.

Figure 9. Write custom properties at three different levels before writing data to the file.
The following example demonstrates how to assign custom properties to multiple TDMS channels. In this example, two channels named Noise and Temperature are written to the same TDMS file and channel group. Each channel is assigned its own property values using the TDMS Set Properties function before the data is written. When the file is opened in a TDMS-compatible application, the properties are stored with their corresponding channel and can be used to provide additional metadata such as sensor identifiers, descriptions, or engineering information.
Notice that this approach scales easily to any number of channels. To add more channels, simply append additional elements to the channel name and property arrays; the For Loop automatically processes them. In this case, the property values are set using a 2D array, in which each row corresponds to the properties of a channel - the Noise channel is assigned the label N01, and the Temperature channel is assigned the label T01 before the data is written to the TDMS file.

Figure 10. Assigning channel-specific properties to multiple TDMS channels prior to writing the data to a TDMS file.
Viewing the Generated TDMS File in LabVIEW
After writing the TDMS file, you can use TDMS File Viewer VI to verify that the data, channel names, and custom properties were written as expected. This utility provides a convenient way to inspect the file structure directly within LabVIEW without requiring third-party tools.
The TDMS File Viewer displays the hierarchy of the file, including groups, channels, and associated properties. In the following example, the channels Noise and Temperature were written using a single TDMS Write call. Opening the file in the TDMS File Viewer allows you to confirm that both channels were created successfully and that any custom properties were stored correctly.
Tip: The TDMS File Viewer is particularly useful during development and troubleshooting because it allows you to quickly validate the contents of a TDMS file immediately after it is generated.

Figure 11. Writing multiple channels (Noise and Temperature) to a TDMS file using a single TDMS Write operation.

Figure 12. Viewing the resulting TDMS file in TDMS File Viewer.vi to verify the file hierarchy, channel names, and custom properties.
You may also view or import TDMS files using other tools such as Microsoft Excel, MATLAB, or DIAdem. Refer to the related links section below for application-specific instructions.
The mark LabWindows is used under a license from Microsoft Corporation. Windows is a registered trademark of Microsoft Corporation in the United States and other countries.