0% found this document useful (0 votes)
15 views5 pages

MUCLecture 2022 37407

Uploaded by

ajay Kamble
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views5 pages

MUCLecture 2022 37407

Uploaded by

ajay Kamble
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Electronics Laboratory

Lecturer: Ali jawad Kadhim Al-Rubaie


E-mail: [email protected]
TA: Eng. Esraa Hussein Al-fatlawi

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.

Binary to Gray Code Conversion

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.

Al-Mustaqbal University College 1/5 http://www.mustaqbal-college.edu.iq/


To get the straight gray coded bits for generating the corresponding gray coded digit
for the given binary digits, look at the primary digit or the MSB digit of binary number
and the second digit then note down 0 if they are similar to each other and 1 if they are
different next to the primary bit of gray code. Do the same thing with the next binary
bit and third bit then note down the product next to the 2nd bit of gray code. Similarly,
follow this procedure until the final binary bit as well as note down the outcomes to
generate the corresponding gray coded binary digit. The truth table of binary to gray
code conversion can be seen at Table (1).

Table 1: Truth Table of Binary to Gray Code Conversion

Binary Code Gray Code


B3 B2 B1 B0 G3 G2 G1 G0
0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 1
0 0 1 0 0 0 1 1
0 0 1 1 0 0 1 0
0 1 0 0 0 1 1 0
0 1 0 1 0 1 1 1
0 1 1 0 0 1 0 1
0 1 1 1 0 1 0 0
1 0 0 0 1 1 0 0
1 0 0 1 1 1 0 1
1 0 1 0 1 1 1 1
1 0 1 1 1 1 1 0
1 1 0 0 1 0 1 0
1 1 0 1 1 0 1 1
1 1 1 0 1 0 0 1
1 1 1 1 1 0 0 0

Gray to Binary Code Conversion


This gray to binary conversion method also uses the working concept of binary to gray
code conversion. The following example with step by step procedure may help to know
the conversion concept of gray code to binary code.
To change gray to binary code, take down the MSB digit of the gray code number, as
the primary digit or the MSB of the binary code is similar to the gray digit. To get the
next straight binary bit, look at the primary digit or the MSB digit of gray code and the
Al-Mustaqbal University College 2/5 http://www.mustaqbal-college.edu.iq/
second digit then note down 0 if they are similar to each other and 1 if they are
different next to the primary bit of binary number. Do the same thing with the next
gray bit and third bit then note down the product next to the 2nd bit of binary code.
Similarly, follow this procedure until the final gray bit as well as note down the
outcomes to generate the corresponding binary number. The truth table of gray to
binary code conversion can be seen at Table (2).

Table 2: Truth Table of Gray to Binary Code Conversion


Gray Code Binary Code
G3 G2 G1 G0 B3 B2 B1 B0
0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 1
0 0 1 0 0 0 1 1
0 0 1 1 0 0 1 0
0 1 0 0 0 1 1 1
0 1 0 1 0 1 1 0
0 1 1 0 0 1 0 0
0 1 1 1 0 1 0 1
1 0 0 0 1 1 1 1
1 0 0 1 1 1 1 0
1 0 1 0 1 1 0 0
1 0 1 1 1 1 0 1
1 1 0 0 1 0 0 0
1 1 0 1 1 0 0 1
1 1 1 0 1 0 1 1
1 1 1 1 1 0 1 0

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.

Al-Mustaqbal University College 3/5 http://www.mustaqbal-college.edu.iq/


Figure 1: DB06 Code Conversion Panel

1.4 Exercise 1: Binary to Gray Code Conversion:


1. Place the DB06 panel shown in Figure 1 on the trainer.
2. To provide power to the board, connect +5 V pin from the trainer on the left side

to +5V pin on the DB06 using a wire.


3. Connect GND pin from the trainer on the left side to ground symbol pin on the
DB06.
4. Connect the input switches which are pins no. D0, D1, D2 and D3 on the bottom of

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

binary to gray code conversion on Table (1).


9. Verify Truth Table on Table (1).

1.5 Exercise 2: Gray to Binary Code Conversion:


1. Turn off the power supply and keep no. 1 through 3 of exercise 1 connections the

same and take of the others.


2. Connect the input switches which are pins no. D0, D1, D2 and D3 on the bottom 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

to binary code conversion on Table (2).


7. Verify Truth Table on Table (2).

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.

Al-Mustaqbal University College 5/5 http://www.mustaqbal-college.edu.iq/

You might also like