Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Adding Data Logging

Acquiring data is the first step in performing an experiment, but the data is lost if it is not recorded. This is where computer-based data logging is useful.  Data logging allows for every point of data acquired by the DAQ device to be recorded to a measurement file for later review. This module introduces you to data logging in NI LabVIEW software.


Step-by-Step Procedure

Download the Step-by-Step Procedure PDF


Before starting this procedure, you should complete the exercise and use the solution in the Taking a Measurement module. You can also create a numeric control to simulate the data acquisition input.

  1. Add the Write to Measurement File Express VI to the block diagram
    1. Right-click on the block diagram and select Express»Output»Write To Measurement File
    2. Place the Write to Measurement File Express VI to the right of the DAQ Assistant, within the While Loop
  2. Configure the Write to Measurement File Express VI
    1. Enter the Filename as desired; select the Browse icon if preferred
    2. Specify the File Format as desired; in this example Binary (TDMS) is selected
    3. Choose which Action to take if the Filename already exists; in this example Append to file is selected
    4. Specify the Segment Header type as desired; in this example only one header is created for the entire log file that is composed of multiple data sets
    5. Specify the X Value Columns as desired; in this example there is One column only for the time columns
    6. Provide a File Description to help identify the data set if desired
  3. Wire the data from the DAQ Assistant into the Signals input of the Write to Measurement File Express VI
  4. Run the VI to visualize the data on the front panel as well as log data to the file
  5. Read the Binary TDMS log
    1. Use the Read from Measurement File Express VI located by right-clicking on the block diagram and selecting Express»Input»Read from Measurement File
    2. Use the TDMS plug-in with Microsoft Excel to open the file by opening Excel, selecting the Add-Ins pane, selecting the TDMS Importer button, and browsing to the Filepath (the data is located on the second worksheet tab of the Excel document)
 

LabVIEW Example Code

Right-click on the above VI snippet and select Save Image As... Locate the file on your hard disk and click and drag the file icon onto your LabVIEW block diagram. LabVIEW automatically generates the code from the VI snippet. For more information, read VI Snippets.

Module Exercise: Adding Data Logging

Download the Module Exercise PDF

Prompt the user for a filename after the run button has been pressed by using the File Dialog Express VI. This allows the user to choose where to place the data log. Before starting this exercise, you should complete the exercise and use the solution in the Taking a Measurement module.

Things to Consider

  • Search for the File dialog in the Functions palette search bar to locate this VI.
  • This VI has a configuration window. Do you want to allow for multiple selections? Do you want to allow for folders, too? Do you want to allow for new files, existing files, or both?
  • Should this be placed inside or outside the While Loop? Consider what happens to any VI placed within the While Loop.
  • Does the File dialog allow for any other customization?
  • Why would this be beneficial?

View the exercise solution (Don’t cheat!).

Cumulative Exam:
LabVIEW and DAQ

Evaluate your understanding of LabVIEW and the basics of DAQ. This exam is recommended after you complete all of the modules for LabVIEW Basic Concepts and LabVIEW Basic Tasks. There are 26 multiple choice questions on the exam.

Take the exam


Cumulative Project:
LabVIEW and DAQ

Assess your working knowledge of building a complete system by acquiring, processing, and displaying data with LabVIEW and a DAQ device. This project is recommended after you complete all of the modules for LabVIEW Basic Concepts and LabVIEW Basic Tasks.

Start the project