Topic: DMD0024 GRAY - Gray Code to Integer |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The Gray Code to Integer (GRAY) instruction converts a 16 bit Gray code value to an integer value. This instruction is designed for use with devices that use the Gray code numbering scheme. Gray codes are often used in absolute encoders, linear encoders, and rotary encoders in preference to straightforward binary encoding. This avoids the possibility that, when several bits change in the binary representation of an angle, a misread could result from some of the bits changing before others. Rotary encoders especially benefit from the cyclic nature of Gray codes, because the first and last values of the sequence differ by only one bit.
720 PPR, 360 PPR and 180 PPR encoders are designed to return a value referenced to degrees. These encoders don't naturally start counting at zero, so a MATH instruction is needed to remove the offset. The Gray Code to Integer instruction does not need to remove an offset for 512 PPR and for 1024 PPR encoders.
For a device having a resolution of 180 counts per revolution you must subtract 38 from the converted value to obtain the correct result (180-Excess-38 Gray Code).
For a device having a resolution of 360 counts per revolution you must subtract 76 from the converted value to obtain the correct result (360-Excess-76 Gray Code).
For a device having a resolution of 720 counts per revolution you must subtract 152 from the converted value to obtain the correct result (720-Excess-152 Gray Code).
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Parameters:Note: Use the F9 key or click the 'three dot box' at the right edge of the parameter field to open the Default Element Selection Tool (the Element Picker or the Element Browser) or use the Down-Arrow key (Auto-Complete) on any parameter field to see a complete list of the memory locations that are valid for that parameter of the instruction.
Input Value is the numeric memory location that contains the Gray code value. This can be any constant value or any readable numeric location.
Output Value is a numeric memory location to store the converted value. This can be any writable numeric location.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
See Also:
GRAY - Gray Code to Integer
SEG - Hex / BCD to 7 Segment Display
STR2INT - Convert String to Integer
STR2REAL - Convert String to Real
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Rung Example:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|