05-27-2010 04:10 AM
This is possibly quite a general question about the relation between calling a function to get data and the physical time that the data is read.
I have two different tasks using a USB-6211 DAQ, the first is a frequency counter and my second is an analogue input.
The frequency counter is set up (using Matlab and library calls) as:
%% Create the task
taskptr=libpointer('voidPtrPtr');
[a,b,task1]=calllib('myni','DAQmxCreateTask', 'count1', taskptr);
ParseErrorWarning(a,ErrorsAndWarnings)
%% Create counter channel for frequency measurement
[a, b, physicalChannel, d]=calllib('myni','DAQmxCreateCIFreqChan',...
task1,...
Device,...
'counterChan',...
90,...
20000000,...
constants.DAQmx_Val_Hz,...
constants.DAQmx_Val_Rising,...
constants.DAQmx_Val_HighFreq2Ctr, ...
SampPeriod,...
1000,...
''); %Note the min divisor is 4
ParseErrorWarning(a,ErrorsAndWarnings)
% Create the counter variables - these will be used in the read operation.
count=uint32(0);
countPtr=libpointer('uint32Ptr',count);
nullPtr=libpointer;
%% Start the task
[a, startTaskReturnedPtr]=calllib('myni','DAQmxStartTask', task1);
ParseErrorWarning(a,ErrorsAndWarnings)
As can be seen this is set to run and then when the measurement is to be made (it is in a scanning microscopy system) I make the call:
[a, countPtrret, count, d]=calllib('myni',...
'DAQmxReadCounterScalarU32', taskptr,10, countPtr, []);
So, in this instance, does the calling of ReadCounter start a measurement and give me the frequency measured over calltime + delta T, or does is the frequency being continually measured in which case it might return the frequency at calltime - delta T which might be in the wrong place on my scanning stage?
My other task is set up using:
%% Create the task
taskptr=libpointer('voidPtrPtr');
[a,b,task1]=calllib('myni','DAQmxCreateTask', '', taskptr);
ParseErrorWarning(a,ErrorsAndWarnings)
%% Create analogue input channel for voltage measurement
[a, b, physicalChannel, d]=calllib('myni','DAQmxCreateAIVoltageChan',...
task1,...
Device,...
'VChannel',...
constants.DAQmx_Val_RSE,...
0,...
5,...
constants.DAQmx_Val_Volts,...
[]);
ParseErrorWarning(a,ErrorsAndWarnings)
%% Set sample clock parameters
[a, b,d]=calllib('myni','DAQmxCfgSampClkTiming',...
task1,...
[],...
SamplingRate,...
constants.DAQmx_Val_Rising,...
constants.DAQmx_Val_FiniteSamps,...
nSample);
ParseErrorWarning(a,ErrorsAndWarnings)
In this instance I am starting and stopping the task with each measurement as I believe that the finite number of samples begin being taken at the time I call startTask and in fact the read call has no connection at all with the timing of when the samples are taken, is this correct?
Hopefully some of this has made sense, and if anybody can clear up my confusion about when the data is actually being taken it would really help in syncronising my acuisitions.
Thanks
Ali