LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Raw Encoder Pulses

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....
0 Kudos
Message 1 of 5
(2,502 Views)
As you have probably noticed, you don't have an attachment. If your vi calls sub-vi's or controls save it as a "Save with options", "Development distribution". If you previewyour post after making the attachment it will loose the attachment.
 
P.M.
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 5
(2,496 Views)
Here is the attachment (hopefully)...
0 Kudos
Message 3 of 5
(2,496 Views)
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.
CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 4 of 5
(2,473 Views)

 

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.

 

0 Kudos
Message 5 of 5
(2,453 Views)