0% found this document useful (0 votes)
59 views15 pages

Micro Lab 2 (AM)

This document summarizes a microcontroller lab experiment involving three tasks: 1) Using a delay subroutine to light LEDs on a bar graph one by one, 2) Displaying numbers 0-9 on a 7-segment display using port 2, and 3) Displaying letters A-F on a 7-segment display. Code was written, compiled, burned onto an 8051 microcontroller IC, and simulated in Proteus to test the hardware processes. The lab helped students learn about 8051 registers, delay subroutines, and interfacing with LED and 7-segment displays.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views15 pages

Micro Lab 2 (AM)

This document summarizes a microcontroller lab experiment involving three tasks: 1) Using a delay subroutine to light LEDs on a bar graph one by one, 2) Displaying numbers 0-9 on a 7-segment display using port 2, and 3) Displaying letters A-F on a 7-segment display. Code was written, compiled, burned onto an 8051 microcontroller IC, and simulated in Proteus to test the hardware processes. The lab helped students learn about 8051 registers, delay subroutines, and interfacing with LED and 7-segment displays.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Microprocessor & Microcontroller

Lab No#2(After Mids)11

P2
Name:
Abdul Nouman, Moeen Riaz ,Zain Ali
ID No:
170914 , 170911, 170899
Class/Sec:
BEEP(B)

Submitted To: Engr.Qaism Hussain

Instructor’s Remarks:

Marks: Total Marks Obtained Marks

Instructor’s Signature: _____________

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)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy