Data Logging in NI LabVIEW With DAQ Hardware

Updated Nov 16, 2023

Environment

Hardware

  • CompactDAQ Chassis
  • USB-TC01
  • USB-6000

Software

  • LabVIEW

Driver

  • NI-DAQmx

Operating System

  • Windows

LabVIEW provides an easy-to-use application development environment designed specifically for the needs of engineers and scientists. Without any prior programming experience, you can use LabVIEW to take measurements from your DAQ device and create custom software functionality.

For data-logging applications, LabVIEW offers built-in functions to choose how data files are created. You can select from basic text files to compact binary files and user standard spreadsheet programs such as Microsoft Excel to view and interact with your data.

  1. Start with a basic measurement VI

Figure 1. LabVIEW applications consist of a Front Panel (left) and Block Diagram (right). Use the DAQ Assistant and Time Delay functions in a while loop to continually acquire data at an interval and plot it to a chart.
  1. Right-click on the Block Diagram, select Output » Write Measurement File, and place it on the Block Diagram.

Figure 2. The Write to Measurement File function saves data that you pass to it to a file.
  1. Once you place the Write to Measurement File function on the Block Diagram a configuration window pops up. Configure the settings as shown below:
  • Filename - Name the file and choose the file location.
  • File Format - Select Binary (TDMS), which is a file format you can open in Excel. You could also select Text (LVM) if you wanted to open the file in a simple text editor.
  • Action - Select Save to one file and Append to file. Because the DAQ Assistant outputs data in segments and the Write to Measurement File writes data to file in segments, you must configure the VI to Append to file each time it is called so it does not overwrite the existing data.
  • Segment Headers - The header displays meta information in the log such as the time, description, and operator. Choose One header only to set only one header for the entire log rather than one header per segment of data.
  • X Value Columns - The X Value Column shows the timestamp. Choose One column only to show the timestamp information in the log.
  • File Description - Add any additional information that you want recorded in the log file.

Figure 3. Configure settings for how the data should be logged.
  1. Wire the output of the DAQ Assistant to the input of the Write to Measurement File. 

Figure 4. Pass the acquired data from the DAQ Assistant to the Write to Measurement File to be logged to the file.
  1. Press the Run button in the top left corner to start the VI and log the measured data to file.

Figure 5. The run button starts your LabVIEW application.
  1. To view the data, open Excel and select the Add-Ins tab. Click the TDM Importer button to open the .tdms log.

Figure 6. LabVIEW automatically installs the TDMS plug-in into Excel so you can easily open data logs.
  1. The log file header information is displayed in the first worksheet and the logged data is displayed in the second worksheet. Add a line chart to view the data in a graph.

Figure 7. Use a line chart to visualize your data in Excel.

Next Steps

What Else Can You Do with LabVIEW?