Skip to content
Home » Blog » TDM Streaming in LabVIEW: Explore the Various Aspects.

TDM Streaming in LabVIEW: Explore the Various Aspects.

TDM Streaming in LabVIEW

Introduction to TDM Streaming in LabVIEW

TDM Streaming, also known as TDMS (Technical Data Management Streaming), is a powerful feature in LabVIEW that allows you to efficiently write data to disk in a structured format. This feature is particularly useful for data-intensive applications, such as data acquisition, signal processing, or control systems, where large amounts of data need to be recorded and analyzed. In this comprehensive article, we will explore the various aspects of TDM Streaming in LabVIEW, including its benefits, usage, and illustrative examples.

Table of Contents

  1. Understanding TDM Streaming
  2. Benefits of TDM Streaming
  3. Using TDM Streaming in LabVIEW
  4. Configuring TDM Streaming
  5. Illustrative Examples
  • Example 1: Writing Random Data to a TDMS File
  • Example 2: Writing Data from a Simulated Sensor to a TDMS File
  • Example 3: Writing String Data and Numeric Data to a TDMS File
  1. Best Practices and Tips
  2. Conclusion

1. Understanding TDM Streaming

TDM Streaming is a file format and data model introduced by National Instruments (NI) to efficiently write data to disk in a structured format. The TDM data model offers a hierarchical structure consisting of three levels: Root, Group, and Channel. Each level can have custom-defined attributes, making the data search-ready and easily accessible for later analysis[1].

TDMS files, which are the output of TDM Streaming, are binary files with a .tdms extension. They consist of a binary data file and an index file (.tdms_index) that provides consolidated information on the attributes and pointers in the data file, allowing for faster access when reading the data[1].

2. Benefits of TDM Streaming

TDM Streaming offers several benefits over traditional file operations in LabVIEW[1][3]:

  1. Efficient streaming of data to disk in a structured format
  2. Ability to save descriptive information with test data, making it search-ready
  3. Categorization of data under groups for better organization
  4. Abstraction of low-level file I/O operations
  5. Inclusion of properties to describe data for later analysis
  6. Compatibility with real-time systems

3. Using TDM Streaming in LabVIEW

LabVIEW provides several interfaces for reading and writing TDMS files[3]:

  1. Write to Measurement File Express VI: Offers an easy-to-use dialog-based configuration but sacrifices performance and is not suitable for high-speed streaming or real-time applications.
  2. TDMS primitive VIs from the File I/O palette: Provides more flexibility and better performance. Suitable for real-time applications using the LabVIEW Real-Time Module.
  3. TDMS Advanced palette: Introduced in LabVIEW 8.2, it offers extremely low-level control of TDMS files, enabling advanced techniques such as asynchronous writes and reads.

4. Configuring TDM Streaming

To configure TDM Streaming in LabVIEW, you can use the TDMS primitive VIs from the File I/O palette. These VIs allow you to create, write to, and close TDMS files, as well as manage properties and channels[3].

Some key configuration options include:

  • File path and file name
  • Append to file or overwrite
  • Precision for numeric data
  • Writing headers and properties

5. Illustrative Examples

Let’s explore a few illustrative examples to demonstrate the usage of TDM Streaming in LabVIEW.

Example 1: Writing Random Data to a TDMS File

In this example, we will generate random data using a loop and write it to a TDMS file using the TDMS primitive VIs.

// Create a new VI and add a For Loop to the block diagram
// Inside the loop, generate random numbers using the Random Number (0-1) function
// Use the TDMS primitive VIs to create, write to, and close the TDMS file
// Configure the file path, append/overwrite, and other options
// Connect the random data to the TDMS Write Data function
// Run the VI to generate and write the random data to the TDMS file

Example 2: Writing Data from a Simulated Sensor to a TDMS File

In this example, we will simulate a temperature sensor and write the sensor data to a TDMS file using the TDMS primitive VIs.

// Create a new VI and add a While Loop to the block diagram
// Inside the loop, generate simulated temperature data using a Random Number (0-1) function and scale it to the desired range
// Use the TDMS primitive VIs to create, write to, and close the TDMS file
// Configure the file path, append/overwrite, and other options
// Connect the simulated temperature data to the TDMS Write Data function
// Run the VI to generate and write the simulated temperature data to the TDMS file

Example 3: Writing String Data and Numeric Data to a TDMS File

In this example, we will write a combination of string data (e.g., column headers) and numeric data to a TDMS file using the TDMS primitive VIs.

// Create a new VI and build the string data using the Concatenate Strings function
// Generate numeric data using a loop or other functions
// Use the TDMS primitive VIs to create, write to, and close the TDMS file
// Configure the file path, append/overwrite, and other options
// Write the string data first using the TDMS Write Property function
// Write the numeric data using the TDMS Write Data function
// Run the VI to write the string data and numeric data to the TDMS file

6. Best Practices and Tips

Here are some best practices and tips when using TDM Streaming in LabVIEW:

  • Choose the appropriate interface: Select the interface that best suits your needs, such as the Write to Measurement File Express VI for quick configuration or the TDMS primitive VIs for more flexibility and performance.
  • Optimize performance: Use techniques like asynchronous writing and reading to improve performance when dealing with large amounts of data[4].
  • Utilize the TDM Streaming .NET Class Library: If you are using .NET languages, take advantage of the TDM Streaming .NET Class Library introduced in Measurement Studio 8.6[3].
  • Integrate with other NI tools: Leverage the integration of TDMS files with tools like NI DIAdem for interactive visualization, analysis, and reporting[3].
  • Validate file writing: Check the status of the file writing operation and handle any errors or exceptions that may occur during the process.

7. Conclusion

TDM Streaming in LabVIEW is a powerful feature that enables efficient and structured data storage to disk. By understanding its benefits, using the appropriate interfaces, and following best practices, you can effectively incorporate TDM Streaming into your LabVIEW projects. The illustrative examples provided in this article should give you a good starting point for working with TDMS files in your own applications.

Citations:
[1] https://www.ni.com/en/support/documentation/supplemental/06/introduction-to-labview-tdm-streaming-vis.html
[2] https://www.dmcinfo.com/latest-thinking/blog/id/178/labview-data-storage-overview-of-tdms
[3] https://www.ni.com/en/support/documentation/supplemental/06/the-ni-tdms-file-format.html
[4] https://www.youtube.com/watch?v=YKHXVcs6gCY
[5] https://labviewwiki.org/wiki/Functions_Palette/Programming/File_I/O/TDM_Streaming/Advanced_TDMS/TDMS_Advanced_Data_Reference_I/O