Professional Documents
Culture Documents
ELECTRIAL DEPARTMENT
Name of student:..
Enrollment no.:.
INDEX
Sr.
Description Page No. Date Sign
No.
1 8 Bit Addition and Subtraction
2 Multi-Byte Addition
9 Frequency Measurement
START
Stop
START
NO Check: C=1
?
Yes
Stop
Aim:
To write and execute an assembly language program to add the given two 8 bit
numbers.
Objectives:
To multiply any two 8 bit numbers using immediate addressing and to store the result
Apparatus Required:
No Name Quantity
1 8051 microcontroller kit & Simulator 1
Algorithm:
INPUT: OUTPUT:
Memor
Data Memory Address Data
y
addres
-- Data1= 30H
s
-- Data2=
INPUT: OUTPUT:
Memory
Data Memory Address Data
address
40H 42H Data
41H 43H Carry
INPUT: OUTPUT:
Memory
Data Memory Address Data
address
-- Data1= 30H
-- Data2=
Result:
Thus an assembly language program 8 bit addition and subtraction were written
and executed successfully.
START
Add Acc. Reg and Higher order byte of Data2 with carry
NO Check: C=1
?
Yes
Stop
Aim:
To write and execute an assembly language program to add two 16 bit numbers.
Objectives:
Get two 16 bit data from the starting locations of 40h and 42h and then add those data and
store in the location of 50H onwards.
Apparatus Required:
No Name Quantity
1 8051 microcontroller kit & Simulator 1
Algorithm:
4. Move the lower order byte result data from A reg to 50h Memory location.
6. Add A reg. and Second higher order byte with carry flag.
7. Move the higher order byte result data from A reg to 51H Memory location.
INPUT: OUTPUT:
Memory
Data Memory Address Data
address
40H 50H Lower order byte=
41H 51H Higher order byte=
42H 52H Carry=
43H
RESULT:
Thus an assembly language program is written to add Multi Byte numbers and executed
successfully.
START
Stop
Aim:
To write and execute an assembly language program to multiply the given two 8 Bit
Numbers.
Objectives:
To multiply the give two 8 Bit numbers using MUL command
Apparatus Required:
No Name Quantity
1 8051 microcontroller kit & Simulator 1
Algorithm:
4. Store the lower byte result from A register to 8300 memory location
5. Store the higher byte result from B register to 8301 memory location
INPUT: OUTPUT:
Memory
Data Memory Address Data
address
8250H 8300H Lower order byte=
8251H 8300H Higher order byte=
Result:
Thus an assembly language is written to multiply two 8 bit numbers and executed
successfully.
START
Yes
Check C=1?
No
No
Check R0 = 0?
Stop
Aim:
To write and execute an assembly language program to add the given array of
8 bit numbers.
Apparatus Required:
No Name Quantity
1 8051 microcontroller kit & Simulator 1
Algorithm:
1. Get first element to R1 register
2. Get the next element in accumulator.
3. Subtract the R1 register from the accumulator.
4. Check the carry flag.
5. If carry is not there, then A register is greater that means 2nd data is larger than
st
1 Data. So exchange the A and B register.
6. If carry is there, then B register is greater that means 1st data is larger than 2nd
Data. So do not exchange the A and B register.
7. Check the R0 register. If R0 is not equal to zero, repeat from the 2nd step else
Move the R1 register to 8300 memory location.
Input: Output:
Memory
Data
address Memory
8251 Data1= Data
address
8300 Largest Number=
8252 Data2=
8253 Data3=
8254 Data4=
8255 Data5=
Result:
Thus an assembly language program is written to find largest number from an array and
executed successfully.
START
Increment R0
NO
Check C=1?
Yes
No
Check R7 =0?
Yes
No
Check R6=0?
Yes
Stop
Aim:
To write and execute the program to sort an array of number using the Bubble Sort
algorithm in ascending order.
Apparatus Required:
No Name Quantity
1 8051 microcontroller kit & Simulator 1
Algorithm:
1. Load the R6 register with (length of the array 1)
2. Load the R7 register with (length of the array Iteration no.)
3. Load the R0 register with array starting address
4. Load R1 register with first data and accumulator with second data
5. Subtract the R1 register from the accumulator.
6. Check the carry flag.
7. If carry is not there, then A register is greater that means 2nd data is larger than 1st
Data. So do not exchange the A and R1 register.
8. If carry is there, then R1 register is greater that means 1st data is larger than 2nd
Data. So exchange the First address location data and second address location data.
9. Decrement and Check the R7 register. If R7 is not equal to zero, repeat from the 4th
step for second and third data processing. Else Decrement R6.
10. Check the R6 register. If R6 is not equal to zero, repeat from the 4th step for
second iteration.
MOV A, @R0
MOV R1, A
INC R0
MOV A, @R0
SUBB A, R1 ;Subtract the first from the second.
JNC Continue2 ;If no carry is generated the second is
:greater and the numbers are in order with
;respect to each other. Otherwise swap
SwapNumbers:
MOV A, @R0
XCH A, R1
MOV @R0, A
DEC R0
MOV A, R1
MOV @R0, A
INC R0
Continue2:
DJNZ R7, LOOP2
Continue1: DJNZ R6, LOOP1
Here: SJMP Here
END
INPUT OUTPUT
Memory address Data Memory address Data
50H 50H
51H 51H
52H 52H
53H 53H
54H 54H
Result:
Thus an assembly language program was written to arrange 8 bit array of data in
ascending order and it was executed successfully.
START
Stop
Aim:
Write an assembly language program to convert 8 bit two digit BCD number system
into Hexadecimal number system.
Apparatus Required:
No Name Quantity
1 8051 microcontroller kit & Simulator 1
Algorithm:
INPUT:
OUTPUT:
Result:
Thus the assembly language program was written to verify the Boolean equation and it was
executed.
START
Stop
Aim:
Apparatus Required:
No Name Quantity
1 8051 microcontroller kit & Simulator 1
Algorithm:
1. Start the program.
2. Move the data from memory location 8300 to Accumulator.(A = FFh)
3. Divide the accumulator with 64h( FF/64 ( A= 2 and B = 37h )
4. Move the accumulator to 8301h ( 8301 = 02)
5. Move the B reg to accumulator (A = 37h)
6. Divide the accumulator with 0Ah (37/0A ( A=05 and B = 05 )
7. Swap the Accumulator.(A = 50)
8. Add the accumulator with B register.(A = 50+5)
9. Move the accumulator to 8302h(8302 = 55)
10. Stop the program.
INPUT:
OUTPUT:
Result
Thus the assembly language program was written to convert the hexadecimal value
into its equivalent BCD value and it was executed successfully.
START
Divide the Acc. Reg by 64h and Add the A Reg with 30h
Divide the Acc. Reg by 0Ah and Add the A Reg with 30h
Stop
Aim:
Apparatus Required:
No Name Quantity
1 8051 microcontroller kit & Simulator 1
Algorithm:
1. Start the program.
2. Move the data from memory location 8300 to Accumulator.(A = FFh)
3. Divide the accumulator with 64h( FF/64 ( A= 2 and B = 37h )
4. Add the accumulator with 30h
5. Move the accumulator to 8301h ( 8301 = 32)
6. Move the B reg to accumulator (A = 37h)
7. Divide the accumulator with 0Ah (37/0A ( A=05 and B = 05 )
8. Add the accumulator with 30h
9. Move the accumulator to 8302h(8302 = 35)
10. Move B reg to Accumulator.
11. Add the accumulator with 30h
12. Move the accumulator to 8303h(8303 = 35)
13. Stop the program.
INPUT:
OUTPUT:
Result
Thus the assembly language program was written to convert the hexadecimal value
into its equivalent ASCII value and it was executed successfully.
Circuit Diagram:
Frequency Measurement
Aim:
Apparatus Required:
No Name Quantity
1 8051 microcontroller kit & Simulator 1
2 Frequency source 1
Algorithm:
1. Set the Timer 0 in mode 1 as a counter.
2. Initialize TH0/TH1timer with zero values.
3. Start timer.
4. Wait for 1 second.
5. Value in TH0/TH1 shows frequency; store that in P0 and P1.
6. Continue from step 2 for continue measurement of frequency.
Result:
The value of measured frequency=
Circuit Diagram:
SERIAL COMMUNICATION
Aim:
To transfer the data serially between two 8051 microcontroller kit and IBM PC using
serial port (RS232).
Apparatus Required:
No Name Quantity
Theory:
Procedure:
1. Connect the 8051 microcontroller kit and IBM PC using RS232 kit.
2. Enter and run the program in 8051 microcontroller kit to transmit GTU serially.
3. Enter and run the program in 8051 microcontroller kit to receive data from PC terminal
program window.
4. Enter and run the program in 8051 microcontroller kit to receive data from PC terminal
program window and sent it to P2 port of 8051 where relay is connected.
HOME:
MOV A,#'G'
ACALL SEND
MOV A,#'T'
ACALL SEND
MOV A,#'U'
ACALL SEND
AJMP HOME
SEND:
MOV SBUF,A
JNB TI,$
CLR TI
RET
END
Result:
Thus the assembly language was written to transfer the data serially between micro
controller kit and IBM PC using RS232 cable and it was executed.
Circuit Diagram:
INTERFACING OF 4 X 4 KEYBOARD
Aim:
To interface the 4 x 4 matrix keyboard with the 89C51 microcontroller and to verify
the output.
Apparatus Required:
No Name Quantity
1 8051 microcontroller kit 1
2 & Simulator
4x4 matrix keyboard 1
Theory:
In 4*4 keyboard, there are 4 rows and 4 column lines. In the intersection of row and
columns, the keys are wired.
In the board , P2.0-P2.3 are used as row lines and P2.4-P2.7 are used as column
lines.The column lines are read inside the controller through port.
All Column lines are given 0 level and row lines checked for 0 logic. Then All Row
lines are given 0 level and column lines checked for 0 logic. Actual no. of key pressed is (No.
column + 4 * No. row). Then this no. is converted in to seven segment code using look up
table and sent for display.
Procedure:
RET
DB 00111111B
DB 00000110B
DB 01011011B
DB 01001111B
DB 01100110B
DB 01101101B
DB 01111101B
DB 00000111B
DB 01111111B
DB 01101111B
DB 01110111B
DB 01111100B
DB 00111001B
DB 01011110B
DB 01111001B
DB 01110001B
END
Result:
Thus the 4 x 4 matrix keyboard was interfaced with 89C51 microcontroller and its output was
verified.
Circuit Diagram:
Aim:
To interface the LCD display with 89C51 microcontroller and to verify data on LCD
display.
Objectives:
Display Alphabet character in the LCD using micro controller.
Apparatus Required:
No Name Quantity
1 8051 microcontroller kit & Simulator 1
2 LCD display 1
Procedure:
Program:
Memory address Hex code(s) Label Mnemonics - Operend(s) - Comments
RSE EQU P1.0
REWR EQU P1.1
ENA EQU P1.2
ORG 0000H
MOV A, #38H
ACALL CONFIG
ACALL DELAY
MOV A, #0EH
ACALL CONFIG
ACALL DELAY
MOV A, #01H
ACALL CONFIG
ACALL DELAY
MOV A, #06H
ACALL CONFIG
AGAIN:
ACALL DELAY
MOV A, #84H
ACALL CONFIG
ACALL DELAY
MOV A, #'G'
ACALL DISPLAY
ACALL DELAY
MOV A, #'T'
ACALL DISPLAY
ACALL DELAY
MOV A, #'U'
ACALL DISPLAY
ACALL DELAY
AJMP AGAIN
CONFIG:
MOV P0, A
CLR RSE
CLR REWR
SETB ENA
ACALL DELAY
CLR ENA
RET
DISPLAY:
MOV P0, A
SETB RSE
CLR REWR
SETB ENA
ACALL DELAY
CLR ENA
RET
DELAY:
MOV R2, #01H
HERE3: MOV R3, #00H
HERE2: MOV R4, #00H
HERE: DJNZ R4, HERE
DJNZ R3, HERE2
DJNZ R2, HERE3
RET
END
Result:
Thus an assembly language program was written to interface LCD display with 89 C 51
micro controller and to verify data on LCD display and it was executed.
Circuit Diagram:
Aim:
To interface two seven segment LED display in 89C51 microcontroller and to
verify data on LED display.
Objective:
Interface one common cathode type seven segment display with port 1.then write a program
that displays pattern 'E' for 1 second and off for 1 second also, continuously.
Apparatus Required:
No Name Quantity
1 8051 microcontroller kit & Simulator 1
2 Keyboard display interface 1
Procedure:
DELAY:
MOV R1, #08H ; 1 Second delay loop
LOOP3: MOV R2, #0FFH
LOOP2: MOV R3, #0FFH
LOOP1: DJNZ R3, LOOP1
DJNZ R2, LOOP2
DJNZ R1, LOOP3
RET
END
DELAY:
MOV R0,#100D
MOV TMOD,#00000001B
JJ: MOV TH0,#0D8H
MOV TL0,#0F0H
SETB TR0
HH: JNB TF0,HH
CLR TF0
DJNZ R0,JJ
RET
END
Result:
Thus an assembly language program was written to interface two seven segment LED
display with 89 C 51 micro controller and it was executed.
Circuit Diagram:
Aim:
To interface the pushbutton switch and relay and make relay ON - OFF using
pushbutton switch.
Apparatus Required:
No Name Quantity
1 8051 microcontroller kit & Simulator 1
2 Relay interface board 1
Procedure:
Result:
Thus the program for interfacing the relay and push button to 8951 microcontroller was
written and executed successfully.
Aim:
To study about C programming of 8051 Microcontroller.
Apparatus Required:
No Name Quantity
1 8051 Simulator 1
Programs:
#include <reg51.h>
void main(void)
{
unsigned char z;
for (z=0;z<=255;z++)
P1=z;
}
#include <reg51.h>
void main(void)
{
unsigned char num[] = {'0' , '1' , '2','3' , '4' , '5', 'A' , 'B','C' , 'D' };
unsigned char z;
for(z=0;z<10;z++)
P1=num[z] ;
}
#include <reg51.h>
void main(void)
{
for (;;)
{
P1=0x55;
P1=0xAA;
}
#include <reg51.h>
void main(void)
{
char mynum[]={+1,-1,+2,-2,+3,-3,+4,-4};
unsigned char z;
for (z=0;z<=7;z++)
P1=mynum[z];
}
5. Write an 8051 C program to toggle bit D0 of the port P1 (P1.0) 50,000 times.
#include <reg51.h>
sbit MYBIT=P1^0;
void main(void)
{
unsigned int z;
for (z=0;z<=50000;z++)
{
MYBIT=0;
MYBIT=1;
}
}
Result:
Thus the programs using C language was written and executed successfully.
******