Gray code — error free decoding, 8 bit gray code table, Figure 2 – Electro Cam PS-4456 Absolute Gray Code Encoder User Manual
Page 4

Gray Code — Error Free Decoding
The Gray Code chart below
(Figure 2) shows the bit pat-
terns that are used to represent all 256 encoder positions.
It can be seen on this chart that from any position to any
adjacent position, only 1 bit changes state. This ensures
that the encoder inputs can be read by the control at any
point in time (even during a transition) without error.
Consider the following comparison to Binary Code:
When Gray Code advances from increment 127 to 128,
only 1 of the 8 bits changes state — bit 8. When Binary
Code advances from increment 127 to 128, all 8 bits
change states. Sampling the Binary bits during this transi-
tion could result in a very large decoding error. Sampling
the Gray Code bits during this transition would yield either
127 or 128, depending only on bit 8.
8 Bit Gray Code Table
Figure 2
INC
DEG
GRAY CODE
BINARY
127
178.6
01000000
01111111
128
180.0
11000000
10000000
4
Refer to the table below to understand the relationship
between the
increment (integer), degrees and binary
numbers. Use this table as a guide for setup and trouble-
shooting your Gray Code system.
■
INC
(increment) column represents the integer value
to which the Gray Code is equal. The increments
are 0 to 255 (256 total) that repeat or cycle. (At 255,
the next number change is 0, increment to 255, then
repeat the cycle over again).
■
DEG
(degree) column represents the actual degree
position that the Gray Code is indicating.
■
Gray Code
column shows the Gray Code value
for that particular position. This Gray Code binary
number is the same as the Gray Code inputs status,
1 = ON and 0 = OFF.
Because the Gray Code value is also a graphic repre-
sentation of the input status, it is an invaluable tool in
checking the position or troubleshooting.
INC
DEG
GRAYCODE
0
0.0
00000000
1
1.4
00000001
2
2.8
00000011
3
4.2
00000010
4
5.6
00000110
5
7.0
00000111
6
8.4
00000101
7
9.8
00000100
8
11.3
00001100
9
12.7
00001101
10
14.1
00001111
11
15.5
00001110
12
16.9
00001010
13
18.3
00001011
14
19.7
00001001
15
21.1
00001000
16
22.5
00011000
17
23.9
00011001
18
25.3
00011011
19
26.7
00011010
20
28.1
00011110
21
29.5
00011111
22
30.9
00011101
23
32.3
00011100
24
33.8
00010100
25
35.2
00010101
26
36.6
00010111
27
38.0
00010110
28
39.4
00010010
29
40.8
00010011
30
42.2
00010001
31
43.6
00010000
32
45.0
00110000
33
46.4
00110001
34
47.8
00110011
35
49.2
00110010
36
50.6
00110110
37
52.0
00110111
38
53.4
00110101
39
54.8
00110100
40
56.3
00111100
41
57.7
00111101
42
59.1
00111111
43
60.5
00111110
44
61.9
00111010
INC
DEG
GRAYCODE
45
63.3
00111011
46
64.7
00111001
47
66.1
00111000
48
67.5
00101000
49
68.9
00101001
50
70.3
00101011
51
71.7
00101010
52
73.1
00101110
53
74.5
00101111
54
75.9
00101101
55
77.3
00101100
56
78.8
00100100
57
80.2
00100101
58
81.6
00100111
59
83.0
00100110
60
84.4
00100010
61
85.8
00100011
62
87.2
00100001
63
88 6
00100000
64
90.0
01100000
65
91.4
01100001
66
92.8
01100011
67
94.2
01100010
68
95.6
01100110
69
97.0
01100111
70
98.4
01100101
71
99.8
01100100
72
101.3
01101100
73
102.7
01101101
74
104.1
01101111
75
105.5
01101110
76
106.9
01101010
77
108.3
01101011
78
109.7
01101001
79
111.1
01101000
80
112.5
01111000
81
113.9
01111001
82
115.3
01111011
83
116.7
01111010
84
118.1
01111110
85
119.5
01111111
86
120.9
01111101
87
122.3
01111100
88
123.8
01110100
89
125.2
01110101
INC
DEG
GRAYCODE
90
126.6
01110111
91
128.0
01110110
92
129.4
01110010
93
130.8
01110011
94
132.2
01110001
95
133.6
01110000
96
135.0
01010000
97
136.4
01010001
98
137.8
01010011
99
139.2
01010010
100
140.6
01010110
101
142.0
01010111
102
143.4
01010101
103
144.8
01010100
104
146.3
01011100
105
147.7
01011101
106
149.1
01011111
107
150.5
01011110
108
151.9
01011010
109
153.3
01011011
110
154.7
01011001
111
156.1
01011000
112
157.5
01001000
113
158.9
01001001
114
160.3
01001011
115
161.7
01001010
116
163.1
01001110
117
164.5
01001111
118
165.9
01001101
119
167.3
01001100
120
168.8
01000100
121
170.2
01000101
122
171.6
01000111
123
173.0
01000110
124
174.4
01000010
125
175.8
01000011
126
177.2
01000001
127
178.6
01000000
128
180.0
11000000
129
181.4
11000001
130
182.8
11000011
131
184.2
11000010
132
185.6
11000110
133
187.0
11000111
134
188.4
11000101
INC
DEG
GRAYCODE
135
189.8
11000100
136
191.3
11001100
137
192.7
11001101
138
194.1
11001111
139
195.5
11001110
140
196.9
11001010
141
198.3
11001011
142
199.7
11001001
143
201.1
11001000
144
202.5
11011000
145
203.9
11011001
146
205.3
11011011
147
206.7
11011010
148
208.1
11011110
149
209.5
11011111
150
210.9
11011101
151
212.3
11011100
152
213.8
11010100
153
215.2
11010101
154
216.6
11010111
155
218.0
11010110
156
219.4
11010010
157
220.8
11010011
158
222.2
11010001
159
223.6
11010000
160
225.0
11110000
161
226.4
11110001
162
227.8
11110011
163
229.2
11110010
164
230.6
11110110
165
232.0
11110111
166
233.4
11110101
167
234.8
11110100
168
236.3
11111100
169
237.7
11111101
170
239.1
11111111
171
240.5
11111110
172
241.9
11111010
173
243.3
11111011
174
244.7
11111001
175
246.1
11111000
176
247.5
11101000
177
248.9
11101001
178
250.3
11101011
179
251.7
11101010
INC
DEG
GRAYCODE
180
253.1
11101110
181
254.5
11101111
182
255.9
11101101
183
257.3
11101100
184
258.8
11100100
185
260.2
11100101
186
261.6
11100111
187
263.0
11100110
188
264.4
11100010
189
265.8
11100011
190
267.2
11100001
191
268.6
11100000
192
270.0
10100000
193
271.4
10100001
194
272.8
10100011
195
274.2
10100010
196
275.6
10100110
197
277.0
10100111
198
278.4
10100101
199
279.8
10100100
200
281.3
10101100
201
282.7
10101101
202
284.1
10101111
203
285.5
10101110
204
286.9
10101010
205
288.3
10101011
206
289.7
10101001
207
291.1
10101000
208
292.5
10111000
209
293.9
10111001
210
295.3
10111011
211
296.7
10111010
212
298.1
10111110
213
299.5
10111111
214
300.9
10111101
215
302.3
10111100
216
303.8
10110100
217
305.2
10110101
218
306.6
10110111
219
308.0
10110110
220
309.4
10110010
221
310.8
10110011
222
312.2
10110001
223
313.6
10110000
224
315.0
10010000
INC
DEG
GRAYCODE
225
316.4
10010001
226
317.8
10010011
227
319.2
10010010
228
320.6
10010110
229
322.0
10010111
230
323.4
10010101
231
324.8
10010100
232
326.3
10011100
233
327.7
10011101
234
329.1
10011111
235
330.5
10011110
236
331.9
10011010
237
333.3
10011011
238
334.7
10011001
239
336.1
10011000
240
337.5
10001000
241
338.9
10001001
242
340.3
10001011
243
341.7
10001010
244
343.1
10001110
245
344.5
10001111
246
345.9
10001101
247
347.3
10001100
248
348.8
10000100
249
350.2
10000101
250
351.6
10000111
251
353.0
10000110
252
354.4
10000010
253
355.8
10000011
254
357.2
10000001
255
358.6
10000000