Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

JOMO KENYATTA UNIVERSITY

OF AGRICULTURE AND TECHNOLOGY


Academic Year 2023/2024

FOURTH YEAR 1ST SEMESTER LABWORK FOR THE DEGREE OF


BACHELOR OF SCIENCE IN ELECTRONICS AND COMPUTER ENGINEERING

EEE 2406: MICROPROCESSOR I

BINARY-GRAY CONVERTER ASSEMBLY PROGRAM

DATE: 6TH AUGUST 2023

MEMBERS:

1. KELVIN NGATIA ENE212-0064/2019


2. LENNY KIBE ENE212-0066/2019
3. BRIAN LEMAYIAN ENE212-0076/2019
4. DAVID KINYANJUI ENE212-0080/2019
TASK:

Generate a gray code shaft encoder assembler program such that a user is given a choice of ‘Binary to
Gray or Gray to Binary’. The user is then made to key-in the input bits to the program. The program
outputs to a port of an Intel 8255 programmable Peripheral Interface (PPI) the corresponding gray or
binary value.

Student should then simulate the system using Proteus environment with peripherals; LEDs and Liquid
Crystal Display (LCD).

DESCRIPTION:

Conversion of Gray to Binary;

Let Gray Code be g3, g2, g1, g0. Then the respective Binary Code can be obtained as follows:

Figure1; Gray to Binary Conversion

The process uses the XOR operation. The XOR logic table is as below;

A B Y
1 1 0
1 0 1
0 1 1
0 0 0
Table1; XOR logic table
Conversion of Binary to Gray;

Let Binary code be b3, b2, b1, b0. Then the respective Gray Code can be obtained is as follows

Figure2; Binary to Gray Conversion

In our solution, the program accepts 8 bits of either binary or grey code to entered using the keypad by
the user, the 8 bits are then converted and the equivalent stored and displayed on the LCD.

Gray to Binary Assembly Module


Binary to Grey Assembly Module
CIRCUIT INTERFACE IN PROTEUS.

The circuit diagram is as shown below


Figure3; Circuit Interface in Proteus.
FLOWCHART:

a) Gray Code to Binary Code Module.


b) Binary Code to Grey Code Module.

Start
Start
Counter = 0
Counter = 0

Input
bit
Input bit

No No No No No No No
Counter Counter Counter Counter Counter Counter Counter Counter
= 0? No = 1? No = 2? No No = 4? No = 5? No = 6? No = 7?
Counter Counter Counter = 3?
Counter Counter Counter Counter Counter
= 0? = 1? = 2? = 3? = 4? = 5? = 6? = 7?
Yes Yes Yes Yes Yes Yes Yes Yes
Yes Yes Yes Yes Yes Yes Yes Yes
Bit1= Bit0 Bit2 = Bit1 Bit3 = Bit2 Bit4 = Bit3 Bit5 = Bit4 Bit6 = Bit5 Bit7 = Bit6
Bit0 =bit XORBit0
bit XOR bit XOR bit XOR bit XOR bit XOR bit XOR bit
Bit1= Bit2 = Bit1 Bit3 = Bit2 Bit4 = Bit3 Bit5 = Bit4 Bit6 = Bit5 Bit7 = Bit6
Bit0 =bit XOR sbit XOR sbit XOR sbit XOR sbit XOR sbit XOR sbit XOR sbit
Start
Start
Inc Counter
Inc Counter
sbit =bit
No Counter
= 8?
No Counter
= 8?
Yes
Yes
Stop
Stop
c) Overall Program flow

Start

Input
1.Gray-Binary
2. Binary-Grey

Input Input
No No
= 1? = 2?

Yes Yes

Convert
Convert gray
Binary to
to binary
Grey

Start

Output Result

Yes
Again?

No

Stop
SAMPLE OUTPUT WINDOWS.

REFERENCES.

1. A.P Godse and D.A Godse, “Microprocessor and interfacing”, First Edition:2009
2. Lecture Notes
3. Emu8086 Documentation

You might also like