09-10-2008 06:00 PM
Dear All:
From the program below, I read from A/D and send data to D/A, the sampling rate is less than 20Hz.
My DAQ is NI6229, and OS is window XP.
How should I increase the sampling rate?
.
Thank you,
Chai9999.
int main(void)
{
int error=0;
char errBuff[2048]={'\0'};
TaskHandle taskHandle=0;
float64 idata1;
while (1) {
/*********************************************/
// DAQmx Configure Code READ A2D
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_RSE,-10.0,10.0,DAQmx_Val_Volts,""));
DAQmxErrChk (DAQmxReadAnalogScalarF64(taskHandle,10.0,&idata1,0));
DAQmxClearTask(taskHandle);
/*********************************************/
// DAQmx Configure Code SEND D2A
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandle,"Dev1/ao0","",-10.0,10.0,DAQmx_Val_Volts,""));
DAQmxErrChk (DAQmxWriteAnalogScalarF64(taskHandle,1,-1,idata1,NULL));
DAQmxClearTask(taskHandle);
}
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
}
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}
09-11-2008 04:20 PM
Hi chai9999,
It seems that you do not have the timing configured for this task. You can do so by adding the DAQmxCfgSampClkTiming() function. A good place to begin learning about DAQmx programming is this page. In addition, the NI-DAQmx C Reference Help is installed with the driver. The path to a few examples can also be found inside that Help file.
Regards,
Kent
Applications Engineer