MUCLecture 2022 37407
MUCLecture 2022 37407
Experiment No.2
Binary to Gray Code Conversion and Vice Versa
1. Introduction
1.1 Objective:
To study of binary to gray and gray to binary code conversion.
1.2 Components:
ST2611 Digital Circuit Development Platform trainer with power supply cord
DB06 – Code Conversion
Set of wires
1.3 Theory:
From the previous experiments, we studied that the binary code of data is represented
by two values such as 0’s and 1’s, and it is mainly used in the world of the computer.
Gray Code is a form of binary that uses a different method of incrementing from one
number to the next. With Gray Code, only one-bit changes state from one position to
another. This feature allows a system designer to perform some error checking. Gray
Code is the most popular Absolute encoder output type because its use prevents certain
data errors which can occur with Natural Binary during state changes.
Code converter is a circuit that makes two systems compatible even though each
uses different binary code. Code converters are used for protecting private information
from spies. Moreover, they are used to enhance data portability and tractability.
We will discuss in this experiment how to convert from binary to gray code and vice
versa, in order to understand how the encoder and decoder are working.
The following example will be very useful for knowing the conversion of binary to
gray code. In this conversion method, take down the MSB bit of the present binary
number, as the primary bit or MSB bit of the gray code number is similar to the binary
number.
The DB06 Code Conversion Panel shown in Figure 1 is a compact, ready to use logic
board that will be used in this experiment. It is useful for students to study and
understand the code conversion techniques binary to gray and gray to binary and
verify them.
the trainer to B0, B1, B2, and B3 pins of the binary to gray code circuit on the left
of the panel respectively.
5. Connect the pin no. G0, G1, G2, and G3 of binary to gray code circuit on the
left side of the panel to the output pin no. 0, 1, 2, and 3 of the 8-bit LED Display on
the right side of the trainer respectively, in order to display the gray code from the
binary inputs.
6. Make sure all your connections are right then turn on the power supply.
7. Turn D3 switch to position 1 and keep D0, D1 and D2 switches at position 0
Al-Mustaqbal University College 4/5 http://www.mustaqbal-college.edu.iq/
then observe the output on 8-bit LED display (green light indicates 0 and red light
indicates 1).
8. Observe the output for different input combination as shown in truth table of
the trainer to G0, G1, G2, and G3 pins of the gray to binary code circuit on the
right of the panel respectively.
3. Connect the pin no. B0, B1, B2, and B3 of gray to binary code circuit on the right
side of the panel to the output pin no. 0, 1, 2, and 3 of the 8-bit LED Display on the
right side of the trainer respectively, in order to display the binary number from the
gray inputs.
4. Make sure all your connections are right then turn on the power supply.
5. Turn D3 switch to position 1 and keep D0, D1 and D2 switches at position 0
then observe the output on 8-bit LED display (green light indicates 0 and red light
indicates 1).
6. Observe the output for different input combination as shown in truth table of gray
3. Discussion:
1. Convert the gray code 01011001 to decimal number and show your work.
2. Convert the gray code 00101101 to binary number and show your work.
3. Design a 8-bit binary to gray code conversion circuit using logic gates and verify
your design.
4. Design a 8-bit gray to binary code conversion circuit using logic gates and verify
your design.