03-21-2013 08:47 AM
Hi, I am using an NI USB-6343 for data aquisition. I will be testing anywhere from 1 to 8 batteries at one time. When testing 1-4 batteries there are no errors. However, once I test 5 or more, i get a 200088 error, which reads "task specified is invalid or does not exist". It will even crash the program if I test 8 at once. The data aquisition code is shown below:
TaskHandle VtaskHandle=0;
// DAQmx Configure Code
DAQmxErrChk (DAQmxCreateTask("readVoltage",&VtaskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(VtaskHandle,getPorts(1).c_str(),"",DAQmx_Val_RSE,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(VtaskHandle,NULL,10000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,100));
// DAQmx Start Code
DAQmxErrChk (DAQmxStartTask(VtaskHandle));
// DAQmx Read Code
DAQmxErrChk (DAQmxReadAnalogF64(VtaskHandle,-1,-1,DAQmx_Val_GroupByScanNumber,temp,numChannels*100,&read,NULL));
//This just averages all readings to a single value for each channel
double averageTemp = 0;
for (int x = 0; x < numChannels; x++){
averageTemp = 0;
for (int y = x; y < (read*numChannels)+x; y+=numChannels){
averageTemp = averageTemp + temp[y];
}
voltageData[x] = (averageTemp/read);
}
DAQmxStopTask(VtaskHandle);
DAQmxClearTask(VtaskHandle);
// DAQmx error handling
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( VtaskHandle!=0 ) {
// DAQmx Stop Code
DAQmxStopTask(VtaskHandle);
DAQmxClearTask(VtaskHandle);
}
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
A lot of this is gathered from sample code. Two other almost identical copies of this code run once per second, one for voltage, current and temperature. If I only measure voltage the error occuring once 5 batteries are tested dissapears, but still crashes at 8. Any help is appreciated.
Thank you.
03-21-2013 09:29 AM
Also, if I take out the stop and clear task functions (not in the error handling section), I get "DAQmx Error: " but no error description or code.