Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Example Program
NI Supported: Yes
Publish Date: Sep 6, 2006


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links - Products and Services

Reading an Absolute Encoder with National Instruments Motion Control

15 ratings | 3.47 out of 5
Print

Downloads

Filename: read_absolute_encoder.zip
Requirements: View

This example shows you how to read various types of absolute encoders. It uses the subVI grey2bin for converting grey to binary. It works with binary absolute encoders, grey absolute encoders, 12-bit binary absolute encoders, and 12-bit grey absolute encoders.
For information on connecting to 7344 controllers, click on the link in the Related Links section to see 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 returns the data in the format of a cluster of booleans. The data is first converted to an array of booleans, and then to a number. These numbers are formatted to unsigned 8 bit and then concatenated to form a single 16-bit or 32-bit number depending on what type of encoder is being used. This implies that we are using the encoders 0 position as a midpoint between two limits of travel. We could also use the 0 position as one extreme and the 65535 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. In this example, this is done by first checking to see if the 16-bit number is negative. If not, it is simply 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 put into the position registers.
For an encoder that produces gray code, the procedure is very similar. It is done in almost the same way as 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 straight binary value is placed into the position registers directly.


Related Links:
Absolute Encoders and NI Products

Requirements


Filename: read_absolute_encoder.zip

Software Requirements


Application Software: LabVIEW Full Development System 5.1
Language(s): LabVIEW

Hardware Requirements


Hardware Group: Motion Control
Driver: NI-Motion 4.5

 
15 ratings | 3.47 out of 5
Print

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/).