09-23-2007 10:14 AM
DAQmxErrChk (DAQmxCreateTask(
"Counter Task1",&taskHandle[1]));DAQmxErrChk (DAQmxCreateCICountEdgesChan(taskHandle[1],
"Dev1/ctr0","Counter0",DAQmx_Val_Falling,0,DAQmx_Val_CountUp)); // Counter 0DAQmxErrChk (DAQmxSetCICountEdgesTerm(taskHandle[1],
"Dev1/Ctr0","/Dev1/20MHzTimebase")); // Sets 20MHz as source clockDAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle[1],
"/Dev1/PFI7",40000,DAQmx_Val_Rising,DAQmx_Val_ContSamps,10000)); // using PFI7 as gateDAQmxErrChk (DAQmxCreateTask(
"Counter Task2",&taskHandle[2]));DAQmxErrChk (DAQmxCreateCICountEdgesChan(taskHandle[2],
"Dev1/ctr1","Counter1",DAQmx_Val_Falling,0,DAQmx_Val_CountUp)); // Counter 1DAQmxErrChk (DAQmxSetCICountEdgesTerm(taskHandle[2],
"Dev1/Ctr1","/Dev1/20MHzTimebase")); // Sets 20MHz as source clockDAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle[2],
"/Dev1/PFI4",40000,DAQmx_Val_Rising,DAQmx_Val_ContSamps,10000)); // using PFI4 as gateDAQmxErrChk (DAQmxStartTask(taskHandle[1]));
DAQmxErrChk (DAQmxStartTask(taskHandle[2]));
DAQmxErrChk (DAQmxReadCounterU32(taskHandle[1],360*RevsToAverage,TimeOut,TimeBuffer,BufferSize,&NumberReadOnTimeCounter,NULL));
DAQmxErrChk (DAQmxReadCounterU32(taskHandle[2],RevsToAverage,TimeOut,OncePerRevBuffer,BufferSize,&NumberReadOnOncePerRevCounter,NULL));
Reading Counter0 is producing BufferOverflow error, I did try doubling the BufferSize even 4X, it didn't help. So, I making the buffer for 72000 samples for example, so it gets the 72000 samples requested in the first iteration of the loop, but when it comes in the next iteration, I don't think the buffer is empty. I do free up the memory on the way out from each iteration too, I am wondering if there is any addiotional housekeeping that I have to dod for the buffer, as I thought NIDAQmx takes care of the flushing.
Thanks for your feedback
09-24-2007 04:01 PM
09-24-2007 05:49 PM