NI DAQ cards are not synchronized to the computer’s system clock and do not output timestamp data. The timestamp in the waveform acquired is based on the system clock; however, it is a software time value because it is based on when the operating system retrieves the data values from the buffer of the DAQ card (Tos_retrieval) after the DAQmx Read VI
is called and the samples are available. The timestamp is a calculated value taking into account the time interval (dt) and the number of samples being acquired from the buffer (#s) in order to approximate the time that the acquisition started:
The system clock is read only once when the data is read from the buffer the first time. This is because the data being acquired is hardware-timed. All of the timestamps for the data values in an acquisition are correct relative to that first timestamp. For a continuous task, the timestamps following the first read from the buffer (t0next) are calculated from the first timestamp in a similar manner but also include the number of buffers read (#b):
The t0 calculation assumes that the acquisition is still running when the Read VI is called. For the best accuracy, the DAQmx Read VI
needs to be called while the DAQ card is still acquiring the first set of samples. If there is a delay and the DAQmx Read VI
is called after the DAQ card has completed the acquisition, the timestamp will be inaccurate. One way to prevent this is to use a trigger to start the acquisition.
As stated above, the accuracy of the timestamp data is dependent on the operating system. A Windows OS may have near millisecond resolution and a Real-Time OS may have somewhere near microsecond resolution. But in these cases, the timestamp is still software timed and may be much worse than their potential high. If your operating system is not returning timestamps that are sufficiently accurate for your application, then you may consider our high-speed digitizers, which use hardware timestamps. For more information refer to the NI High Speed Digitizers Help Manual
Time Interval (dt)
The time interval is the change in time between each sample of the waveform. This value is hardware-timed and is as accurate as the clock of the DAQ card being used. To determine the accuracy of your card, refer to the specifications
for that particular card.
Because DAQmx does not know the rate when "Handshake", "Implicit", "On Demand", or "Change Detection" timing is specified, DAQmx returns dt
as 0. Waveforms with a dt
of 0 will often not work with the waveform analysis functions. However, you can update the value of dt
in your application if you know the expected rate of the timing source.
The waveform data type only supports equal timing between samples. If your timing is not equal (for example each sample has its own timestamp) the waveform data type cannot contain the timing information. You can, however, use your Application Development Environment’s analysis library to resample the data using a constant dt
. The resampled data can then be used with the waveform-based analysis library.
If you are doing a finite acquisition with a ten-second duration and the code is waiting for a user input value after DAQmx Start Task
and before DAQmx Read
, then the data will start acquiring when DAQmx Start Task
is called and sit on the buffer until DAQmx Read VI
If the user waits two minutes before they enter the value, the timestamp will be two minutes off from the actual acquisition time. If the user inputs the value one second after DAQmx Start Task
is called, then the timestamp will be as accurate as the operating system allows.
Ways to prevent this are to remove the code that waits for the user input or use a triggered acquisition which starts after DAQmx Read
If you are doing a continuous acquisition and you are viewing the timestamp data of the waveform and none of the timestamps are evenly spaced as expected, then there is a problem with the coding of the task. This may be caused if the number of samples per channel input is not wired correctly.