Gray Code for Rotary Incremental Encoders
June 17, 2014
Gray code was named for Frank Gray, a Bell labs researcher, who patented the procession in 1953, even though a form of it was used by Emile Baudot for telegraphy as early as 1878.
The most important thing to understand about Gray code is that only one bit changes from transition to transition. In binary it is possible for a number to go from all ones to all zeros, as is the case with 11111111 (255 decimal) going back around to 00000000 (zero).
Dec Bin Gray 0 0000 0000 1 0001 0001 2 0010 0011 3 0011 0010 4 0100 0110 5 0101 0111 6 0110 0101 7 0111 0100 8 1000 1100 9 1001 1101 10 1010 1111 11 1011 1110 12 1100 1010 13 1101 1011 14 1110 1001 15 1111 1000Notice how only one of the 0’s or 1’s of the Gray code change as the number increments? In binary there are times when all of the bits change, (0111 to 1000 (Seven to Eight ) and 1111 back to 0000 (Fifteen to Zero) ).
Error Checking
The advantage to only one bit changing in Gray code is that it gives you error-checking ability. If you sum the number of bits, the bit total will always change by only one.
You could also do some error checking knowing that the bit sum will always alternate between even and odd.
Gray Bit Sum 0000 0 0001 1 0011 2 0010 1 0110 2 0111 3 0101 2 0100 1Gray Code in Incremental Encoders
The A & B channels of incremental encoders are in quadrature, which makes a two-bit gray code progression. Depending on direction, the incremental encoder bit progression with be a cyclical pattern of either 00 – 01 -11 – 10 or 00 – 10 – 11 – 01 – 00.
Only one bit changes from transition to transition.
The QD787 absolute encoder shown at the top of this post has an option for an eight bit Gray code output. Update: encoder model QD787 has been discontinued. Quantum Devices does not offer an absolute encoder at this time.
Links to More Information on Gray Code:
https://encyclopedia2.thefreedictionary.com/Grey+code
https://mathworld.wolfram.com/GrayCode.html
WIKI:
https://en.wikipedia.org/wiki/Gray_code#Constructing_an_n-bit_gray_code
For more information on encoders, Contact Quantum Devices today!