Hardware timed single point acquisition using ANSI C
I'd like to perform HDTSP acquisition in the ANSI C enviroment. The code is listed in the following. would you please help me check it? I think there is some mistake because i cannot excuate it.
#include <stdio.h>
#include <NIDAQmx.h>
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
int main(void)
{
int32 error=0,read=1;
bool32 islate=0;
float64 data[1];
TaskHandle AItaskHandle=0;
char errBuff[2048]={'\0'};
/*********************************************/
// DAQmx AI Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&AItaskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(AItaskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(AItaskHandle,"",5000.0,DAQmx_Val_Rising,DAQmx_Val_HWTimedSinglePoint,0));
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(AItaskHandle));
/*********************************************/
// DAQmx Read Code
/*********************************************/
while(islate==0)
{
DAQmxErrChk (DAQmxReadAnalogF64(AItaskHandle,DAQmx_Val_Auto,10.0,DAQmx_Val_GroupByChannel,data,1,&read,NULL));
printf("%f\n",data[0]);
DAQmxErrChk (DAQmxWaitForNextSampleClock (AItaskHandle,10,&islate));
}
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( AItaskHandle!=0) {
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(AItaskHandle);
DAQmxClearTask(AItaskHandle);
}
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}