# GRAY CODE WHAT IS IT, AND WHERE IS IT USED

## GRAY CODE WHAT IS IT, AND WHERE IS IT USED

GRAY CODE WHAT IS IT, AND WHERE IS IT USED

BY: Don McClatchie

Gray Code is employed in many electronic devices that use rotary switches for position encoders. The Gray Code also called “reflected binary code” or (RBC) was named after Bell Labs researcher Frank Gray who took out a patent application for it before it had a formal name. This code was built up by using binary code altered by a reflection process. This process has also been referred to as “minimum error code” and “cyclic permutation code” and “Bell Telephone Gray Code”.

This code was designed to eliminate the possible errors caused by none ideal mechanical switches. Mechanical switches that output binary results suffer from one main problem, errors caused by multiply contacts not being in synchronicity so that the switches don’t make and brake at precisely the same time so it is possible to get wrong readings from them when switching from one number to the next. Take the number 3 to 4 transition in binary switching as a prime example, in binary the switch contacts would go from “011” binary to “100” binary that is a change of all three switch contacts with different make and break times, a data system could read any one of 8 different combinations of numbers at the time of switch transition.

Take a close look at the nature of the Gray Code next to Binary, Decimal, Hexadecimal, Octal, and Binary Coded Decimal coding. Notice that going from one number to the next only requires a one bit change.

Gray Code  Binary        Decimal      Hexadecimal         Octal           Binary Coded Decimal

0000           0000                  0                 0                           0                 0

0001           0001                  1                 1                           1                 1

0011           0010                  2                 2                           2                 2

0010           0011                  3                 3                           3                 3

0110           0100                  4                 4                           4                 4

0111           0101                  5                 5                           5                 5

0101           0110                  6                 6                           6                 6

0100           0111                  7                 7                           7                 7

1100           1000                  8                 8                           10               8

1101           1001                  9                 9                           11               9

1111           1010                10                A                          12               —-

1110           1011                 11                B                          13               —-

1010           1100                 12                C                          14               —-

1011           1101                 13                D                          15               —-

1001           1110                 14                E                          16               —-

1000           1111                 15                F                           17               —-

This coding has also been used in code groups to reduce errors in data transmission.