From: Grizzly_Bear_69 on
LabVIEW newbie question...
 
I have a linear quadrature encoder (5um resoulution with X4 decoding) connected to a PCI-6251 DAQ board.  The encoder A line is connected to  PFI 8 and the B line is connected to PFI 10. 
 
Using LabVIEW 7.1, I would like to count the number of raw pulses from a zero point using X4 decoding.  I have tried the Express VI and a couple of example VIs but I have not been able to have anything work quite right.  The attached Encoder Pulses VI is a simplified portion of the code.  When Ticks are selected, I get the correct number of pulses for the given distance but the data item "rolls over" instead of counting in the negitive direction.  When meters is selected, I get a +/- measurement but unless I set the distance per pulse to 4 I don't get all the expected pulses. 
 
What should I be using / doing to get the desired data format?
 
Thanks....
From: Kevin Price on
Here's a slight modification to the vi you posted.  The essential trick for getting +/- counts when using "Ticks" as units is to convert the u32 (unsigned integer) to an i32 (signed integer).  When you decrement across 0, the actual count register stores the maximum unsigned 32-bit integer -- all bits set to 1.  When this same bit pattern is converted to an i32, it is interpreted as -1.  Further decrementing will continue -2, -3, -4... 
 
Note: This approach would still produce a discontinuity, but it would happen as you crossed the 2**31 ticks position rather than the 0 position.  Fortunately, with a linear encoder you're unlikely to ever get there...
 
-Kevin P.


Encoder Pulses v2.vi:
http://forums.ni.com/attachments/ni/170/130741/1/Encoder Pulses v2.vi
From: Grizzly_Bear_69 on
 
Many thanks...I knew about the unsigned integer but I did not know how to get around it.
Since I am only dealing with about 11,000 ticks, I don't anticipate overflowing a 32 bit register.