You are on page 1of 63

1

CONTENTS

Ex. NO 01. 02. 03. 04. 05. 06. 07. 08. 09. 10. 11. 12. 13.

NAME OF THE EXPERIMENT SOFTWARE: Introduction to Microcontroller kit Addition , Subtraction Multi byte addition Multiplication of two numbers Finding maximum value in an array Arranging the given data in Ascending order BCD to HEX Conversion HEX to BCD Conversion HEX to ASCII Conversion ASCII to Binary Conversion Square root of an Given data Least Common Multiple Greatest Common Divisor HARDWARE: 5 9 13 15 17 19 23 25 29 31 33 35 37

PAGE NO

01. 02. 03 04. 05. 06.

Matrix Keyboard Seven segment displays. LCD displays. Traffic Light Control Interfacing of stepper motor control. Lift control.

41 45 49 53 57 59

SOFTWARE

Ex. No:1 4

INTRODUCTION TO MICROCONTROLLER KIT AIM: To study about the microcontroller kit APPARATUS REQUIRED:
Sl.No 1. APPARATUS Micro Controller Kit QUANTITY 1 No

THEORY: A Single package microcontroller contains a central processing unit(CPU), semi conductor memory (RAM for data memory and ROM for program memory),a clock generator and input /output port capabilities processed in a single chip. BLOCK DIAGRAM OF MICROCONTROLLER

ALU ACCUMULATOR REGISTER PROGRAM COUNTER STACK POINTER INTERUPT CKT TIMING AND CLOCK CIRCUIT

INTERNAL ROM INTERNAL RAM TIMERS& COUNTERS I/O PORT

FEATURES: 8051 is an 8 bit microcontroller 4096 bytes program memory on chip 128 bytes data memory on chip Single supply +5v operation using HOMS technology 3 bidirectional I/O lines organized as four 8 bits ports.

ARCHITECTURE OF 8051 MICROCONTROLLER 5

P0.0 P0.7
PORT 0 DRIVERS PORT 0 DRIVERS PORT 0 LATCH

P.2.0 P2.7
PORT 2 DRIVERS

RAM ADDR REGISTER

RAM

PORT2 LATCH

FLASH

B REGISTER

ACC

STACK POINTER

PROGAM ADDRES REGISTER

TMP

TMP1

BUFFER

ALU
INTERRUPT,SERIAL PORT&TIMER BLOCKS

PC INCREMENTER

PSW

PROGARM COUNTER

PSEN ALE EA RST

TIMING AND INSTRUCTION CONTROL REGISTER

DPTR

OSC

PORT1 LATCH

PORT3 LATCH

PORT 1 DRIVERS

PORT 3 DRIVERS

P1.0 P1.7

P3.0 P3.7

STRUCTURE OF ASSEMBLY LANGUAGE [LABEL:] MNEMONICS [OPERANDS] [COMMENTS] STEPS: STEP 1: RESET STEP 2: RESET STEP 3: RESET STEP 4: RESET STEP 5: RESET SUBMEMORY GO STARTING ADDRESS NEXT NEXT NEXT NEXT NEXT

STARTING ADDRES

SUBMEMORY GO

INPUT ADDRESS

STARTING ADDRESS

SUBMEMORY

OUTPUT ADDRESS

RESULT: The operation of microcontroller kit is studied

ADDITION PROGRAM 7

MEMORY ADDRESS 5000 5003 5004 5006 5009 500A 500B 500D 500F 5011 5012 5015 5016 5017 5018 5019

MNEMONICS Opcode Operand MOV DPTR,#5101 MOVX MOV MOV MOVX CLR MOV ADD JNC INC STORE: MOV MOVX INC MOV MOVX HALT: SJMP A, @DPTR B,A DPTR,#5100 A, @DPTR C R0,#00 A,B STORE R0 DPTR,#5200 @DPTR, A DPTR A, R0 @DPTR,A HALT

HEX CODE 90,51,01 E0 F5,F0 90,51,00 E0 C3 78,00 25,F0 50,01 08 90,52,00 F0 A3 E8 F0 80,FE

COMMENTS Load the first data into the DPTR points. Move the data in the external RAM to Accumulator. Move the content of Accumulator to B ( Direct) Load the second data into the DPTR points. Move the data in the external RAM to Accumulator. Clear carry Assign register for carry Add 1st data and 2nd data Check for carry Increment the carry register Load DPTR points with 16bit constant Move the lower byte of the result to external RAM. Increment Data Pointer Move the carry to Accumulator Move the higher byte of the result to external RAM. Short jump to the loop HALT.

Ex.No.2A ADDITION AIM: To write a program for addition of two numbers. APPARATUS REQUIRED: SI.no 1. APPARATUS Micro controller kit QUANTITY 1 No

PROCEDURE: 1. Enter the hex code in the RAM Memory starting from the location 5000. 2. The program is executed after entering all the hex code. 3. The inputs are given in the specified memory location. 4. Execute the program. 5. Store the result in the given location. INPUT: 5100: 1st data 5101: 2nd data OUTPUT: 5200: Result 5201: Carry

RESULT: Thus the program for addition is executed and the output is noted.

SUBTRACTION PROGRAM

MEMORY ADDRESS 5000 5003 5004 5006 5009 500A 500C 500F 5010

MNEMONICS Opcode Operand MOV DPTR,#5101 MOVX MOV MOV MOVX SUBB MOV MOVX HALT: SJMP A, @DPTR B,A DPTR,#5100 A, @DPTR A,B DPTR,#5200 @DPTR, A HALT

HEX CODE 90,51,01 E0 F5,F0 90,51,00 E0 95,F0 90,52,00 F0 80,FE

COMMENTS Load the first data into the DPTR points. Move the data in the external RAM to Accumulator. Move the content of Accumulator to B ( Direct) Load the second data into the DPTR points. Move the data in the external RAM to Accumulator. Subtract 2nd data from 1st data Load DPTR points with 16bit constant Move the lower byte of the result to external RAM. Short jump to the loop HALT.

10

Ex.No.2B SUBTRACTION AIM: To write a program for subtraction of two numbers. APPARATUS REQUIRED: SI.no 1. APPARATUS Micro controller kit QUANTITY 1 No

PROCEDURE: 1. Enter the hex code in the RAM Memory starting from the location 5000. 2. The program is executed after entering all the hex code. 3. The inputs are given in the specified memory location. 4. Execute the program. 5. Store the result in the given location. INPUT: 5100: 1st data 5101: 2nd data OUTPUT: 5200: Result

RESULT: Thus the program for subtraction is executed and the output is noted.

11

MULTI BYTE ADDITION MEMORY ADDRESS 5000 5003 5004 5005 5006 5007 5008 5009 500A 500B 500C 500D 500E 500F 5011 5012 5013 5014 5015 5016 5018 5019 501A 501B 501C 501D 501E MNEMONICS Opcode Operand MOV DPTR, #5100 MOVX MOV INC MOVX MOV INC MOVX MOV INC MOVX MOV MOV MOV ADD INC MOVX MOV ADDC JNC INC INC MOVX MOV INC MOVX HALT: SJMP A, @DPTR R0, A DPTR A, @DPTR R1, A DPTR A, @DPTR R2, A DPTR A, @DPTR R3, A A, R0 R4, #00 A, R2 DPTR @DPTR, A A, R1 A, R3 LOOP R4 DPTR @DPTR, A A, R4 DPTR @DPTR, A HALT HEXCODE 90,51,00 E0 F8 A3 E0 F9 A3 E0 FA A3 E0 FB E8 7C,00 2A A3 F0 E9 3B 50,02 0C A3 F0 EC A3 F0 80,FE COMMENTS Load the Data pointer with 16 bit constant Move the LSB of the first Data present in external RAM to A Move the content of A to R0 Increment Data pointer Move the MSB of the first Data present in external RAM to A Move the content of A to R1 Increment Data pointer Move the LSB of the Second Data present in external RAM to A Move the content of A to R2 Increment Data pointer Move the MSB of the Second Data present in external RAM to A Move the content of A to R3 Move the content of R0 to A Clear the register R4 to store carry Add the LSBs of the data Increment Data pointer Store the LSB result in the given location. Move the content of R1 to A Add the content of R3 to A with carry Jump to LOOP if carry flag is not set otherwise increment R4 Increment R4 for carry Increment Data pointer Store the MSB result in the given location. Move the carry bit to A Increment Data pointer Store the Carry in the given location. Short jump to loop HALT

12

Ex.No:3 MULTI BYTE ADDITION AIM: To write a program for Multi byte addition. APPARATUS REQUIRED: SI.no 1. APPARATUS Micro controller kit QUANTITY 1 No

PROCEDURE: 1. Enter the hex code in the RAM Memory starting from the location 5000 2. The program is executed after entering all the hex code. 3. The inputs are given in the specified memory location. 4. Execute the program. 5. Store the result in the given location. INPUT: 5100: LSB1 5101: MSB1 5102: LSB2 5103: MSB2 OUTPUT: 5104: LSB of the result 5105: MSB of the result 5106: Carry

RESULT: Thus the program for Multi byte addition is executed and the output is noted.

13

MULTIPLICATION PROGRAM MEMORY ADDRESS 5000 5003 5004 5005 5007 5008 5009 500C 500D 500E 5010 5011 MNEMONICS Opcode Operand MOV DPTR,#5100 MOVX INC MOV MOVX MUL MOV MOVX INC MOV MOVX HALT: SJMP A, @DPTR DPTR B,A A, @DPTR AB DPTR,#5200 @DPTR, A DPTR A, B @DPTR,A HALT HEX CODE 90,51,00 E0 A3 F5,F0 E0 A4 90,52,00 F0 A3 E5,F0 F0 80,FE COMMENTS Load the first data into the DPTR points. Move the data in the external RAM to Accumulator. Increment Data Pointer Move the content of Accumulator to B ( Direct) Move the second data in the external RAM to Accumulator. Multiply the content of accumulator with B register. Load DPTR points with 16bit constant Move the lower byte of the result to external RAM. Increment Data Pointer Move the content of B register to Accumulator Move the higher byte of the result to external RAM. Short jump to the loop HALT.

14

Ex.No.4 MULTIPLICATION AIM: To write a program for multiplication of two numbers. APPARATUS REQUIRED: SI.no 1. APPARATUS Micro controller kit QUANTITY 1 No

PROCEDURE: 1. Enter the hex code in the RAM Memory starting from the location 5000. 2 .The program is executed after entering all the hex code. 3. The inputs are given in the specified memory location. 4. Execute the program. 5. Store the result in the given location. INPUT: 5100: Multiplicand 5101: Multiplier OUTPUT: 5200: Lower byte of the result 5201: Higher byte of the result

RESULT: Thus the program for multiplication is executed and the output is noted.

15

FINDING MAXIMUM VALUE PROGRAM MEMORY ADDRESS 5000 5001 5004 5005 5006 5009 500A 500B 500E 5010 5013 5015 5016 5018 501A 501C MNEMONICS Opcode Operand CLR C MOV MOVX MOV MOV REPEAT:INC MOVX CJNE STEP2:DJNZ MOV MOV MOVX HLT:SJMP STEP3:JC MOV STEP1:SJMP DPTR,#5100 A,@DPTR R0,A 40H,#00H DPTR A,@DPTR A,40,STEP3 R0,REPEAT DPTR,#5500 A,40H @DPTR,A HLT STEP1 40H,A STEP2 HEXCODE C3 90,51,00 E0 F8 75,40,00 A3 E0 B5,40,0A D8,F9 90,55,00 E5,40 F0 80,FE 40,02 F5,40 80,F0 Clear Carry Load the address in Dptr Move the external ram to Acc Move the Acc to R0 Reg Move 00 to 40H address Increment Data Pointer Content of DPTR is moved to acc Compare the Acc with 40H address Decrement R0 and jump to relative address Load DPTR with 5500 Move the 40H address to Acc Move the result to given location Be in a loop HLT If carry present go to step1 Move the content of acc to 40h address Jump to step2 COMMENTS

16

Ex.No:5 FINDING MAXIMUM VALUE AIM: To write a program for finding the maximum value in an array. APPARATUS REQUIRED: SI.no 1. APPARATUS Micro controller kit QUANTITY 1 No

PROCEDURE: 1. Enter the hex code in the RAM Memory starting from the location 5000. 2. Specify the length of the array in the program. 3. The inputs are given in the specified memory location. 4. Execute the program. 5. Store the result in the given memory location. INPUT: 5100: Count - 1 (Length of array) 5101: OUTPUT: 5200: Maximum value

RESULT: Thus the program for finding the maximum value in an array is executed and the output is noted.

17

ASCENDING ORDER PROGRAM MEMORY ADDRESS 5000 5002 5004 MNEMONICS Opcode Operand MOV R3,#04 MOV MOV REPT1: MOV R4,#04 DPTR,#8382 HEX CODE 7B,04 7C,04 90,83,82 COMMENTS Count-1 Move immediate data to R3 Count-1 Move immediate data to R3 Load the Data pointer with 16 bit constant Move the content of DPL to R5 Register Move the content of DPH to R6 Register Move the content present in external RAM to A Move the accumulator content to B(direct) Increment data pointer Move the content present in external RAM to A Move the content of accumulator to R0 Clear carry flag Subtract the direct byte from A with borrow Jump to CHKNXT loop if carry flag is not set. Push direct byte (DPL) to stack Push direct byte (DPH) to stack Move the content of R5 register to DPL Move the content of R6register to DPH Move the content of R0 to accumulator

5007

R5,DPL

AD,82

5009 500B 500C

MOV MOVX MOV REPT: INC MOVX MOV CLR SUBB JNC EXCH: PUSH PUSH MOV MOV MOV

R6,DPH A,@DPTR B,A

AE,83 E0 F5,F0

500E 500F 5010 5011 5012 5014

DPTR A,@DPTR R0,A C A,B CHKNXT

A3 E0 F8 C3 95,F0 50,13

5016 5018 501A 501C 501E

DPL DPH DPL,R5 DPH,R6 A,R0

C0,82 C0,83 8D,82 8E,83 E8

18

Ex.No:6

ASCENDING ORDER

AIM: To write a program for Sorting of 8 bit datas in ascending order. APPARATUS REQUIRED: SI.no 1. APPARATUS Micro controller kit QUANTITY 1 No

PROCEDURE: 1. Enter the hex code in the RAM Memory starting from the location 5000. 2. Specify the length of the array in the program. 3. The inputs are given in the specified memory location. 4. Execute the program. INPUT: 8382: 8383: 8384: 8385: 8386: OUTPUT: 8382: 8383: 8384: 8385: 8386:

19

501F 5020 5022 5024 5026 5027 5029 502B 502C 502D 502E 502F 5031 5033 5034 5036

MOVX POP POP MOV MOVX MOV CHKNXT: DJNZ DEC MOV MOV INC MOV MOV INC DJNZ HALT:SJMP

@DPTR,A DPH DPL A,B @DPTR,A B,R0 R5,REPT R4 A,R4 R3,A R4 DPL,R5 DPH,R6 DPTR R4,REPT1 HALT

F0 D0,83 D0,82 E5,F0 F0 88,F0 DB,E3 1C EC FB 0C 8D,82 8E,83 A3 DC,D1 80,FE

Move A to external RAM POP the direct byte (DPH) from stack POP the direct byte (DPL) from stack Move the direct byte to accumulator Move A to external RAM Move the content of R0 to B register. Decrement the content of R5 register and jump to loop REPT if not zero Decrement R4 register Move the content of R4 to accumulator Move the content of accumulator to R3 Increment R4 register Move the content of R5 register to DPL Move the content of R6 register to DPH Increment data pointer Decrement the content of R4 register and jump to loop REPT1 if not zero Short jump to loop HALT

20

RESULT: Thus the program for sorting of 8 bit datas in ascending order is executed and the output is noted.

BCD TO HEX CONVERSION 21

MEMORY ADDRESS 5000 5003 5004 5005 5007 5008 5009 500A 500B 500C 500D 500F 5010 5011 5014 5015 5016 5017 5018

MNEMONICS Opcode Operand MOV DPTR,#5200 MOVX MOV ANL RL RL RL RL MOV MOV ANL MOV MOV MOV MUL ADD INC MOVX HALT: SJMP A,@DPTR R5,A A,#F0 A A A A R1, A A, R5 A, #0F R2, A A, R1 FO, #0A AB A, R2 DPTR @DPTR, A HALT

HEXCODE 90,52,00 E0 FD 54,F0 23 23 23 23 F9 ED 54,0F F8 E9 75,F0, 0A A4 2A A3 F0 80,FE

COMMENTS Load the Data pointer with 16 bit constant Move the content present in external RAM to A Bring the content to R5 Register Separate the 10th digit. Mask the 4 bit Bring the MSB to LSB by rotate instruction

MSB is changed to LSB Store the 10th digit in R1 From original number separate 1s digit Separate the 1s digit. Store in R2 register Move the content of R1 to A Multiply 10s digit with 0A Add unit digit to the multiplied numbers Increment data pointer Result is stored in this location Short jump to loop HALT

22

Ex.No:7

BCD TO HEX CONVERSION

AIM: To write a program to convert the given of BCD value to its equivalent Hexadecimal value. APPARATUS REQUIRED: SI.no 1. APPARATUS Micro controller kit QUANTITY 1 No

PROCEDURE: 1. Enter the hex code in the RAM Memory starting from the location 5000. 2. The program is executed after entering all the hex code. 3. The inputs are given in the specified memory location. 4. Execute the program. 5. Store the result in the given location. INPUT: 5200: OUTPUT: 5201:

RESULT: Thus the program for conversion of BCD number to Hexadecimal number is executed and the output is noted.

HEX TO BCD CONVERSION 23

MEMORY ADDRESS 5000 5003 5004 5005 5006 5008 500A 500B

MNEMONICS Opcode Operand MOV DPTR, #5200 MOVX MOV CLR MOV MOV MOV JZ K1: MOV ADD DA MOV JNC CLR MOV ADD MOV K2: DJNZ K3: MOV MOV MOVX INC MOV MOVX HALT: SJMP A, @DPTR R5, A C R0, #00 R1, #00 A, R5 K3

HEXCODE 90,52,00 E0 FD C3 78,00 79,00 ED 60,D8

COMMENTS Load the Data pointer with 16 bit constant Move the content present in external RAM to A Bring the content to R5 Register Clear the carry flag Register to store 0-99 Register to store 100th digit Bring the content R5 Register to A Check for Zero jump if content is zero Move the content of accumulator to R0

500D 500E 5010 5011 5012 5014 5015 5016 5018 5019 501B 501E 501F 5020 5021 5022 5023

A, R0 A, #01 A R0, A K2 C A, R1 A, #01 R1, A R5, K1 DPTR,#5201 A, R0 @DPTR, A DPTR A, R1 @DPTR, A HALT

E8 24,01 D4 F8 50,05 C3 E9 24,01 F9 D0, F2 90,52,01 E8 F0 A3 E8 F0 80,FE Every time 1 is added Decimal adjust accumulator for BCD Check for overflow flag (exceeding 99) Clear carry flag Move the content of R1 to A The content present in A is the 100th digit and the maximum value of this is 2 Move the content of A to R1 Repeat till R5 becomes zero Load the Data pointer with 16 bit constant Move the content of R0 to A 0-99 Value is stored in this location Increment data pointer Move the content of R1 to A 100th digit is stored in this location Short jump to loop HALT

24

Ex.No:8

HEX TO BCD CONVERSION

AIM: To write a program to convert the given Hexadecimal value to its equivalent BCD value. APPARATUS REQUIRED: SI.no 1. APPARATUS Micro controller kit QUANTITY 1 No

PROCEDURE: 1. Enter the hex code in the RAM Memory starting from the location 5000. 2. The program is executed after entering all the hex code. 3. The inputs are given in the specified memory location. 4. Execute the program. 5. Store the result in the given location. INPUT: 5200: HEX Data OUTPUT: 5201: Lower byte of the result 5202: Higher byte of the result

RESULT: Thus the program for conversion of Hexadecimal number to BCD number is executed and the output is noted.

25

HEX TO ASCII CONVERSION MEMORY ADDRESS 5000 5003 5004 5006 5008 5009 500A 500C 500D 500E 5010 5012 5014 5015 5017 5019 5015 501C 501D 501E 5021 5022 5023 5024 5025 5026 5027 5028 502A 502B MNEMONICS Opcode Operand MOV DPTR, #6000 MOVX A, @DPTR MOV MOV MOV MOV ANL MOV CLR SUBB JC JZ MOV ADD SJMP LOOP: MOV ADD LOOP2: INC INC MOV MOV MOVX MOV RR RR RR RR ANL MOV CLR 50H,A R0, #50H A, @R0 R2, A A, #0F R1, A C A, #09 LOOP LOOP A, R1 A, #37 LOOP2 A, R1 A, #30 R0 R0 DPTR, #6002 @R0, A @DPTR, A A, R2 A A A A A, #0F R3, A C 26 HEXCODE 90,60,00 E0 F5, 50 78,50 E6 FA 54,0F F9 C3 94,09 40,07 60,05 E9 24,37 80,03 E9 24,30 08 08 90,60,02 F6 F0 COMMENTS Load the Data pointer with 16 bit constant Move the content present in external RAM to A Bring the content A to memory location 50H Move the immediate data to R0 register Move the content to A Move the content of A to R2 Mask the MSB Move the content of A to R1 Clear the carry flag Subtract 09 from the accumulator content Jump to LOOP if carry flag is set Jump to LOOP if the content of A is zero Move the content of R1 to A Add 37 to the accumulator content Short jump to LOOP2 Move the content of R1 to A Add 30 to the content of A Increment R0 Increment R0 Load the Data pointer with 16 bit constant Move the content of A to the location specified in R0 Move the content of A to the given location

EA Move the content of R2 to the given location 03 Rotate the content of accumulator right 03 Rotate the content of accumulator right 03 Rotate the content of accumulator right 03 Rotate the content of accumulator right 54,0F AND the content of A with 0F FB Move the content of A to R3 C3 Clear carry flag

502C 502E 5030 5032 5033 5035 5037 5038 503A 503B 503E 503F

SUBB JC JZ MOV ADD SJMP LOOP1: MOV ADD LOOP3: DEC MOV MOV MOVX HALT: SJMP

A, #09 LOOP1 LOOP1 A, R3 A, #37 LOOP3 A, R3 A, #30 R0 DPTR, #6001 @R0, A @DPTR, A

94,09 40,07 60,05 EB 24,37 80,03 EB 24,30 18 90,60,01 F6 F0

Subtract 09 from the accumulator content Jump to LOOP1 if carry flag is set Jump to LOOP1 if the content of A is zero Move the content of R3 to A Add 37 to the accumulator content Short jump to LOOP3 Move the content of R3 to A Add 30to the accumulator content Decrement R0 Load the Data pointer with 16 bit constant Move the content of A to the location specified in R0 Move the content of A to the given location Short jump to loop HALT

5040

HALT

80,FE

27

Ex.No:9 HEX TO ASCII CONVERSION 28

AIM: To write a program to convert the given Hexadecimal value to its equivalent ASCII. APPARATUS REQUIRED: SI.no 1. APPARATUS Micro controller kit QUANTITY 1 No

PROCEDURE: 1. Enter the hex code in the RAM Memory starting from the location 5000. 2. The program is executed after entering all the hex code. 3. The inputs are given in the specified memory location. 4. Execute the program. 5. Store the result in the given location. INPUT: 6000: OUTPUT: 6001: 6002:

RESULT: Thus the program for conversion of Hexadecimal number to ASCII is executed and the output is noted.

ASCII TO BINARY CONVERSION 29

MEMORY ADDRESS 5000 5003 5004 5005 5007 500A 500D 500F 5011 5012 5013

MNEMONICS Opcode Operand MOV DPTR, #5100 MOVX CLR SUBB MOV CJNE NXT:JC SUBB CODE:INC MOVX HLT:SJMP A,@DPTR C A,#30H 40H,#OA A,40,NXT CODE A,#07H DPTR @DPTR,A HLT

HEXCODE 90,51,00 E0 C3 94,30 75,40,0A B5,0,00 40,02 94,07 A3 F0 80,FE

COMMENTS Load the Data pointer with 16 bit constant Move the data in the external ram to Accumulator Clear carry Subtract 30 From Accumulator With Borrow Move the 0A to internal RAM to 40H Compare the acc content is less than 0A If yes go to CODE label Else subtract 07 from acc content Increment Data pointer Store the result in 5101 Be in a loop

Ex.No:10 30

ASCII TO BINARY CONVERSION AIM: To write a program for ASCII TO BINARY CONVERSION APPARATUS REQUIRED: SI.no 1. APPARATUS Micro controller kit QUANTITY 1 No

PROCEDURE: 1. Enter the hex code in the RAM Memory starting from the location 5000. 2. The program is executed after entering all the hex code. 3. The inputs are given in the specified memory location. 4. Execute the program. 5. Store the result in the given location. INPUT: 5100: OUTPUT: 5101:

RESULT: Thus the program for conversion of ASCII TO BINARY CONVERSION is executed and the output is noted.

SQUARE ROOT OF A GIVEN NUMBER MNEMONICS 31 HEXCODE COMMENTS

MEMORY ADDRESS 5000 5003 5004 5006 5008 5009 500A 500C 500E 500F 5010 5011 5013 5014 5015 5016 5018 501A 501B 501C

OPCODE MOV MOVX MOV MOV NXTSUB: CLR SUBB JZ JC INC INC INC SJMP OVER: MOV INC MOVX HERE: SJMP ERROR: MOV INC MOVX AGAIN: SJMP

OPERAND DPTR,#5100 A,@DPTR R0,#01H R1,#01H C A,R1 OVER ERROR R0 R1 R1 NXTSUB A,R0 DPTR @DPTR,A HERE A,#FFH DPTR @DPTR,A AGAIN 90,51,00 E0 78,01 79,01 C3 99 60,07 40,0A 08 09 09 80,F5 E8 A3 F0 80,FE 74,FF A3 F0 80,FE Load the data pointer with 16 bit constant Move the content present in external ram to Acc. Set R0 for counter Set R1 for Odd number Clear carry Subtract odd number from Acc Jump to over if A=0 Jump to ERROR if carry present Increment R0 Reg Increment R1 Reg Increment R1 Reg Repeat subtraction Move result to Acc Increment DataPointer Move the Acc content to given location Be in loop here Store ERROR code FFH Increment DataPointer Move the perfect square number to given location Be in loop AGAIN

32

Ex.No:11 SQUARE ROOT OF A GIVEN NUMBER AIM: To write a program for SQUARE ROOT OF A GIVEN NUMBER APPARATUS REQUIRED: SI.no 1. APPARATUS Micro controller kit QUANTITY 1 No

PROCEDURE: 1. Enter the hex code in the RAM Memory starting from the location 5000. 2. The program is executed after entering all the hex code. 3. The inputs are given in the specified memory location. 4. Execute the program. 5. Store the result in the given location. INPUT: 5100: OUTPUT: 5101:

RESULT: Thus the program for SQUARE ROOT OF A GIVEN NUMBER executed and the output is noted.

33

LEAST COMMON MULTIPLE MEMORY ADDRESS 5000 5003 5004 5005 5006 5007 5008 5009 500B 500C 500E 5011 5014 5015 5016 5017 5019 501A 501B MNEMONICS Opcode MOV MOVX MOV INC MOVX MOV NXT DIV: MOV MOV DIV MOV MOV CJNE MOV INC MOVX HERE: SJMP NXT:MOV ADD SJMP Operand DPTR,#5100 A,@DPTR R0,A DPTR A,@DPTR R1,A R2,A B,R0 AB A,B 40H,#00 A,40,NXT A,R2 DPTR @DPTR,A HERE A,R2 A,R0 NXTDIV HEX CODE 90,51,00 E0 F8 A3 EO F9 FA 88,F0 84 E5,F0 75,40,00 B5,40,05 EA A3 F0 80,FE EA 29 80,EB COMMENTS Load The First Data Into The DPTR Points Move the data in the external ram to Accumulator Save the second number In R0 Register Increment data pointer Move the content of external RAM to Accumulator Save 1st number in R1 Register Save 1st number in R2 Register Save the 2nd number in B Register Divide the 1st & 2nd number Move reminder to Accumulator Move 00 to 40H check reminder is 0; if not jump to NXT Move LCM to Accumulator Increment data pointer Move the content of A to 5102 Be in a loop Move the content of R2 to Accumulator Add 1st number to 1st number Go and perform next division

34

Ex.No:12 LEAST COMMON MULTIPLE AIM: To write a program for LEAST COMMON MULTIPLE APPARATUS REQUIRED: SI.no 1. APPARATUS Micro controller kit QUANTITY 1 No

PROCEDURE: 1. Enter the hex code in the RAM Memory starting from the location 5000. 2. The program is executed after entering all the hex code. 3. The inputs are given in the specified memory location. 4. Execute the program. 5. Store the result in the given location. INPUT: 5100: OUTPUT: 5101:

RESULT: Thus the program for LEAST COMMON MULTIPLE is executed and the output is noted.

35

GREATEST COMMON DIVISOR MEMORY ADDRESS 5000 5003 5004 5006 5007 5008 500A 500B 500D 5010 5013 5014 5015 5016 5018 501B MNEMONICS Opcode MOV MOVX MOV INC MOVX NXT DIV: MOV DIV MOV MOV CJNE MOV INC MOVX HERE: SJMP NXT: MOV SJMP Operand DPTR,#5100 A,@DPTR B,A DPTR A,@DPTR R0,B AB A,B 40H,#00 A,40,NXT A,R0 DPTR @DPTR,A HERE A,R0 NXTDIV HEX CODE 90,51,00 E0 F5,F0 A3 EO A8,F0 84 E5,F0 75,40,00 B5,40,05 E8 A3 F0 80,FE E8 80,ED COMMENTS Load The First Data Into The DPTR Points Move the data in the external ram to Accumulator Bring the content(divisor) A to B register Increment data pointer Move the content of external RAM to Accumulator Save divisor in R0 Register Divide the 1st & 2nd number Move reminder to Accumulator Move 00 to 40H check reminder is 0; if not jump to NXT Move GCD to Accumulator Increment data pointer Move the content of A to 5102 Be in a loop HERE Move the content of R0 to Accumulator Go and perform next division

36

Ex.No:13 GREATEST COMMON DIVISOR AIM: To write a program for GREATEST COMMON DIVISOR APPARATUS REQUIRED: SI.no 1. APPARATUS Micro controller kit QUANTITY 1 No

PROCEDURE: 1. Enter the hex code in the RAM Memory starting from the location 5000. 2. The program is executed after entering all the hex code. 3. The inputs are given in the specified memory location. 4. Execute the program. 5. Store the result in the given location. INPUT: 5100: 5101: OUTPUT: 5102:

RESULT: Thus the program for GREATEST COMMON DIVISOR is executed and the output is noted.

37

38

HARDWARE

39

40

MEMORY

MNEMONICS 41

HEXCODE

ADDRESS 4100 4103 4105 4106 4108 410B 410C 410F 4110 4112 4115 4118 411B 411E 4120 4122 4124 4126 4128 412B 412D 4130 4132 4135 4137 413A 413B 413E 413F 4142 4143 4145 4146 4148 414A 414C

OPCODE MOV MOV MOVX START:MOV MOV MOVX MOV MOVX ANL CJNE LJMP CONT:LCAL L LJMP GETDAT:MO V MOV MOV MOV MOV LCALL MOV LCALL MOV LCALL MOV LCALL RET FIND1:MOV MOVX MOV MOVX ANL MOV MOV FFN2:MOV MOV MOVX

OPERAND DPTR,#FF0FH A,#82H @DPTR,A A,#00H DPTR,#FF0CH @DPTR,A DPTR,#FF0DH A,@DPTR A,#0FH A,#0FH,CONT START GETDAT START R2,#51H R3,#00H R4,#52H R5,#00H A,#0EH FIND1 A,#0DH FIND1 A,#0BH FIND1 A,#07H FIND1 DPTR,#FF0CH @DPTR,A DPTR,#FF0DH A,@DPTR A,#0FH R6,A R7,#04H DPH,R4 DPL,R5 A,@DPTR

90,FF,0F 74,82 F0 74,00 90,FF,0C F0 90,FF,0D E0 54,0F B4,0F,03 02,41,06 12,41,1E 02,41,06 7A,51 7B,00 7C,52 7D,00 74,0E 12,41,3B 74,0D 12,41,3B 74,0B 12,41,3B 74,07 12,41,3B 22 90,FF,0C F0 90,FF,0D E0 54,0F FE 7F,04 8C,83 8D,82 E0

42

Ex.No:1 MATRIX KEYBOARD AIM: To write a program to interface matrix keyboard with 8051 microcontroller. APPARATUS REQUIRED: SI.no 1. 2. APPARATUS Micro controller kit Keyboard Interface card QUANTITY 1 No 1 No

PROCEDURE: 1. Connect the keyboard interface card to Micro controller 2. Enter the hex code in the RAM Memory starting from the location 4100 3. Execute the program. 4. Display will be blank in the card. 5. Now press any key. 6. Output will be observed in LCD of 8051 by using matrix keyboard

414D 414F 4152

MOV CJNE LCALL

DPL,R6 A,DPL,FFN3 STOREDAT 43

8E,82 B5,82,04 12,41,5F

4155 4156 4157 4158 415A 415C 415E 415F 4162 4165 4167 4168 416B 416D 416E 4171 4173 4174 4177 4179 417A 417D 417F 4180 4182 4184 4187 4189 418C 418D 418E 4191 4192 4193 4195 4197 419A 419C 419D 41A0

RET FFN3:INC INC DJNZ MOV MOV RET STOREDAT:L CALL MOV MOV MOVX LCALL MOV MOVX LCALL MOV MOVX LCALL MOV MOVX LCALL MOV MOVX MOV MOV MORE:LCAL L MOV MOV MOVX MOVX MOV MOVX RET BSYCHK:MO V MOV MOV MOV MOVX BSY:MOV MOVX

R3 R5 R7,FFN2 R4,#52H R5,#00H BSYCHK DPL,#DEN A,#38H @DPTR,A BSYCHK A,#01H @DPTR,A BSYCHK A,#06H @DPTR,A BSYCHK A,#0FH @DPTR,A BSYCHK A,#80H @DPTR,A DPH,R2 DPL,R3 BSYCHK A,#01H P2,#IOHIGH @R0,A A,@DPTR P2,#IOHIGH @R1,A R1,#DENL R0,#LATCHL P2,#IOHIGH A,#02H @R0,A P2,#IOHIGH A,@R1 44

22 0B 0D DF,EE 7C,52 7D,00 22 12,41,93 90,FF,04 74,38 F0 12,41,93 74,01 F0 12,51,93 74,06 F0 12,41,93 74,0F F0 12,41,93 74,80 F0 8A,83 8B,82 12,41,93 74,01 75,A0,FF F2 E0 75,A0,FF F3 22 79,04 78,08 75,A0,FF 74,02 F2 75,A0,FF E3

41A1 41A3 41A5 41A8 41AA 41AB

ANL JNZ MOV MOV MOVX RET ADDRESS 5100 5104 5108 510C 5200

A,#80H BSY P2,#IOHIGH A,#00H @R0,A

54,80 70,FA 75,A0,FF 74,00 F2 22

INPUT
DATA TO BE STORED 30H,31H,32H,33H 34H,35H,36H,37H 38H,39H,41H,42H 43H,44H,45H,46H 0EH,0DH,0BH,07H

RESULT: Thus the program for interfacing matrix keyboard with 8051 microcontroller is executed and output is observed in LCD of 8051 by using matrix keyboard.

SEVEN SEGMENT DISPLAY 45

CNTRL PORTA PORTB TEMP MEMORY ADDRESS 4101 4103 4105 4106 4109 410B 410C 410F 4110 4113 4115 4117 4119 411B 411E 411F 4121 4123 4124 4127 4128 412B 412C 412D 4130 4131 4133

ORG EQU EQU EQU EQU

4100H FF0FH FF0CH FF0DH 5000H HEXCODE 90,FF,0F 74,80 F0 90,FF,0C 74,FF F0 90,FF,0D F0 90,42,00 A8,82 A9,83 7A,04 74,01 90,50,00 F0 88,82 89,83 E0 90,FF,0C FO 90,50,00 E0 F4 90,FF,0D E0 31,42 08

MNEMONICS OPCODE OPERAND MOV DPTR,#CNTRL MOV MOVX MOV MOV MOVX MOV MOVX START:MOV MOV MOV MOV MOV MOV MOVX CONT:MOV MOV MOVX MOV MOVX MOV MOVX CPL MOV MOVX ACALL INC A,#80H @DPTR,A DPTR,PORTA A,#FFH @DPTR,A DPTR,#PORTB @DPTR,A DPTR,#4200H R0,DPL R1,DPH R2,#04H A,#01 DPTR,#TEMP @DPTR,A DPL,R0 DPH,R1 A,@DPTR DPTR,#PORTA @DPTR,A DPTR,#TEMP A,@DPTR A DPTR,#PORTB @DPTR,A DELAY R0

Ex..No:2 SEVEN SEGMENT DISPLAY 46

AIM: To write a program to interface seven segment display with 8051 microcontroller. APPARATUS REQUIRED: SI.no 1. 2. APPARATUS Micro controller kit Seven segment display interface QUANTITY 1 No 1 No

PROCEDURE: 1. Connect the Seven segment display interface to Micro controller 2. Enter the hex code in the RAM Memory starting from the location 4100 3. Execute the program. 4. Observe the result in seven segment display board.

4134 4137 4138

MOV MOVX MOV

DPTR,#TEMP A,@DPTR R6,A 47

90,50,00 E0 FE

4139 413A 413D 413E 4140 4142 4144 4147 4149 414A 414C 414E 4150 4152

ADD MOV MOVX DJNZ JMP DELAY:MOV L3:CALL DJNZ RET DELY:MOV L2:MOV L1:DJNZ DJNZ RET INPUT

A,R6 DPTR,#TEMP @DPTR,A R2,COUNT START R3,#02H DELY R3,L3 R4,#FFH R5,#FFH R5,L1 R4,L2

2E 90,50,00 F0 DA,DF 21,10 7B,02 12,41,4A DB,FB 22 7C,FF 7D,FF DD,FE DC,FA 22 OUTPUT IN 7 SEGMENT DISPLAY ABCD

4200

DB

88H,80H,C6H,C0 H

48

RESULT: Thus the program for interfacing 7 segment display with 8051 microcontroller is executed and output is observed in 7 segment display. \

INTERFACING OF LCD

49

MEMORY ADDRESS 4100 4100 4103 4106 4109 410C 410F 4112 4114 4116 4119

MNEMONICS Opcode Operand ORG 4100H LCALL LCALL LCALL LCALL LCALL MOV MOV MOV LCALL HLT: SJMP SETADDR: LCALL LCALL MOV ORL MOV MOVX RET FUNSET: LCALL LCALL MOV FUNSET CLRDAS SHFOFF CURON SETADDR DPTR,#419EH R1,DPL R2,DPH PUTSTR HLT SETS BSYCHK SETO A,#00H A,#80H DPTR,#0FFC4 H @DPTR,A BSYCHK SET0 A,#38H

HEXCODE

COMMENTS

12,41,2A 12,41,6C 12,41,37 12,41,44 12,41,1B 90,41,9E A9,82 AA,83 12,41,79 80,FE DD RAM ADDRESS 12,41,51 12,41,65 74,00 44,80 90,FF,C4 F0 22 12,41,51 12,41,65 74,38 INITIALIZE FOR 8 BIT

411B 411E 4121 4123 4125 4128 4129 412A 412D 4130

Ex.No.3 AIM:

INTERFACING OF LCD

50

To write a program to interface LCD with micro controller and to display text messages. APPARATUS REQUIRED: SI.no 1. 2. APPARATUS Micro controller kit LCD interface card QUANTITY 1 No 1 No

PROCEDURE: 1. Connect the LCD interface card to micro controller kit. 2. Enter the hex code in the RAM Memory starting from the location 4100. 3. Execute the program. 4. Observe the result in the LCD display

RESULT: Thus the program for interfacing of LCD display with micro controller is executed and output is observed in LCD display.

4132 4135

MOV MOVX

DPTR,#0FFC4 H @DPTR,A 51

90,FF,C4 F0 CHARACTER FONT

4136 4137 413A 413D 413F 4142 4143 4144 4147 414A 414C 414F 4150 4151 4154 4157 4158 415A 415B 415D 415E 4160 4163 4164 4165 4167 416A 416B 416C 416F 4172 4174 4177 4178 4179 417A 417D 4180 4183

RET SHF0FF: LCALL LCALL MOV MOV MOVX RET CURON:LCAL L LCALL MOV MOV MOVX RET BSYCHK:LCAL L BBB:MOV MOVX ANL RLC JC RET SET2:MOV MOV MOVX RET SET0:MOV MOV MOVX RET CLRDIS:LCAL L LCALL MOV MOV MOVX RET PUTSTR:MOV X CJNE LJMP LCALL LCALL

BSYCHK SET0 A,#06 DPTR,#0FFC4 H @DPTR,A BSYCHK SET0 A,#0FH DPTR,#FFC4H @DPTR,A SET2 DPTR,#FFC4H A,@DPTR A,#80H A BBB A,#0AH DPTR,#FFC0H @DPTR,A A,#08H DPTR,#FFC0H @DPTR,A BSYCHK SET0 A,#01H DPTR,#FFC4H @DPTR,A A,@DPTR A,#2E,PUTC HLT BSYCHK SET1 52

22 12,41,51 12,41,65 74,06 90,FF,C4 F0 22 12,41,51 12,41,65 74,0F 90,FF,C4 FO 22 12,41,5E 90,FF,C4 E0 54,80 33 40,F7 22 74,0A 90,FF,C0 F0 22 74,08 90,FF,C0 F0 22 12,41,51 12,41,65 74,01 90,FF,C4 F0 22 E0 B4,2E,03 02,41,19 12,41,51 12,41,97 CURSOR ON NO SHIFT, AUTO INCREMENT OF DISPLAY POSITION

TO CLEAR THE DISPLAY

4186 4188 418A 418B 418E 418F 4191 4193 4194 4197 4199 419C 419D 419E 41A2 41A6 419E 41A2 41A6

MOV MOV MOVX MOV MOVX MOV MOV INC LCALL SET1:MOV

DPL,R1 DPH,R2 A,@DPTR DPTR,#FFC4H @DPTR,A DPL,R1 DPH,R2 R1 PUSTR A,#09H

89,82 8A,83 E0 90,FF,C4 F0 89,82 8A,83 09 12,41,79 74,09

TO DISPLAY THE NEXT LETTER WRITE DATA TO CG/DD RAM

MOV DPTR,#FFC0H MOVX @DPTR,A RET INPUT 43,4B,50,43 20,42,43,45 2E 43,4B,50,43 20,45,45,45 2E

90,FF,C0 F0 22 OUTPUT IN LCD DISPLAY CKPC_ECE. CKPC_EEE.

PROGRAM FOR TRAFFIC LIGHT CONTROL


FF0F FF0C FF0D FF0E ORG CONTRL PORTA PORTB PORTC 4100H EQU EQU EQU EQU 53 0FF0FH 0FF0CH 0FF0DH 0FF0EH

ADDRESS 4100 4102 4105 4106 4108 410B 410D 410F 4112 4114 4116 4117 4119 411B 411E 411F 4120 4122 4124 4125 4127 4129 412C 412D 412E 4130 4132 4133 4135 4137 413A 413B 413C 413F 4141 4143 4144 4146 Ex.No.4

MNEMONICS OPCODE OPERAND MOV A,#80h MOV DPTR,#contrl MOVX @DPTR,A START:MOV R4,#04h MOV DPTR,#LOOK1 MOV R2,DPH MOV R3,DPL MOV DPTR,#LOOK MOV R0,DPH MOV R1,DPL GO:MOVX A,@DPTR MOV R0,DPH MOV R1,DPL MOV DPTR,#porta MOVX @DPTR,A INC R1 MOV DPH,R0 MOV DPL,R1 MOVX A,@DPTR MOV R0,DPH MOV R1,DPL MOV DPTR,#portb MOVX @DPTR,a INC R1 MOV DPH,R0 MOV DPL,R1 MOVX A,@DPTR MOV R0,DPH MOV R1,DPL MOV DPTR,#portc MOVX @DPTR,A INC R1 LCALL DELAY MOV DPH,R2 MOV DPL,R3 MOVX A,@DPTR MOV R2,DPH MOV R3,DPL

HEXCODE 74 80 90 FF 0F F0 7C 04 90 41 9B AA 83 AB 82 90 41 8F A8 83 A9 82 E0 A8 83 A9 82 90 FF 0C F0 09 88 83 89 82 E0 A8 83 A9 82 90 FF 0D F0 09 88 83 89 82 E0 A8 83 A9 82 90 FF 0E F0 09 12 41 75 8A 83 8B 82 E0 AA 83 AB 82

TRAFFIC LIGHT CONTROL

AIM: To write a program to interface TRAFFIC LIGH CONTROL with Micro controller. APPARATUS REQUIRED: 54

SI.no 1. 2.

APPARATUS Micro controller kit Traffic light control board

QUANTITY 1 No 1 No

PROCEDURE: 1. Connect the TLC interface card to micro controller kit. 2. Enter the hex code in the R Memory starting from the location 4100. 3. Execute the program. 4. Observe the result in the Traffic Light Control board.

4148 414B 414C 414D 414F 4151 4152 4154

MOV MOVX INC MOV MOV MOVX MOV MOV

DPTR,#porta @DPTR,A R3 DPH,R2 DPL,R3 A,@DPTR R2,DPH R3,DPL 55

90 FF 0C F0 0B 8A 83 8B 82 E0 AA 83 AB 82

4156 4159 415A 415B 415D 415F 4160 4162 4164 4167 4168 4169 416C 416E 4170 4172 4175 4177 4179 417B 417D 417F 4181 4182 4184 4186 4188 418A 418C 418E 418F 4192 4195 4198 419B 419E 41A1 41A4

MOV MOVX INC MOV MOV MOVX MOV MOV MOV MOVX INC LCALL MOV MOV DJNZ LCALL DELAY:MOV L3:MOV L2:MOV L1:DJNZ DJNZ DJNZ RET DELAY1:MOV L6:MOV L5:MOV L4:DJNZ DJNZ DJNZ RET LOOK:DB DB DB DB LOOK1:DB DB DB DB END

DPTR,portb @DPTR,A R3 DPH,R2 DPL,R3 A,@DPTR R2,DPH R3,DPL DPTR,#portc @DPTR,A R3 DELAY1 DPH,R0 DPL,R1 R4,GO START R5,#12H R6,#0FFH R7,#0FFH R7,L1 R6,L2 R5,L3 R5,#12H R6,#0FFH R7,#0FFH R7,L4 R6,L5 R5,L6 44H,27H,12H 92H,2BH,10H 84H,9DH,10H 84H,2EH,48H 48H,27H,12H 92H,4BH,10H 84H,9DH,20H 04H,2EH,49H

90 FF 0D F0 0B 8A 83 8B 82 E0 AA 83 AB 82 90 FF 0E F0 0B 12 41 82 88 83 89 82 DC A4 12 41 06 7D 12 7E FF 7F FF DF FE DE FA DD F6 22 7D 12 7E FF 7F FF DF FE DE FA DD F6 22 44 27 12 92 2B 10 84 9D 10 84 2E 48 48 27 12 92 4B 10 84 9D 20 04 2E 49

56

RESULT: Thus the program for interfacing of Traffic Light Control Board with micro controller is executed and output is observed in Traffic Light Control Board.

STEPPER MOTOR PROGRAM MEMORY ADDRESS 4100 4100 MNEMONICS Opcode Operand ORG 4100H START:MOV 57 DPTR,#4500H HEXCODE

90,45,00

4103 4105 4106 4108 410A 410D 410F 4111 4113 4115 4117 4119 411A 411C 411E 411F 4121 4123 INPUT 4500 4500

MOV JO:MOVX PUSH PUSH MOV MOV MOV DLY1:MOV DLY:DJNZ DJNZ DJNZ MOVX POP POP INC DJNZ SJMP END

R0,#04H A,@DPTR DPH DPL DPTR,#FFC0H R2,#04H R1,#0FH R3,#0FH R3,DLY R1,DLY1 R2,DLY1 @DPTR,A DPL DPH DPTR R0,JO START

78,04 E0 C0,83 C0,82 90,FF,C0 7A,04 79,0F 7B,0F DB,FE D9,FA DA,F8 F0 D0,82 D0,83 A3 D8,E4 80,DD 80,DD

09,05,06,0A 0A,06,05,09

STEPPER MOTOR ROTATION FORWARD DIRECTION REVERSE DIRECTION

Ex.No:5 INTERFACING OF STEPPERMOTOR AIM: To write a program to interface stepper motor with micro controller. APPARATUS REQUIRED: 58

SI.no 1. 2. 3.

APPARATUS Micro controller kit Stepper motor Interface card

QUANTITY 1 No 1 No 1 No

PROCEDURE: 1. Connect the Stepper motor interface card to micro controller kit. 2. Enter the hex code in the RAM Memory starting from the location 3. 4100.Execute the program. 4. observe the result in rotation of stepper motor.

RESULT: Thus the program for stepper motor interface with microcontroller kit is executed and output is observed in rotation of stepper motor.

PROGRAM FOR LIFT CONTROL


0001 0030 0031 FFC0 FFC4 FFC8 T0_m1 COUNT COUNT1 LIFT1 LIFT2 STAT_IN 59 EQU EQU EQU EQU EQU EQU 01H 30H 31H 0FFC0H 0FFC4H 0FFC8H

FFCC ORG 4100 ADDRESS 4100 4102 4105 4106 4109 410B 410C 410E 4111 4112 4114 4117 4118 411B 411E 4120 4121 4124 4126 4127 412A 412C 412D 4130 4132 4133 4135

STAT_0U

EQU HEXCODE 74,03 90,FF,CC F0 12,41,41 74,02 F0 74,80 90,FF,C0 F0 74,01 90,FF,C4 F0 12,41,41 90,FF,C0 74,40 F0 12,41,41 74,20 F0 12,41,41 74,10 F0 12,41,41 74,08 F0 74,0B 90,FF,CC

0FFCCH COMMENT DEFAULT OPEN DOORS OF LIFT1 & 2 CLOSE DOOR OF LIFT1 INDICATES LIFT 1 IN GROUND FLOOR INDICATES LIFT 2 IN 7TH FLOOR

MNEMONICS OPCODE OPERAND START:MOV A,#03H MOV DPTR,#STAT_ OU MOVX @DPTR,A CALL DELAY MOV A,#02H MOVX MOV MOV MOVX MOV MOV MOVX CALL MOV MOV MOVX CALL MOV MOVX CALL MOV MOVX CALL MOV MOVX MOV MOV @DPTR,A A,#80H DPTR,#LIFT1 @DPTR,A A,#01H DPTR,#LIFT2 @DPTR,A DELAY DPTR,#LIFT1 A,#40H @DPTR,A DELAY A,#20H @DPTR,A DELAY A,#10H @DPTR,A DELAY A,#08H @DPTR,A A,#0BH DPTR,#STAT_ OU

BEEP FOR DOOR OPEN

Ex.No.6

LIFT CONTROL

AIM: To write a program to interface LIFT CONTROL with Micro controller. APPARATUS REQUIRED: 60

SI.no 1. 2.

APPARATUS Micro controller kit Lift control interface

QUANTITY 1 No 1 No

PROCEDURE: 1. Connect the lift control interface card to micro controller kit. 2. Enter the hex code in the R Memory starting from the location 4100. 3. Execute the program. 4. Observe the result in the lift Control board.

4138 4139 413C 413E 413F 4141 4144

MOVX CALL MOV MOVX HERE:SJMP DELAY:MOV DL2:MOV

@DPTR,A DELAY A,#03H @DPTR,A HER COUNT1,#10 COUNT,#100 61

F0 12,41,41 74,03 F0 80,FE 75,31,0A 75,30,64

OPEN DOORS FOR 1 SECOND DELAY

4147 414A 414D 4150 4151 4154 4157

D2:CALL DJNZ DJNZ RET DELAY 1 ms: MOV MOV CALL

DELAY 1 MS COUNT,D2 COUNT1,DL2 DL0,#17H DH0,#FCH T0 DELAY

12,41,51 D5,30,FA D5,31,F4 22 75,8A,17 75,8C,FC 12,41,5B

THE LOW BYTE OF TIMER 0(TL0=17H) THE HIGH BYTE OF TIMER 0(TH0=FCH) ACTIVATE THE TIMER 0 AND WAIT UPTO TIMER OVERFLOW OCCURS

415A 415B 415D 415F 4161 4163 4165

RET T0 DELAY: MOV ANL ORL MOV SETB JNB

A,TMOD A,#F0H A,#T0_M1 TMOD,A TR0 TFO,$

22 E5,89 54,F0 44,01 F5,89 D2,8C 30,8D,FD

4168 416A 416C

CLR CLR RET

TR0 TF0

C2,8C C2,8D 22

2 TIMER 0,MODE 1 1 START TIMER 0 0FFFF-(16 BIT TIMER VALUE)+1; MONITOR TIMER FLAG 0 1 STOP THE TIMER 0 1 CLEAR TIMER FLAG 0 1 RETURN FROM SUBROUTINE

END

62

RESULT: Thus the program for interfacing of Lift Control Board with micro controller is executed and output is observed in Lift Control Board.

63

You might also like