How Do I Include a Time Stamp in a File Using the Write To Measurement File VI?

Updated Oct 19, 2018

Reported In

Software

  • LabVIEW

Issue Details

  • I would like to include time in my data collection, how do I do this?
  • When I use the Write to Measurement File Express VI, I want the X value column to be the CPU time stamp. By default, the X value column has time values that start only when the execution starts. How can I change this?

Solution

This can be done in two ways. The first way is for writing to a .lvm file, and the second is for writing to a .tdms.
 

For a .lvm file 

  1. The DAQ Assistant is acquiring data continuously.
  2. Use the Get Date/Time in Seconds.vi to acquire the time at which the data is acquired.
  3. Use the Format Date/Time String.vi to convert the time stamp data into a string that can be wired into the comment section of the Write to Measurement File.vi.
  4. Concatenate the time string with a tab constant so that the data appears correctly in the text file.
  5. Wire the final time data into the Comment input of the Write to Measurement File.vi.
Now the CPU time will show up in the text file next to the data that you are writing in the while loop.  If you are acquiring more than 1 sample in the DAQ Assistant, only one value of time will show up for all the samples that you acquire. The resulting measurement file will have one time stamp at the beginning of each measurement set.  A screenshot is shown below.
Note: You would also need to select Empty Time Column in the configuration for the Write To Measurement File.vi, if you do not want the default time data to appear. 
 

For a .tdms file: 

  1. Acquire data in continuous mode using a DAQ Assistant.
        Note: This method will also work with DAQmx VIs that are acquiring waveform data.
  2. Wire the output of the DAQ Assistant to the Write to Measurement File.vi
  3. Configure the Write to Measurement File.vi to log time in One column only with One header only, as in the settings below:
Now the time stamp will be logged in a column to the left of the measurements under the heading Time, and the dt value will be logged under the heading Time*. A screenshot of the resulting .tdms file in Excel is shown below:
Note: Unlike with a .lvm file, a .tdms file will record a timestamp for every data point.

Additional Information

  • Enabling the One Column per channel option under the X Value (Time) Columns will insert an additional column for each channel, increasing considerably the file size for each additional channel.

WAS THIS ARTICLE HELPFUL?

Not Helpful