Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Polling counter value from a buffered counter

Hi

 

Is it possible to poll the value of a counter that has a sample clock configured?

 

I am still interested in getting the counter value both at the time of the sample clock (normal buffered counter task), but would also like to be able to poll the value at any other time!

 

Currently this is solved (and working) by sending the same input to two independant counters - one setup with a sample clock and one setup without a sample clock. But that requires strict control of starting both tasks at the same time to avoid an offset between them (implemented using a third counter to generate a trigger signal).

 

I am using the C api and setting up the counter using DAQmxCreateCILinEncoderChan, and for the buffered counter DAQmxCfgSampClkTiming is also called to define the sample clock source and parameters.

 

A PCI-6601 card is used.

0 Kudos
Message 1 of 3
(133 Views)

I don't think you can poll for instantaneous values in between the times the count is buffered by the sample clock.  I think your 2-counter solution is the best workaround.   Be aware that counter *input* tasks can't use the regular start trigger.  Instead you need to configure a special "Arm Start" trigger.

 

You can get away with generating the triggering signal with DO so as not to tie up a 3rd counter.  IIRC, digital port0/line0 corresponds to PFI0 on that device, and similarly for line1 / PFI1.   So you can configure the counter's to be arm-start-triggered by PFI0, then generate a signal there by writing to port0/line0.

 

I would typically start the DO first and write a False.  Then I'd start the counter tasks, which will be stuck waiting for an Arm Start Trigger edge at PFI0.  Then I'd toggle DO True and immediately back to False before stopping the DO task.  That pulse will get the counter tasks started at the same instant.

 

 

-Kevin P

0 Kudos
Message 2 of 3
(102 Views)
Highlighted

Hi Kevin

 

Thanks for the reply.

Yes I am using Arm Start trigger (using a counter).

I actually have two spare unused counters and I am more limited on DO so using a counter is ok.

 

I guess I will keep it as is Smiley Happy

 

- Simon

0 Kudos
Message 3 of 3
(74 Views)