Example Code

How to Display Absolute Timestamps from a LabVIEW Waveform in DIAdem

Code and Documents

Attachment

Overview


This example shows how to generate and save a LabVIEW waveform to a TDMS file, load that file in DIAdem, and view the data with respect to absolute timestamps.

The LabVIEW waveform datatype consists of the following elements:

  • t0 - The start time of the waveform.*
  • dt - The time interval between data points in the waveform.
  • y - The data values of a waveform.

*The t0 property can be stored as a timestamp or a numeric. If t0 was originally stored as a numeric, the behavior described below does not apply.

If you pass a waveform to the TDMS Write VI, the resulting TDMS file will contain one waveform channel that contains all of the information listed above. If you attempt to plot this channel in the View or Report Windows in DIAdem, the x-axis will display relative values for the timestamps in the waveform. These values are computed using the wf_increment channel property, and they start at zero.

In order to display the timestamps as absolute values, e.g. 01.01.07 12:00:00, it is necessary to split the waveform channel into two separate channels, one for the time, and one for the amplitude. This can be accomplished in either DIAdem or LabVIEW.

DIAdem Approach - These steps have been automated in the script "WaveformAbsoluteTimestamp.VBS"

  1. If you do not already have a TDMS file to work with, generate one using the unmodified shipping example "Cont Acq&Graph Voltage - Write Data with Time to File (TDMS).vi"
  2. Load the TDMS file into the DIAdem data portal.
  3. Calculate the difference between 1/1/0000 and the t0 value of the waveform (using the wf_start_time property)
  4. Split the waveform channel into time and amplitude channels.
  5. Add the offset computed in step three to the values in the newly created time channel.*
  6. Display the time and amplitude channels on a report having an x-axis configured with the correct time format.

*By default, converting the waveform channel to a numeric channel will create dates starting at 1/1/0000 in the resulting time channel.

LabVIEW Approach - Refer to the modified shipping example "Cont Acq&Graph Voltage - Write Data with Time to File (TDMS).vi"

  1. Use the WDT Get Waveform Time Array DBL VI to create an array of timestamps based on the t0, dt, and number of values in the y component of the waveform.
  2. Explicitly write this array to the TDMS file by itself so that it will be created in a separate channel.*
  3. Use the Get Waveform Components VI to separate the y values from the waveform.
  4. Again, write this array by itself to the TDMS file.
  5. Load the TDMS file into the DIAdem data portal. Notice there are already two channels, one for the time, and another for the amplitude.

*It is not necessary to offset the timestamps in the time channel in LabVIEW - the TDMS Write VI automatically handles this for you.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors