04-07-2009 04:47 PM
Hello Kgy,
Typically, t0 is taken and is associated with the time of your first sample read. However, there are several limitations to using t0. These are outlined in the DAQmx help. You can find the help file by going to Start » Programs » National Instruments » NI-DAQ » DAQmx Help. Once inside, search for "waveform timing limitations". This outlines how t0 is taken and used to aproximate the time of your first sample. This is done by reading the system time at the time you call the DAQmx read and subtracting the number of samples already acquired to determine t0. This doesn't work if you call the read after the acquisition is complete.
In my opinion, you have two options.
Option #1:
Try and do exactly what the driver does. This will require you to do exactly what you are doing in the posted example. Call the current system time immediately prior to calling the DAQmx Read and subtract dt * x where x is the number of samples already acquired. This will require you to know exactly how many samples have been acquired. This can be found by calling the Total Samples Per Channel Acquired property immediately prior to the DAQmx Read. This introduces some points of innaccuracy. For example, you're system time is already innaccurate to some amount. In addition, it takes some time between calling system time, calling the total samples acquired, and calling the DAQmx read. If 2 samples are acquired between calling the system time and total samples acquired, you could be off by a few samples. For slower clock rates, you will have more accuracy.
Option #2:
If you are not using any triggering and you acquisition starts immediately upon calling the DAQmxStartTask function, you can use option #2. All you need to do is call the current system time prior to calling DAQmxStartTask and using this system time as the time for your first sample. The innacuracy in this measurement will be due to the system time innacuracy and the amount of time between calling system time and initiating the task to start taking samples.
If you are using any triggering to start your acquisition, you must use option #1. If you are calling DAQmxRead after all of your samples have all been acquired, you must use Option #2. Otherwise, both methods should be pretty close to the initial time for the first sample. The main point is that you should take t0 with a grain of salt. Understand that taking timestamps using system time has its own inherent innaccuracy. If you are looking for a device that has more accurate timestamping information, I would highly advise you to take a look at our High Speed Digitizers.
I hope this information helps,
Paul C
04-07-2009 08:35 PM