The full Gray Code table works well if you require the full binary range of bits offered by the encoder such as 4 bits (2^4 = resolution of 16 ppr), 8 bits (2^8 = resolution of 256 ppr), or 10 bits (2^10 = resolution of 1024 ppr). But if you require another resolution that is not a power of 2 (such as 360 or 1000 ppr) you must then remove some counts. Equal counts are removed from the beginning and end of the Gray Code table which then leaves the middle section. The counts that are removed are referred to as excess Gray codes.
A Gray code encoder with a resolution of 10 ppr would be based on a 4 bit absolute encoder (16 ppr) with 3 counts removed from each end (6 counts total) of the Gray code table. This is done from each end so when the encoder completes one revolution and cycles back around to 1 then still only one bit will change from 10 to 1, maintaining the "only 1 bit changes per increment" purpose of the Gray code.
In order to use the extracted middle section in your PLC code you will have to subtract the lower segment of excess Gray codes from the value in the table. So the second position in the 10ppr encoder would be 0110 (4) so you would have to subtract 3 in order to get the true position of 1 from the encoder.
Gray Code | Decimal Value | Excess Gray Code | ||||||
2^3 | 2^2 | 2^1 | 2^0 | 2^3 | 2^2 | 2^1 | 2^0 | |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 1 |
0 | 0 | 1 | 1 | 2 | 0 | 0 | 1 | 1 |
0 | 0 | 1 | 0 | 3 | 0 | 0 | 1 | 0 |
0 | 1 | 1 | 0 | 4 | 0 | 1 | 1 | 0 |
0 | 1 | 1 | 1 | 5 | 0 | 1 | 1 | 1 |
0 | 1 | 0 | 1 | 6 | 0 | 1 | 0 | 1 |
0 | 1 | 0 | 0 | 7 | 0 | 1 | 0 | 0 |
1 | 1 | 0 | 0 | 8 | 1 | 1 | 0 | 0 |
1 | 1 | 0 | 1 | 9 | 1 | 1 | 0 | 1 |
1 | 1 | 1 | 1 | 10 | 1 | 1 | 1 | 1 |
1 | 1 | 1 | 0 | 11 | 1 | 1 | 1 | 0 |
1 | 0 | 1 | 0 | 12 | 1 | 0 | 1 | 0 |
1 | 0 | 1 | 1 | 13 | 1 | 0 | 1 | 1 |
1 | 0 | 0 | 1 | 14 | 1 | 0 | 0 | 1 |
1 | 0 | 0 | 0 | 15 | 1 | 0 | 0 | 0 |
Other common resolution examples:
RESOLUTION:180 EXCESS GRAY CODES: 38 RESOLUTION: 360 EXCESS GRAY CODES: 76 RESOLUTION: 720 EXCESS GRAY CODES: 152