Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I acquire data at equal time increments?

I am acquiring data within a loop using DAQ Assistant (4-20mA signal) and then writing this data to a file in each loop iteration (file is opened and closed outside the while loop).  To control the sampling rate of the loop, I use the Wait Until Next ms Multiple vi and in DAQ Assistant, I use the 1 sample On Demand option.
 
At slower sampling rates (100 ms or 10Hz), the program is doing an okay job at capturing the data at equal time increments.  However, at higher sampling rates (10 ms or 100Hz, which is what we're shooting for in our application), some of the time points are repeated, even though the corresponding data for those time points are different.  For example, when collecting at 100Hz, we'd see something like this in the output file:
 
Time (s)      Data (units)
0.015625     1.5
0.015625     2.8
0.03125       6.3
0.046875     3.1
0.046875     7.2
 
Overall, we are, in fact, seeing about 100 samples in a 1 second period, but we keep seeing these repeated time points.
 
For our application, we would like to collect the data at 100Hz and then perform an FFT on this data, however, we would like the time vector to contain equal time increments.
 
Is this timing issue a common problem?  Any suggestions on how to fix it, or if not, how to perform an FFT within a program that is writing each data point to a file within each loop iteration?  Should we just use the Tick Count for our time data?
 
0 Kudos
Message 1 of 2
(2,736 Views)
You can improve things by using a timed loop instead of a while loop but even then, you are not guaranteed that every iteration will happen at exactly the rate you specify. The timed loop will do it's best and then inform you when it late but there's not much you can do to prevent windows from interupting periodically. The best and most reliable method is to not use on demand but hardware timing. The on-board clock of the DAQ board will assure you of very precise timing. There are numberous shipping examples. I suggest you look at some the continuous acquisition types.
0 Kudos
Message 2 of 2
(2,730 Views)