Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

double buffering using ni-daq mx base

Who could tell me where to find a description of the analog input functions available in NI-Daq mx Base package. I'm trying to set up a continuous sampling task in the background, to be analysed in realtime (maximal delay of a few ms). Under OS9 using NI-Daq I used to do this by double buffering and keeping track of the most recent samples in this buffer). Under Mac OSX it seems there is a very limited subset of function calls and tasks available and I can't even find a decent description of these functions. I am programming in Xcode (C/objective C) and I'm using the USB 6009.
The example code for contAcquireNChan.c seems to work fine. The problem continuing from there is that I do not see how to set up the separate calls to make it do what I want. Several functions have nrofsamples variables and buffersizes, some of which probably get overruled. But I cannot find a description of this behavior.
The basic function calls are very simple:

DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandle,clockSource,sampleRate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,samplesPerChan));
DAQmxErrChk (DAQmxBaseCfgInputBuffer(taskHandle,1000)); //?
DAQmxErrChk (DAQmxBaseStartTask(taskHandle));

// The loop will quit after 10 seconds

startTime = time(NULL);
while( time(NULL) DAQmxErrChk (DAQmxBaseReadAnalogF64(taskHandle, pointsToRead, timeout,DAQmx_Val_GroupByScanNumber,data,bufferSize*2,&pointsRead,NULL));
totalRead += pointsRead;
printf("Acquired %d samples. Total %d\n",pointsRead,totalRead);
// Just print out the first 10 points of the last data read
for (i = 0; i < 10; ++i)
printf ("data0[%d] = %f\tdata1[%d] = %f\n",i,data[2*i],i,data[2*i+1]);
}


How do these functions allow me to continuously analyse the datastream, without dropping segments?

Any hint on additional information is most welcome,
thanks,
M. Lankheet
utrecht University
0 Kudos
Message 1 of 1
(2,952 Views)