Reading an Absolute Encoder with National Instruments Motion

http://zone.ni.com/devzone/cda/epd/p/id/1920
Page 1 of 1
Improve your ni.com experience. Login or Create a user profile.
Document Type: Example Program
NI Supported: Yes
Publish Date: Nov 10, 2008
Reading an Absolute Encoder with National Instruments
Motion Control
Downloads
Filename: read-absolute-encoder_7.1.zip
Requirements: View
This example shows you how to read various types of absolute encoders. It uses the subVI gray2bin for converting gray
encoded data to binary encoded data. You can use this example with the following absolute encoder types:
binary absolute encoders
gray absolute encoders
12-bit binary absolute encoders
12-bit gray absolute encoders
For information about connecting to NI 73xx motion controllers, see the Related Links section for a document about
encoders and NI products.
In this VI, the data from a 16-bit encoder is read from ports 1 and 2. The data from the encoder can be of various types.
The data connected to port 1 represents the lower byte of the word and port 2 the upper byte. The VIs that read the
digital ports return the data as a cluster of Booleans. The data is first converted to an array of Booleans, and then to a
number. These numbers are formatted as unsigned 8-bit and then concatenated to form a single 16-bit or 32-bit number
depending on what type of encoder is used. This implies that we are using the 0 position of the encoder as a midpoint
between two limits of travel. We could also use the 0 position as one extreme and the 65,535 position as the other limit.
Since the position registers are 32-bit signed numbers, we now have to format the 16-bit number to 32 bits. The example
implements this functionality by first checking to see if the 16-bit number is negative. If not, it is passed straight into the
position registers with 0's in all the bits above 16 bits. If it is negative, then all the bits above 16 are set to 1's before
being passed to the position registers.
For an encoder that produces gray code, the procedure is very similar. The process is almost the same as for the natural
binary encoder except there is the addition of a VI which simply takes the 16 bit gray code and converts it to 32-bit
binary. In this case, the binary value is placed into the position registers directly.
Related Links:
Absolute Encoders and NI Products
Requirements
Filename: read-absolute-encoder_7.1.zip
Software Requirements
Application Software: LabVIEW Base Development System 7.1
Language(s): LabVIEW
Hardware Requirements
Hardware Group: Motion Control
Hardware Model: PCI-7330, PCI-7340, PXI-7350, PXI-7330, PXI-7340, PCI-7350
Driver: NI-Motion 7.0
Reader Comments | Submit a comment »
Legal
This example program (this "program") was developed by a National Instruments ("NI") Applications Engineer. Although
technical support of this program may be made available by National Instruments, this program may not be completely
tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this program with
each new revision of related products and drivers. THIS EXAMPLE PROGRAM IS PROVIDED "AS IS" WITHOUT
WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN
NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
My Profile | RSS | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.
http://zone.ni.com/devzone/cda/epd/p/id/1920
|
E-Mail this Page
1/27/2011