Professional Documents
Culture Documents
Jomo Kenyatta University of Agriculture and Technology: Bachelor of Science in Electronics and Computer Engineering
Jomo Kenyatta University of Agriculture and Technology: Bachelor of Science in Electronics and Computer Engineering
MEMBERS:
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:
Let Gray Code be g3, g2, g1, g0. Then the respective Binary Code can be obtained as follows:
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
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.
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