05-14-2012 11:55 AM
Hi, i'm working with a NI 6602 board. Actually we have 3 optical encoder connected to ctr0 (pfi38), crt1(PFI34) and ctr2(PFI30). I need to have synchronous acquisition of frequency. I'm using NI-DAQMX with C . Our goal is to display frequency variation between the 3 entry.
I think using edge count can be a better way to have synched samples but actually i can't change wiring and cannot connect my source signal to pfi39, pfi35 and pfi31. I've tried to use DAQmxSetCICountEdgesTerm(taskHandle,"Dev2/ctr0","Dev2/PFI38") , i have the error -89120 (signal can't be routed). When i set DAQmxSetCICountEdgesTerm(taskHandle,"Dev2/ctr0source","Dev2/PFI38") no error but always count 0.
My signal frequency is betwenn 0 and 16000hz.
My code is below
DAQmxErrChk (DAQmxCreateCOPulseChanTime(taskHandleOut,
"Dev2/ctr4", // gating pulse generated
"channel 1",
DAQmx_Val_Seconds, // units
DAQmx_Val_Low, // resting state
0.0, // initial delay
0.5, // pulse train freq 0.,
0.5)); // pulse shape
DAQmxErrChk (DAQmxCfgImplicitTiming( taskHandleOut,
DAQmx_Val_ContSamps,
0));
DAQmxErrChk (DAQmxCreateCICountEdgesChan( taskHandle,
"Dev2/ctr0",
"channel 0",
DAQmx_Val_Rising,
0, // initial count
DAQmx_Val_CountUp)); // count direction
DAQmxErrChk (DAQmxCfgSampClkTiming( taskHandle,
"/Dev2/Ctr4InternalOutput", // sample clock set to pulse gen
20000000.0, // max expected rate of sample clock
DAQmx_Val_Rising,
DAQmx_Val_ContSamps,
10000000)); // buffer size
DAQmxSetCICountEdgesTerm(taskHandle,"Dev2/ctr0source","Dev2/PFI38");
Regards
05-21-2012 10:34 AM
Hi yipilipi,
To make edge count, you need to put your signal on the counter sources pin. If not you will not get counts!
Regards,
Rémi D.
National Instruments France