05-11-2006 12:15 PM - edited 05-11-2006 12:15 PM
Message Edited by Frank Rizzo on 05-11-2006 12:16 PM
05-12-2006 07:05 PM
Hi Frank,
Just as you figured out, you definitely want to set the acquisition mode to continuous in this case. A finite acquisition acquires a predetermined number of samples, and then stops when the buffer is full. In your case, you would acquire that specified amount, stop the acquisition, then on the next loop try to read samples that didn't exist (which throws the error you saw). In a continuous acquisition, the board just keeps grabbing those samples until stopped by the user or another event.
I ran the code on my machine (I have different hardware, an M-series DAQ card), and for me it ran just as you had intended. It ran continuously, and on every loop it acquired exactly 80 samples on all 9 channels. I'm not sure how you could be getting less than 80 samples if you have the 'number of samples per channel' input of the DAQmx Read VI set to 80. The way it works is when the VI is called inside the loop, it checks the buffer to see if 80 samples are available. If they are, it reads that data off the buffer. If there are less than 80 samples in the buffer, it waits until either the buffer reaches 80 samples or the specified timeout value is reached.
Could you try running it with just 1 channel to see if that behaves correctly?
Thanks,
Justin M.
National Instruments
05-15-2006 08:24 AM - edited 05-15-2006 08:24 AM
Message Edited by Frank Rizzo on 05-15-2006 08:26 AM
05-16-2006 06:43 PM
Hi Frank,
I took a look at the code in DAQmx read position.vi, and it looks like an output of 80 or above from the 'samples available' output should be possible. The 'samples available' output just shows the total number of samples acquired (per channel) minus the current read position. Here is some pseudocode of what the DAQmx read position.vi is actually doing:
Let samples to read = 80;
IF (have not read in 80 new samples from current read position) {
leave current read position alone and keep reading in values;
ELSE (if you have read in 80 or more new samples from current read position)
set a new current read position that is 80 samples behind the most recent sample acquired;
The software is checking the hardware buffer for the number of samples available. When the VI gets called, if the DAQ card has not read in 80 new samples since the last time the current read position was set, it does nothing and waits for the next iteration of the loop. If it reads the buffer on the next iteration and finds that there are 100 samples waiting, it sets the current read position to 20 so that the DAQmx read will grab the most recent 80 samples, and disregard the other 20.
It looks like this VI was designed for the case where the DAQ card is acquiring data faster than the software can read it out of the buffer. If this were the case, the buffer would eventually fill up and then throw an error. This DAQmx read position VI makes sure that when the buffer starts filling up past the number you are trying to read, you always grab the most recent samples. For your specific case, I'm guessing that your program is reading the samples out of the buffer fast enough, so the 'samples available' output should never hit 80 or above.
That was a little tough to put down into words...let me know if any of this is unclear.
Thanks,
Justin M.
National Instruments
05-18-2006 12:24 PM