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

8051-LED Blink and Suqare Wave Generation

The document outlines a laboratory experiment for S.Y.B.Sc. Electronics students at Sir Parshurambhau College, focusing on LED blinking and square wave generation using the 8051 microcontroller. It includes objectives, procedures, algorithms, and flowcharts for both tasks, emphasizing the use of I/O ports and delay generation. The experiment aims to enhance students' understanding of microcontroller programming and circuit connections.

Uploaded by

prashantsheetal
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)
20 views5 pages

8051-LED Blink and Suqare Wave Generation

The document outlines a laboratory experiment for S.Y.B.Sc. Electronics students at Sir Parshurambhau College, focusing on LED blinking and square wave generation using the 8051 microcontroller. It includes objectives, procedures, algorithms, and flowcharts for both tasks, emphasizing the use of I/O ports and delay generation. The experiment aims to enhance students' understanding of microcontroller programming and circuit connections.

Uploaded by

prashantsheetal
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/ 5

Sir Parshurambhau College, Pune-30

S.Y.B.Sc. Electronics
LED Blink and Square Wave Generation
Aim: To blink the LED and to generate the square wave using 8051 micro-controller.
Objectives: 1. Study the use of I/O ports.
2. Learn the generation of delay using registers.
3. Generate the square wave of desired duty cycle and observe it on CRO.
4. Compile, Execute and simulate the program.
5. Learn to use programmer for microcontroller.
Block Diagram: Part-A: LED Blink

R
D1
39
P0.0
330 LED

8051 D2
38
R
P0.1 +5 V
330E LED

Procedure:
1) Connect circuit as shown above.
2) Write program in assembly language to blink the LED using delay subroutine.
3) Change the delay by changing values in registers and observe its effect on blinking rate of LED.
4) Burn this program in 89C51 IC using programmer.
5) Make appropriate connections on 8051 development board and observe the output.
Algorithm:
1) Begin program at address 0h
2) in program memory.
3) Set output at pin P0.0 of the micro-controller to 1.
4) Call delay routine of appropriate time in millisecond for ON time.
5) Clear the output of micro-controller’s pin P0.0 to 0.
6) Again, call the same delay routine in milliseconds for OFF time.
7) Repeat steps 1-5 above to loop forever.
8) Repeat the steps 1-6 for pin P0.1.
OR
1) Start at desired address in program memory.
2) Complement any one of the pins of microcontroller.
3) Call delay routine of appropriate time in milliseconds.
4) Repeat steps 1-3 continuously.
Flowchart: a) Main Program Subroutine

Start Start

Set bit P0.0=1 Initialize counter (R2)

Call delay subroutine Initialize register R3

Clear bit P0.0=0 Initialize register R4

Call delay subroutine Decrement R4 by one


R4=R4-1
Repeat again

Is NO
Main Program R4=0
b) ??
Start YES

Decrement R3 by one.
R3=R3-1
Complement port bit
P0.0

Is NO
R3=0?
?
Call delay
YES
Decrement R2 by one.
R2=R2-1

Repeat again

Is NO
R2=0?
?

YES

RET
Part B: Square Wave Generation
When any pin is made low or high with some delay, square wave is generated. For 50 % duty cycle
ON-OFF time is same/equal.
Block Diagram:

Square wave with


39
50 % duty cycle
P0.0

8051
38
P0.1

Procedure:
1) Write program in assembly language to generate square wave at P0.0 of 8051 using delay
subroutine.
2) Change the delay by changing values in registers R2, R3 and observe its effect on duty cycle and
frequency of square wave.
3) Compile and burn the hex file of program in 8051 IC using programmer.
4) Make appropriate connections on 8051 development board and observe the square wave generated
at P0.0 of 8051 on CRO.
Program: a) Square wave generation for 50 % duty cycle
ORG 0000h
start:CPL P0.0 ;complement oin P0.0 or any other pin
ACALL delay ;call delay subroutine
SJMP start ; loop forever
delay:MOV R2, #20h ;R2=20h
pqr:MOV R3, #80h ;R3=80h
xyz:DJNZ R3, xyz ;keep decrementing R3 untill it becomes zero
DJNZ r2, pqr ;decrement R2 by one and repeat delay routine till R2=0
RET ;return control to main program back
b) Square wave generation for duty cycle other than 50%
To change the duty cycle of square wave delay for ON time and OFF time should be separate.
ORG 0000h
start:SETB P0.1
ACALL del1
CLR P0.1
ACALL del2
SJMP start
del1:MOV R2, #80h ; delay routine for ON time
pqr:ACALL delay
DJNZ R2, pqr
RET
del2:MOV R2, #20h ; delay routine for OFF time
lmn:ACALL delay
DJNZ R2, lmn
RET
delay:MOV R3, #50h ; general delay routine
xyz:DJNZ R3, xyz
RET
Algorithm: a) For Square wave generation of 50 % duty cycle.
1. Start at desired address in program memory.
2. Complement any one of the pins of microcontroller (P0.1).
3. Call delay routine of appropriate time in milliseconds.
4. Repeat steps 1-3 continuously.

Flowchart: Main Program Delay Subroutine

Start Start

Initialize register R2
Complement port bit
P0.0
Initialize register R3

Decrement R3 by one.
Call delay R3=R3-1

NO
Repeat again Is R3= 0?

YES

Decrement R2 by one.
R2=R2-1

Is NO
R2=0?
?
YES

RET

b) Algorithm: For square wave generation with duty cycle other than 50%.

1. Begin program at some address in program memory.


2. Make one of the micro-controller pins’ (P0.1) output 1.
3. Call delay routine 1 of appropriate time in millisecond for ON time.
4. Clear the output of micro-controller’s pin (P0.1) to 0.
5. Again, call the delay routine 2 in milliseconds for OFF time.
6. Repeat steps 1-5 above to loop forever.
Flowchart: Main Program Delay Subroutine 1
Start
Start

Initialize register R2
Set bit P0.0=1

Call delay
Call delay subroutine 1

Decrement R2 by one.
Clear bit P0.0=0 R2=R2-1

Call delay subroutine 2

NO Is
Repeat again
R2=0?

Delay Subroutine 2

Start YES

RET
Initialize register R2

Delay Subroutine
Call delay Start

Decrement R2 by one.
R2=R2-1 Initialize register R3

Decrement R3 by one.
NO Is R3=R3-1
R2=0?
?

YES
Is NO
RET R3=0?

YES

Result: RET

Conclusion:

You might also like