08-07-2014 01:28 AM - edited 08-07-2014 01:30 AM
Hello
i write a little programm. with this programm i like to read continuous samples from my NI 6251 with 1MHZ. I works okay, but every 3000 samples it is not continuous and i lost 0,010ms. I think think i not good to initialised the task every 3000 samples, but i have found no other solution that is working for me.
Need i a callback funtion to do this or need i on external clock to do this correct..
Here is mylittle porgramm.
#include<stdio.h>
#include<NIDAQmx.h>
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
int main(void)
{
int32 error=0;
TaskHandle taskHandle=0;
int32 read;
float64 data[3000];
char errBuff[4096]={'\0'};
float64 spannung1[3000];
int32 start = 0;
int i;
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Diff,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",1000000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,3000));
for (start=0;start<1000;start++)
{
DAQmxErrChk (DAQmxStartTask(taskHandle));
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,3000,10.0,DAQmx_Val_GroupByChannel,data,3000,&read,NULL));
for(i=0; i<3000; i++) {
spannung1[i]=data[i];
printf("Zahl %d %d %f\n",start,i, spannung1[i]);
}
DAQmxStopTask(taskHandle);
}
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
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;
}
thanks for helping me.
08-07-2014 03:06 PM
ich had solve my problem with a callback funktion.