05-25-2009 11:57 AM
I took one of the example C files and started to split up the functionality so I can call upon them in a larger program.
When I do this, when the second function works with TaskHandle, I get error -200088.
I set the TaskHandle variable as a global and during debug, I see that the value has not changed when it hits the second function. Why has the handle become invalid?? I cut and pasted the section of code below.
I saw a simlar problem in the following post, but there was no answer...
http://forums.ni.com/ni/board/message?board.id=250&requireLogin=False&thread.id=16497
Thanks in Advance!
Running on Visual C++ 2008.
int DAQ_fnInit(void) {
/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&DAQ_taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(DAQ_taskHandle,CHANNELS,"",DAQmx_Val_RSE,MINVOLTAGE,MAXVOLTAGE,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(DAQ_taskHandle,"",SAMPLERATEHZ,DAQmx_Val_Rising,DAQmx_Val_ContSamps,SAMPPERCHANTOACQ));
//Configure the DAQ so that the buffer is overwriten.
DAQmxErrChk (DAQmxResetReadOverWrite(DAQ_taskHandle));
DAQmxErrChk (DAQmxSetReadOverWrite(DAQ_taskHandle,DAQmx_Val_OverwriteUnreadSamps));
DAQmxErrChk (DAQmxSetReadRelativeTo(DAQ_taskHandle, DAQmx_Val_MostRecentSamp));
DAQmxErrChk (DAQmxSetReadOffset(DAQ_taskHandle, 0));
DAQmxErrChk (DAQmxStartTask(DAQ_taskHandle));
Error:
DAQ_fnCheckError();
return NI_error;
}
void DAQ_GetMeasurement(void) {
int32 NI_qtyofreadpts;
float64 NI_data[200];
//Battery Calculation
DAQmxErrChk (DAQmxReadAnalogF64(DAQ_taskHandle,100,DAQmx_Val_WaitInfinitely,DAQmx_Val_GroupByChannel,NI_data,200,&NI_qtyofreadpts,NULL));
Error:
DAQ_fnCheckError();
}
void main() {
DAQ_fnInit();
DAQ_GetMeasurement();
printf("End of program, press Enter key to quit\n");
getchar();
}
05-26-2009 06:21 AM