01-18-2012 10:35 AM
Hello,
I'm facing a problem.
With Ni USB 6343 I want to acquire synchronously some Ai chanels and two quadrature encoders
here under the flow of my program :
Create analog input task
Create counter task 1 for left position
Create counter task 2 for right position
Setup analog task (Sample rate, input voltage, …)
Setup counter task 1 & 2 with analog sampling clock as master clock
DAQmxRegisterEveryNSamplesEvent on analog input task
Start counter task 1 & 2
Start analog task as master task to synchronize the three task.
in callback :
DAQmxReadAnalogF64 to read analog samples,
DAQmxReadCounterU32 to read counter 1
DAQmxReadCounterU32 to read counter 2
Here is the issue :
On first (and sometime second) calling of the callback I get the right number of samples from analog task but 0 or 1 samples from counter tasks.
Any idea about this issue ?
Thanks by advance for your support.
B.Williot
01-19-2012 01:46 AM - edited 01-19-2012 01:51 AM
I am adding a stripped down version of my code.
Here under a screen capture of output window.
You can see that the first call to EventAcquireCallback, there is no data from counters.
B.Williot.
01-19-2012 02:34 AM
I've found a modification that works.
I changed
err = DAQmxReadCounterU32(g_TaskHandleCpt1,DAQmx_Val_Auto,60,ctr0Data,50,&nbCtr0,NULL);
by
err = DAQmxReadCounterU32(g_TaskHandleCpt1, nSamples,60,ctr0Data,50,&nbCtr0,NULL);
nSamples is the parameters from
int32 CVICALLBACKEventAcquireCallback(TaskHandle taskHandle,int32 everyNsamplesEventType,uInt32 nSamples,void*callbackDatas)
But I don't know why DAQmx_Val_Auto is not working !
Any idea ?
B.Williot.