I am trying to read 1 sample from two different analog inputs on a USB6009 device. I tried doing a very simple modification to the acquire1Scan.c example but the second channel is not being read. Am I doing something wrong here. I think I highlighted all the changes I made to the example.
// Task parameters
int32 error = 0;
TaskHandle taskHandle = 0;
char errBuff[2048]={'\0'};
// Channel parameters
char chan[] = "Dev1/ai0:1"; float64 min = -10.0;
float64 max = 10.0;
// Timing parameters
uInt64 samplesPerChan = 1;
// Data read parameters
float64 data[2]; int32 pointsToRead = 1;
int32 pointsRead;
float64 timeout = 10.0;
DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,chan,"",
DAQmx_Val_RSE,min,max,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxBaseStartTask(taskHandle));
DAQmxErrChk (DAQmxBaseReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByChannel,
data,samplesPerChan,&pointsRead,NULL));
printf ("Acquired reading: %f, %f\n", data[0], data[1]);Error:
if( DAQmxFailed(error) )
DAQmxBaseGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
DAQmxBaseStopTask(taskHandle);
DAQmxBaseClearTask(taskHandle);
}
if( DAQmxFailed(error) )
printf("DAQmxBase Error: %s\n",errBuff);