Micro Lab 2 (AM)
Micro Lab 2 (AM)
P2
Name:
Abdul Nouman, Moeen Riaz ,Zain Ali
ID No:
170914 , 170911, 170899
Class/Sec:
BEEP(B)
Instructor’s Remarks:
PROCEDURE:
In this lab, we have understand the use of delay subroutine. In this
delay:
mov R0,#200
loop1:
mov R1,#200
loop2:
djnz R1,loop2
djnz R0,loop1
In this first line will run only one time and the one iteration of outer loop is equal to 200 times of
inner loop. And in it djnz means decrement if not equal to zero.this delay subroutine is used to waste
some machines cycles that our naked eye is easily visible and also in this delay subroutine we have used
the 8 general purpose registers of micro controller 8051 that are R0 ,R1,R2,R3,R4,R5,R6,R7.After this
delay subroutine we have end the program.
TASK(1)
Explanation:
In this code , we have using the port no 02 of micro controller and take two randomly addresses either
hexa or binary then this port 02 is connected to the bar graph in the proteus software then LEDs in the bar
graph glowing one after another and vice versa but this process is too much fast as our naked aye is not
visible. For visible to naked eye we use the delay subroutine
CODE:
org 00h
main:
mov P2,#55h
call delay
call delay
call delay
call delay
call delay
call delay
call delay
mov P2,#0AAh
call delay
call delay
call delay
call delay
call delay
call delay
call delay
jmp main
delay:
mov R0,#200
loop1:
mov R1,#200
loop2:
djnz R1,loop2
djnz R0,loop1
ret
end
Result:
TASK#2:
Explanation:
Now we have to check micro controller will behave as a sink not as a source in seven segment display
with battery voltage of 5V. In this code , we have using the port no 02 of micro controller and take
addresses in hexadecimal then this port 02 is connected to the seven segment and connected with 5V
battery in the proteus software and using the delay subroutine to see numbers display from 0 to 7 that is
easily visible to our naked eye.
num h g f e d c b a Hexadecimal
0 0 1 0 0 0 0 0 0 40h
1 0 1 0 0 1 1 1 1 4Fh
2 0 0 1 0 0 1 0 0 24h
3 0 0 1 1 0 0 0 0 30h
4 0 0 0 1 1 0 0 1 19h
5 0 0 0 1 0 0 1 0 12h
6 0 0 0 0 0 0 1 0 02h
7 0 1 1 1 1 0 0 0 78h
8 0 0 0 0 0 0 0 0 00h
9 0 0 0 1 1 0 0 0 18h
CODE:
org 00h
main:
mov P2,#40h
call delay
call delay
call delay
mov P2,#4Fh
call delay
call delay
call delay
mov P2,#24h
call delay
call delay
call delay
mov P2,#30h
call delay
call delay
call delay
mov P2,#19h
call delay
call delay
call delay
mov P2,#12h
call delay
call delay
call delay
mov P2,#02h
call delay
call delay
call delay
mov P2,#78h
call delay
call delay
call delay
mov P2,#00h
call delay
call delay
call delay
jmp main
delay:
mov R0,#200
loop1:
mov R1,#200
loop2:
djnz R1,loop2
djnz R0,loop1
ret
end
Result:
TASK#3
Explanation:
Now we have to check micro controller will behave as a sink not as a source in seven segment display
from A to F with battery voltage of 5V. In this code , we have using the port no 02 of micro controller and
take addresses in hexadecimal then this port 02 is connected to the seven segment and connected with 5V
battery in the proteus software and using the delay subroutine to see numbers display from A to F that is
easily visible to our naked eye.
Alphabet h g f e d c b a Hexadecimal
s
A 0 0 0 0 1 0 0 0 08H
B 0 0 0 0 0 0 0 0 00H
C 0 1 0 0 0 1 1 0 46H
D 0 1 0 0 0 0 0 0 40H
E 0 0 0 0 0 1 1 0 06H
F 0 0 0 0 1 1 1 0 0EH
Code:
org 00
main:
mov P2,#40h
call delay
call delay
call delay
call delay
call delay
call delay
mov P2,#4Fh
call delay
call delay
call delay
call delay
call delay
mov P2,#24h
call delay
call delay
call delay
call delay
call delay
mov P2,#30h
call delay
call delay
call delay
call delay
call delay
mov P2,#19h
call delay
call delay
call delay
call delay
call delay
mov P2,#12h
call delay
call delay
call delay
call delay
call delay
mov P2,#02h
call delay
call delay
call delay
call delay
mov P2,#78h
call delay
call delay
call delay
call delay
mov P2,#00h
call delay
call delay
call delay
call delay
call delay
mov P2,#18h
call delay
call delay
call delay
call delay
call delay
mov P2,#08h
call delay
call delay
call delay
call delay
call delay
mov P2,#00h
call delay
call delay
call delay
call delay
call delay
mov P2,#46h
call delay
call delay
call delay
call delay
call delay
mov P2,#40h
call delay
call delay
call delay
call delay
call delay
mov P2,#06h
call delay
call delay
call delay
call delay
call delay
mov P2,#0Eh
call delay
call delay
call delay
call delay
call delay
jmp main
delay:
mov R0,#200
loop1:
mov R1,#200
loop2:
djnz R1,loop2
djnz R0,loop1
ret
end
Result:
CONCLUSION:
In this lab we are able to learn about the 8 general purpose registers of 8051 microcontroller
How to use the delay subroutine in the program and how it works
How to burnt the code generated in the microcontroller 8051 IC and then proteus simulation of
LEDs glowing one after another using LED bar graph proved in the hardware process(using burnt
code IC)