Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Using internal clock with counter task?

Hello all,
a really noob question. I need to among other things count the output from a quadrature encoder with a normal CI task. Such as:

    DAQmxErrChk (DAQmxCreateTask("CI",&taskHandleCI));
    DAQmxErrChk (DAQmxCreateCICountEdgesChan(taskHandleCI,"Dev1/ctr0","",DAQmx_Val_Rising,0,DAQmx_Val_ExtControlled));

However, docs says I need a sample clock to make the counting, and that is must be an external clock. This text is from the examples:

"Note: An external sample clock must be used. Counters do not
have an internal sample clock available. You can use the
Gen Dig Pulse Train-Continuous example to generate a pulse
train on another counter and connect it to the Sample         
Clock Source you are using in this example.
"

Is it really possible that I need an external input to the card? is it not possible to just use some on-board internal clock? (i am a total DAQ noob). I really dont want to connect anything more to my device.

Another unrelated question; if I read for instance a buffered AI input with

    DAQmxErrChk (DAQmxReadAnalogF64(taskHandleAI,-1,1.0,DAQmx_Val_GroupByChannel,data,4000,&read,NULL));
   
, can I be sure that the buffer is cleared after the read so I don't get some samples twice the next time I read?

Thanks a lot!

/ Roland



0 Kudos
Message 1 of 3
(3,768 Views)
To clarify: I would like to do a buffered count measurement without using an external clock. Actually, I only need to have one sample per count tick, so it would be ultimate to use the pulse train itself as a trigger. Is this possible? I tried this without any success (I got an error message saying that there was regsitered trigger lines):

    DAQmxErrChk (DAQmxCreateTask("CI",&taskHandleCI));
 
    DAQmxErrChk (DAQmxCreateCICountEdgesChan(taskHandleCI,"Dev2/ctr0","",DAQmx_Val_Rising,0,DAQmx_Val_CountUp));
 
    DAQmxCfgChangeDetectionTiming (taskHandleCI, "Dev2/ctr0", NULL, DAQmx_Val_ContSamps, 1000);


0 Kudos
Message 2 of 3
(3,742 Views)
Problem solved, I finally figured out how to use the ai/Sampleclock for this task as explained by Kevin in another thread
0 Kudos
Message 3 of 3
(3,734 Views)