Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxBaseReadAnalogF64() Bug

Since the DAQmxBaseIsTaskDone() is not working with annalog input (a known bug), I wanted to write a workaround suggested by Joe Savage.

> Joe Savage wrote (04-08-2005):
> My previous posts only applied to DAQmx.
> However, to address the original post, with DAQmxBase you can perform
> a read with a zero timeout, which will cause the read to
> return quickly if the data to be read is not available.


I use the following test program:


DAQmxErrChk (DAQmxBaseCreateTask("AD",&taskHandle));
DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,600));

DAQmxBaseIsTaskDone(taskHandle, &isTaskDone);
printf("isTaskDone = %x\n", isTaskDone); // Known bug! isTaskDone is always 1

DAQmxErrChk (DAQmxBaseStartTask(taskHandle));


do {
i = DAQmxBaseReadAnalogF64(taskHandle,600,0,DAQmx_Val_GroupByChannel,data,600,&read,NULL);
printf("i = %d read = % d\n", i, read); // returns DAQmxErrorSamplesNotYetAvailable (-200284) if A/D in progress
}
} while(i != 0);

printf("task completed\n");


Zero timeout does not work correctly, the output of the program looks like this:

isTaskDone = 1
i= -200284 read = 0
i= 0 read = 600
task completed

There are only two iterations in the loop!
This indicates that DAQmxBaseReadAnalogF64() does not return immediately, it is waiting >= 300ms until it returns;

Similar results can be seen with timeouts < 0.01 s.

With 0.1 s timeout the program works correcly:

isTaskDone = 1
i= -200284 read = 0
i= -200284 read = 0
i= -200284 read = 0
i= -200284 read = 0
i= -200284 read = 0
i= 0 read = 600
task completed

however the variable "read" remains 0 until all samples are done.
According to the online documentation the variable "read" should return "The actual number of samples read from each channel".

This is probably a second bug in DAQmxBaseReadAnalogF64().

I use the latest version of DAQmxBase, USB-6008 with a Windows XP.
0 Kudos
Message 1 of 2
(2,852 Views)
Check out this thread:

http://forums.ni.com/ni/board/message?board.id=250&message.id=11228#M11228
John Weeks

WaveMetrics, Inc.
Phone (503) 620-3001
Fax (503) 620-6754
www.wavemetrics.com
0 Kudos
Message 2 of 2
(2,845 Views)