Rotary encoder: why Gray, not binary — Gray code
exam standardthe failure Gray code prevents
Answer
4
Why this example is worth doing
The engineering reason the code exists. On a binary-coded shaft encoder, the step from 7 to 8 changes every bit at once, and if the sensors do not switch at precisely the same instant the reading passes through a spurious intermediate value — possibly 15, at the opposite end of the range. With Gray code only one track changes, so the worst case is reading the old value or the new one. The page cites Gray's 1953 patent.
Try your own input in the Gray code. Convert binary to reflected Gray code and back, and build the sequence by reflection.
How the answer is reached
Differing positions
a0111
b1000
4 of 4 positions differ, so the Hamming distance is 4.