Log Data From NI-DAQmx Task Into Separate TDMS Files for Each Channel

Updated Nov 27, 2020

This article goes through the steps on how to log data for each channel of an NI-DAQmx task into separate TDMS files. It assumes that you already have an NI-DAQmx task with more than one channel that was defined using either NI MAX or LabVIEW and general knowledge about the TDMS file format.

1. Create an NI-DAQmx task which is going to acquire data from a DAQ system with more than one channel. If you have doubts on how to create an NI-DAQmx task, please take a look at the following article: Create Tasks for NI-DAQmx Devices in LabVIEW.

2. Use the function Array Subset to get the data for each of the channels by going to Programming >> Array >> Array Subset and place it into the block diagram.

3. Connect the data wire from the DAQmx Read (VI) output into the Array Subset input terminal and wire a constant number to the index terminal to select the channel.

4. Implement the TDMS logging functionality by placing the TDMS Open, TDMS Write and TDMS Close functions which can be found in the Programming >> File I/O >> TDM Streaming palette. If you need more information on how to use the TDMS API for logging data, please take a look at the following article: Introduction to LabVIEW TDM Streaming VIs.

5. Connect the subarray output terminal to the TDMS write input data for each one of the channels.

The resulting VI should look similar to the one below which shows an example with two analog input channels included into the same task and data being logged to two separate TDMS files: