Hello,
I have written an application in C++ for the USB 6009 unit. I have successfully been able to simultaneously acquire data from the "ai0" and "ai1" channels. When I go for "ai2" and "ai3" the data starts to look confused...not sure how the DAQmx_Val_GroupByChannel works or whether I should use GroupByScanNumber.
Here's my code (snippets from my prog):
char Dev1_joint1_channels[] = "Dev1/ai0:1";
char Dev1_joint2_channels[] = "Dev1/ai2:3";//the only reason I split this is to test with and without
//buffersize is 500
uInt64 samplesPerChan = bufferSize/4;
// Data read parameters
float64 data[bufferSize];
int32 pointsToRead = bufferSize;
/---------Initialize the task--------------------/
DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,Dev1_joint1_channels,"",DAQmx_Val_Diff,min,max,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle3,Dev1_joint2_channels,"",DAQmx_Val_Diff,min,max,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxBaseStartTask(taskHandle));
/------------------------------------------------/
WHILE LOOP
{
/---------Acquire data--------------------------/
DAQmxErrChk (DAQmxBaseReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByChannel,data,samplesPerChan,&pointsRead,NULL));
/-----------------------------------------------/
/---------Assign to variables after averaging---/
joint1_chanA = arrayAverage(data,0,pointsToRead/4);
joint1_chanB = arrayAverage(data,pointsToRead/4,pointsToRead/4);
joint2_chanA = arrayAverage(data,pointsToRead/2,pointsToRead/4);
joint2_chanB = arrayAverage(data,pointsToRead*3/4,pointsToRead/4);
/-----------------------------------------------/
}//END WHILE LOOP
This works perfectly for just 2 channels, without even using the timer. I tried to stick the timer in, but the acquisition would not even go at that point. With 2 channels, I simply average the first half of data and assign it to the appropriate variable and then do the same for the second half. This works very well for just 2 channels, it's when i get into 4 channels that the data either doesn't show up, or is very confusing.
Help is appreciated!
Thank you!
Nathan
nbluvol@imaging.robarts.ca