Dieser Inhalt liegt nicht in Ihrer bevorzugten Sprache vor.

Der Inhalt wird Ihnen in einer anderen verfügbaren Sprache angezeigt. Ihr Browser bietet ggf. Funktionen, die Sie bei der Übersetzung des Textes unterstützen.

Start at Zero Using Waveform Charts

Updated Jan 2, 2024

Environment

Software

  • LabVIEW

Driver

  • NI-DAQmx

  • I am using a waveform chart in my application but the time on the x axis is showing 900,000+ hours. I would like to start my waveform chart at 0 seconds, how can I do this? 
  • I'm acquiring a signal using DAQ Assistant and when I plot it using a waveform chart it starts with an offset instead of starting at 0 seconds.

To set the chart to start at 0 seconds the following steps are required: 

  1. Right click on chart >> Properties
  2. Select Display Format >> Relative Time >> HH:MM:SS
  3. In the code use the Get Date/Time In Seconds function to find the timestamp when the code starts running
  4. Subtract that from the initial waveform
  5. Input resulting waveform into Waveform Chart indicator

The code to carry this out can be seen below: 


The resulting chart will look as follows: 

Using DAQ Assistant

If you are using the DAQ Assistant, the data will be in the format 'dynamic data type'.
To achieve a time x axis that starts at 0 seconds, please follow the next steps:
  1. Make sure you have your DAQ Assistant inside a While Loop.
  2. Add a Get Date/Time in Seconds to your diagram. Right-click the block diagram and select Programming>>Timing>>Get Date/Time in Seconds and drop it outside your while loop.
  3. You will need to convert your 'dynamic data type' from the DAQ Assistant to a 'waveform data type'. You can find the conversion function by right-clicking your block diagram and select Express>>Signal Manipulation>>From DDT. 
  4. Drop the function and a window will pop up. Choose 1D array of waveform and then wire the data output of the DAQ Assistant to the input of the Convert from Dynamic Data.
  5. Add a Get Waveform Components to your diagram. Right-click the block diagram and select Programming>>Waveform>>Get Wfm Comps and drop it inside your while loop.
  6. Wire the output of Convert from Dynamic Data to the input of Get Wfm Comps. Click the right square and change the attribute to t0.
  7. Add a subtract function. Right-click the block diagram and select Programming>>Numeric>>Subtract and drop it inside your while loop. Wire the output of Get Date/Time in Seconds to the second input of Subtract and the output of Get Wfm Comps to the first input.
  8. Convert the Subtract result to a time stamp. Right-click the block diagram and select Programming>>Numeric>>Conversion>>To time stamp and drop it inside your while loop. Wire the output of Subtract to the input of To time stamp.
  9. Add the new time stamp to the original waveform. Right-click the block diagram and select Programming>>Waveform>>Build Waveform and drop it inside your while loop. Wire the output of Convert from Dynamic Data to the top input of Build Waveform. Wire the output of the conversion function To time stamp to the bottom input of Build Waveform and change the attribute to t0.
  10. Wire the output of Build Waveform to the input of your waveform chart. It should start plotting at 0 seconds.

Find a VI version of this image attached. 
Ensure the DAQ Assistant is linked correctly to your hardware and physical channels. 

Additional Information

Waveform data contains the timing information from the system that the code is run from and is taken as the number of seconds since 12:00 a.m., Friday, January 1, 1904, Universal Time.  LabVIEW then formats that number into the current date and time.  

If the chart set to work with relative time the following image will be seen as the code only knows the reference of 01/01/1904 and displays the number of hours and minutes since that date as the "Relative Time."