05-14-2010 03:13 AM
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!
05-14-2010 09:21 AM
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
05-14-2010 12:07 PM - edited 05-14-2010 12:17 PM
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
05-15-2010 07:41 AM
Thanks for usefull advices!
learning every day something new is very exciting
05-17-2010 02:48 AM
05-17-2010 09:34 AM
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,