Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Count up and down with two input clock

Hello!

 

Is it possible to configure a counter on a PCI-6251 card in a way to receive two digital trains (input clocks) and the counter should count up for one, down for the other?

If so could someone plz show me an example how to set it using traditional DAQmx driver (simple C code)?

 

Thx very much!

0 Kudos
Message 1 of 6
(6,470 Views)

I'm no help on the C syntax, but yes you can definitely do that.  The concept is to create a "Two Pulse Encoder" task.  By default, the count will increment for edges coming into the counter's Source input and will decrement for edges coming into the Aux/UpDn input.  It's possible to make config calls that will specify alternate pins to look at for those input signals.

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 2 of 6
(6,462 Views)

I'd be careful about saying "traditional DAQmx driver".  I'm assuming you just meant the standard DAQmx Driver so this should be fine.  Traditional DAQ is actually a separate driver meant for older hardware (it will NOT work with M Series DAQ Devices).

 

Kevin is dead-on about using the Two Pulse Encoder task.  You will need to use DAQmxCreateCILinEncoderChan:

set decodingType to DAQmx_Val_TwoPulseCounting

 

set units to DAQmx_Val_Ticks

 

The general structure of the program will be similar to many of the other counter examples, let us know if you get stuck with any specific portion.

 


Best Regards,

 

John
Message Edited by John P on 05-14-2010 12:17 PM
John Passiak
0 Kudos
Message 3 of 6
(6,452 Views)

Thanks for usefull advices!

 

 learning every day something new is very exciting Smiley Very Happy

Certified-LabVIEW-Developer_rgb.jpg

0 Kudos
Message 4 of 6
(6,424 Views)
Thanks for the help both of you! I forgot to say that I need to create a counter output task with a delay. This counter should receive the two clock signals and count up and down. When it reaches the predefined value than it should make the output. I havent gone into details yet, but I guess it also can be done.
0 Kudos
Message 5 of 6
(6,404 Views)

Hi TarPista,

 

The way to implement this would be to set an initial count (the initialPos input parameter to the Create Channel function) to 2^32 - N, where N is the number of ticks that you want to count to before making the output.  The counter generates an internal output when a rollover occurs (at 2^32 for 32-bit counters).  To export this signal to a PFI line, you can call DAQmxExportSignal.

 

 

Best Regards,

John Passiak
0 Kudos
Message 6 of 6
(6,394 Views)