|
Binary and Gray Code
The output data of many physical systems are quantities that are
continuous. These data must be converted into digital form before they
are applied to a digital system. Continuous or analog information is
converted into digital form by means of an analog-to-digital converter.
It is sometimes convenient to use the Gray code shown in Table 1 to
represent digital data that have been converted from analog data. The
advantage of the Gray code over the straight binary number sequence is
that only we bit in the code group changes in going from one number to
the next. For example, in going from 7 to 8, the Gray code changes from
0100 to 1100. My the first bit changes, from 0 to 1: the other three
bits remain the same. By contrast, with binary numbers the change from 7
to 8 will be from 0111 to 1000, which causes all four bits to change
values.
Table 1.
|
Decimal |
Gray Code |
|
0 |
0000 |
|
1 |
0001 |
|
2 |
0011 |
|
3 |
0010 |
|
4 |
0110 |
|
5 |
0111 |
|
6 |
0101 |
|
7 |
0100 |
|
8 |
1100 |
|
… |
… |
|
… |
… |
Figure 1 and 2 below are the idea for conversion of binary to gray code
and the opposite by using EX-OR gate.

Figure 1. Binary to Gray Code Conversion.

Figure 2. Gray Code to Binary.
Source:
Digital Design, M.Morris Mano
|