10-18-2010 09:50 PM
I would like some assistance with understanding the DAQmx Read analog function.
If I have a loop going at 5ms with the Task read rate at 1kHz, I will get approximately 5 data values per loop. Do these 5 data values represent 1 ms intervals?
ex. I have a function generator generating a linear function y = x, where y is the voltage and x is time in ms. Although the loop runs every 5 ms, will the data values outputted by the Task be 1v, 2v, 3v, 4v, 5v, or will they just be 5v, 5v, 5v, 5v, 5v?
This is important to me because I have a project in which it is really important to have both precise timing and precise data to go with each of the timing. It would be ideal if we could get a loop running at 1ms with data continuously recording, so we have data being recorded every ms, however, because of other operations happening inside the loop, the time it takes the computer to run the loop will be more than 1 ms. This is obvious when I set the loop speed to one loop every 1 ms and make the loop stop at 1000 iterations, the time of which the loop started and the time of which the loop stopped had a difference of about 10 milliseconds instead of 0.
To be able to run my project with precision in terms of time (running x amount of loops in exactly y seconds), I decided to make the loop speed 5ms a loop. This caused the difference between the start and stop times to be much less (about 3 ms). Now that I have "solved" the timing problem, it is also important that we get a data value for each millisecond that passed. I was hoping that the DAQ card is able to obtain a time dependent data value at each millisecond despite the fact that the loop loops at 5ms.
In short, if a loop loops every 5 ms but the read rate on the Task is 1kHz and the data being recorded changes every millisecond, will DAQ be able to pick up each unique data value happening at 1, 2, 3, 4, and 5 ms under "Single Channel>Multiple Samples>1D DBL"?
10-19-2010 02:23 PM
Hi Leyne,
The DAQmx Read function is calling to the board to take samples off of the FIFO buffer that is being filled as soon as a start trigger is given to the DAQ board to start acquiring. The acquisition rate on the board is set with DAQmx Timing vi and that will determine when data is sampled. There are a lot of differet factors to consider when you look at sample timing which is both hardware dependant and application dependant. Lets take a look at an example given the amount of information you have provided.
Whether your board can do simultaneous sampling or multiplexed sampling, you indicate you are only reading one channel. This will eliminate any concern of timing offset you may see in the multiplexed version of our boards. Lets assume you are sampling at 1kHz, and the DAQmx read is called when 100 samples are acquired. The single channel is sampled once per rising edge of the sample clock, hardware timed. At 1kHz, you will receive 1000 samples a second, 1ms apart from each other. These samples are being acquired on the board, but are waiting to be taken from the buffer with the DAQmx Read function.
When your buffer fills with 100 samples, so at 100ms, DAQmx Read will pull all 100 samples off the buffer and into your PC memory for use on your machine. These 100 samples are timed by your hardware AI clock (1ms apart) but are all grabbed at once from the board with the Read function. The timing on when they are grabbed are based on the start time of the acquisition, and the hardware timed sample clock timing.
I believe for your particular application you are doing things right. The internal sample clock is pretty accurate, and more can be found in the specifications if precise timing is concerned. If you set it to 1kHz, you will generate a unique A/D converted sample every 1ms at a 1kHz rate. The DAQmx Read function is the call to take those samples acquired and bring them onto your PC for analysis or saving. It is standard to have the DAQmx Read Number of Samples to be 1/10th of the sample rate used. This is to prevent buffer overflow/underflow on the board.
10-19-2010 06:29 PM
Thank you for the clarification!
I was also wondering, how accurate is the DAQ clocking? Can I run my program, see that there are, for example, 5k samples recieved, and say that my program has run for exactly 5000 miliseconds? The task read rate was 1khz.
10-19-2010 06:41 PM
Additionally, if the read rate was 20khz, is DAQ really taking 20 samples per millisecond? 100khz, 100 samples per millisecond? It is hard to believe because it would be such a fast collection speed!
10-20-2010 10:33 AM
Hi Leyne,
It is pretty accurate and fast, but what DAQ hardware are you using? This will help determine what specifications you have and what you can do as far as read rate. If you set the sampling rate on the card at 1kHz using DAQmx Timing, and run the task for 5 seconds, you will acquire 5000 samples over that 5 seconds. At 20kHz, the card will take 20,000 samples a second, or 20 samples a millisecond. Same with 100kHz, as long as your card permits that sampling rate, so it is important to look over the specifications of your card that you have.
10-20-2010 10:43 AM
The timing for Data Acquisition devices, at least those that use hardware timing, use a precision crystal oscillator. This oscillator is usually accurate to about 50ppm (0.005%) and has a value of either 80MHz or 100MHz that is then divided down to the sample rate you specify. This clock determines when the DAQ board takes samples. As a result, even though a Windows machine has a timing resolution and accuracy of milliseconds, a DAQ board can have a timing resolution and accuracy of microseconds and an accuracy
The board has an onboard buffer that stores samples until they can be transfered into the computers memory. Once they are in the computers memory, they are held there until your program calls DAQmx Read and retrieves the samples from memory. This way, the DAQ board can acquire with much faster and more accurate timing than your program.
10-25-2010 06:09 PM
The board is a NI PCI-6289. Thanks for explaining how it works. Seems like I have nothing to worry about in terms of its accuracy and precision. Thanks alot.
10-25-2010 06:56 PM
@Leyne wrote:
Seems like I have nothing to worry about in terms of its accuracy and precision. Thanks alot.
For future reference, this should be looked at before purchasing. The last thing you want is to open a card or module that has between 5 and 500 stickers saying you are unable to return the hardware after it is opened, only to find out it doesn't meet the specs you need.