Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Spliting up NI-DAQmx functions gives me error code -200088

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();

}

 

0 Kudos
Message 1 of 2
(3,083 Views)
Yesterday, I ran across a very similar problem, and I also figured that there must be something wrong with the task handle - but it wasn't. I resolved my problem by changing in the call to DAQmxCfgSampClkTiming() the parameter DAQmx_Val_ContSamps to DAQmx_Val_FiniteSamps.

I do not know how this could make the difference, though, in my application I do need only a definite number of samples and changing the parameter seems to make sense for this reason. Only, I needed to make sure, that my reading routine does not read beyound the defined number of samples.

Best regards

Rolf
0 Kudos
Message 2 of 2
(3,063 Views)