0% found this document useful (0 votes)
2K views

Microprocessor and Microcontroller Laboratory

The document contains details about the Microprocessor and Microcontroller Laboratory manual for the II Year/IV Semester Electrical and Electronics Engineering students of the academic year 2023-2024. It includes a list of 13 experiments to be performed using 8085 Microprocessor and 8051 Microcontroller covering arithmetic operations, interfacing, and programming PIC architecture. The experiments are divided into two cycles with the first cycle focusing on 8085 Microprocessor and the second on 8051 Microcontroller.

Uploaded by

thivyaprasad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

Microprocessor and Microcontroller Laboratory

The document contains details about the Microprocessor and Microcontroller Laboratory manual for the II Year/IV Semester Electrical and Electronics Engineering students of the academic year 2023-2024. It includes a list of 13 experiments to be performed using 8085 Microprocessor and 8051 Microcontroller covering arithmetic operations, interfacing, and programming PIC architecture. The experiments are divided into two cycles with the first cycle focusing on 8085 Microprocessor and the second on 8051 Microcontroller.

Uploaded by

thivyaprasad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 70

DEPARTMENT OF ELECTRICAL AND ELECTRONICS

ENGINEERING

EE3413 - MICROPROCESSOR AND MICROCONTROLLER


LABORATORY MANUAL

II YEAR/ IV SEMESTER

REGULATION 2021

ACADEMIC YEAR 2023-2024

PREPARED BY .D.THIVYA PRASAD , AP/EEE

NAME OF THE STUDENT:…………………………………………………….


SPR.NO:……………………………………………………..
YEAR/ SEM:………………………………………………………..
DEPARTMENT :…………………………………………………………

3
MARK SIGNATURE
S.No DATE NAME OF THE EXPERIMENT

10

11

12

13

Completed date:

Average Mark: Staff - in – charge

4
EE3413 MICROPROCESSOR AND MICROCONTROLLER LABORATORY

LIST OF EXPERIMENTS

CYCLE-1

PROGRAMMING EXERCISES / EXPERIMENTS WITH µP8085:

1. Simple arithmetic operations: Multi precision addition / subtraction /multiplication /

division.

2. Programming with control instructions: Increment / Decrement, Ascending / Descending

order, Maximum / Minimum of numbers, Rotate instructions, Hex / ASCII / BCD code
conversions.

3. Interface Experiments: A/D Interfacing. D/A Interfacing. Traffic light controller

4. Stepper motor controller interface.

5. Displaying a moving/ rolling message in the student trainer kit’s output device.

CYCLE-2

PROGRAMMING EXERCISES / EXPERIMENTS WITH µC8051:

6. Simple arithmetic operations with 8051: Multi precision addition / subtraction /

multiplication/ division.

7. Programming with control instructions: Increment / Decrement, Ascending / Descending.

order, Maximum / Minimum of numbers, Rotate instructions, Hex / ASCII / BCD code

conversions.

8. Interface Experiments: A/D Interfacing. D/A Interfacing. Traffic light controller

9. Stepper motor controller interface.

10. Displaying a moving/ rolling message in the student trainer kit’s output device.

11. Programming PIC architecture with software tools.

5
CONTENTS

S.No. Ex.No NAME OF THE EXPERIMENT PAGE NO.


8085 MICROPROCESSOR

1. 8 BIT ARITHMETIC OPERATIONS


1. 1.A. 8 bit Addition
2. 1.B. 8 bit Subtraction
3. 1.C. 8 bit Multiplication
4. 1.D. 8 bit Division
2. 16 BIT ARITHMETIC OPERATIONS
5. 2.A. 16 bit Addition
6. 2.B. 16 bit Subtraction
7. 2.C. 16 bit Multiplication
8. 2.D. 16 bit Division
3. SORTING OPERATIONS
9. 3.A. Ascending order
10. 3.B. Descending order
4. SEARCHING OPERATIONS
11. 4.A. Smallest number
12. 4.B. Largest Number
5. CODE CONVERSION
13. 5.A. ASCII to decimal
14. 5.B. BCD to hexadecimal
6. 8085 INTERFACING EXPERIMENTS
15. 6.A. A/D, D/A Interfacing with 8085
16. 6.B Traffic Light Controller using 8085
17. 7. Stepper motor controller interface.
18. 8 Displaying a moving/ rolling message in the
student trainer kit’s output device.
8051 MICROCONTROLLER
19. 9 8 BIT ARITHMETIC OPERATIONS

20. 9.A. 8 bit Addition


6
21. 9.B. 8 bit Subtraction

22. 9.C. 8 bit Multiplication

23. 9.D. 8 bit Division


10 SORTING OPERATIONS
24. 10.A. Programming with control instructions:
Increment / Decrement
25. 10.B. Ascending / Descending
26. 10.C. Maximum / Minimum of numbers
27. 10.D. Rotate instructions,

28. 10.E. Hex / ASCII conversions.


10F. BCD code conversions

11 8051 INTERFACING EXPERIMENTS


29. 11.A. Interfacing Stepper motor Control
30. 11.B. Interfacing ADC/ DAC
31. 11.C. Traffic light controller
32. 12. Displaying a moving/ rolling message
33. 13. Programming PIC architecture with software
tools

7
1.A. 8 BIT ADDITION USING 8085
AIM:

To add two 8 bit numbers stored at two memory locations.

ALGORITHM:

1. Start the program.


2. Initialize memory pointer to data location.
3. Get the first number from memory in accumulator.
4. Also get the second number.
5. Add it to the accumulator.
6. Store the answer at another memory location.
7. Store the carry at next memory location.
8. Stop the program.

PROGRAM:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


9100 MVI C,00H 0E,00 Clear C register
Move the immediate data 1 to
9102 MVI A, data 1 3E, data 1
accumulator
9104 MVI B, data 2 06, data 2 Move the immediate data 2 to B register
Add the content of B register with the
9106 ADD B 80
content of accumulator
9107 JNC GO D2,0B,91 Jump on no carry to specified address
910A INR C 0C Increment the content of C register by 1
Store the content of accumulator in the
910B GO STA 5000 32,00,50
address 5000
Move the content of C register to
910E MOV A,C 79
accumulator
Store the content of accumulator in the
910F STA 5001 32,01,50
address 5001
9112 HLT 76 End the program
OBSERVATION:
INPUT OUTPUT

RESULT:

Thus the 8 bit numbers stored at two memory locations were added and the result was displayed.

8
1.B. 8 BIT SUBTRACTION USING 8085
AIM:

To subtract two 8 bit numbers stored at two memory locations.

ALGORITHM:

1.Start the program.


2.Initialize memory pointer to data location.
3.Get the first number from memory in accumulator.
4.Get the second number and subtract from the accumulator.
5.If the result yields a borrow, the content of the acc. is complemented and 01H is added to it (2’s
complement). A register is cleared and the content of that reg. is incremented in case there is a
borrow. If there is no borrow the content of the acc. is directly taken as the result.
6. Store the answer at next memory location.
7. Stop the program.
PROGRAM:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


Load the immediate data to HL register
4100 LXI H,4150 21,50,41
pair
Move the content of M register to
4103 MOV A,M 7E
accumulator
4104 MVI C,00 0E,00 Clear the content of C register

4106 INX H 23 Increment the HL register pair by 1


Subtract the content of M register with
4107 SBB M 9E
borrow from accumulator
4108 JNC GO D2,0C,41 Jump on no carry to specified address
410B INR C 0C Increment the content of C register by 1
Store the content of accumulator in the
410C G0 STA 4152 32,52,41
address 4152
Move the content of C register to
410F MOV A,C 79
accumulator
Store the content of accumulator in the
4110 STA 4153 32,53,41
address 4153
4113 HLT 76 End the program

OBSERVATION:
INPUT OUTPUT

RESULT:

Thus the 8 bit numbers stored at two memory locations were subtracted and the result was displayed.

9
1. C. 8 BIT MULTIPLICATION USING 8085
AIM:
To multiply two 8 bit numbers stored at two memory locations and store the result.

ALGORITHM:
1. Start the program.
2. Initialize memory pointer to data location.
3. Move multiplicand to a register.
4. Move the multiplier to another register.
5. Clear the accumulator.
6. Add multiplicand to accumulator
7. Decrement multiplier
8. Repeat step 5 till multiplier comes to zero.
9. The result, which is in the accumulator, is stored in a memory location.
10. Stop the program.
PROGRAM:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


4100 LXI H,4150 21,50,41 Load the immediate data to HL register pair
Move the content of M register to
4103 MOV A,M 7E
accumulator
4104 MVI C,00 0E,00 Clear the content of C register

4106 INX H 23 Increment the HL register pair by 1


Subtract the content of M register with
4107 SBB M 9E
borrow from accumulator
4108 JNC GO D2,0C,41 Jump on no carry to specified address
410B INR C 0C Increment the content of C register by 1
Store the content of accumulator in the
410C G0 STA 4152 32,52,41
address 4152
Move the content of C register to
410F MOV A,C 79
accumulator
Store the content of accumulator in the
4110 STA 4153 32,53,41
address 4153
4113 HLT 76 End the program

OBSERVATION:
INPUT OUTPUT

RESULT:

Thus the 8-bit multiplication was done in 8085 p using repeated addition method.

10
1. D. 8 BIT DIVISION USING 8085
AIM:

To divide two 8-bit numbers and store the result in memory.

ALGORITHM:

1.Start the program.


2.Load Divisor and Dividend
3.Subtract divisor from dividend
4.Count the number of times of subtraction which equals the quotient
5.Stop subtraction when the dividend is less than the divisor .The dividend now becomes the
remainder. Otherwise go to step 2.
6. Stop the program execution.
PROGRAM:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


4500 MVI A,data1 3E, data 1 Move the dividend to accumulator

4502 MVI B, data 2 06, data 2 Move the divisor to B register

4504 MVI C, 00 0E,00 Clear the content of C register

4506 LOOP 2 CMP B B8 Compare B register and accumulator

4507 JC LOOP 1 DA,0F,45 Jump on carry to specified address

450A SBB B 90 Repetitive subtraction

450B INR C 0C Increment the content of C register by 1

450C JMP LOOP 2 C3,06,45 Jump unconditionally to specified address

450F LOOP 1 STA 5000 32,00,50 Store the remainder in the address 5000

4512 MOV A,C 79 Move C register content to accumulator

4513 STA 5001 32,01,50 Store the quotient in the address 5000

4516 HLT 76 End the program

OBSERVATION:
INPUT OUTPUT

RESULT:

Thus an ALP was written for 8-bit division using repeated subtraction method and executed using
8085 p kit.

11
2. A. 16 BIT ADDITION USING 8085

AIM:

To add two 16-bit numbers stored at memory locations and display the result.

ALGORITHM:

1. Start the program.


2. Initialize memory pointer to data location.
3. Get the first number from memory and store in Register pair.
4. Get the second number in memory and add it to the Register pair.
5. Store the sum & carry in separate memory locations.
6. Stop the program.

PROGRAM:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


4500 MVI B,00H 06,00 Clear the content of B register

4502 LHLD 5500H 2A,00,55 Load data 1 to HL register

4505 XCHG EB Move the data from HL to DE

4506 LHLD 5502H 2A,02,55 Load data 2 to HL register

4509 DAD D 19 Add the content of HL and DE pair

450A JNC LOOP D2,0E,45 Jump on no carry to specified address

450D INR B 04 Increment the content of B register by 1

450E LOOP SHLD 5504H 22,04,55 Store the result

4511 MOV A,B 78 Move B register content to accumulator

4512 STA 5506H 32,06,55 Store the carry

4515 HLT 76 End the program

OBSERVATION:
INPUT OUTPUT

RESULT:

Thus an ALP program for 16-bit addition was written and executed in 8085 p using special
instructions.

12
2. B. 16 BIT SUBTRACTION USING 8085
AIM:

To subtract two 16-bit numbers stored at consecutive memory locations.

ALGORITHM:

1. Start the program.


2. Initialize memory pointer to data location.
3. Get the subtrahend from memory and transfer it to register pair.
4. Get the minuend from memory and store it in another register pair.
5. Subtract subtrahend from minuend.
6. Store the difference and borrow in different memory locations.
7. Stop the program.
PROGRAM:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


4500 LHLD 5500H 2A,00,55 Load data 1 to HL register
4503 XCHG EB Move the data from HL to DE
4504 LHLD 5502H 2A,02,55 Load data 2 to HL register
4507 MOV A,L 7D Move L register content to accumulator
4508 SUB E 93 Subtract E register content & accumulator
4509 STA 5100H 32,00,51 Store the result
450C MOV A,H 7C Move H register content to accumulator

450D SBB D 9A Subtract D register content & accumulator

450E STA 5101H 32,01,51 Store the result


4511 HLT 76 End the program

OBSERVATION:

INPUT OUTPUT

RESULT:

Thus an ALP program for subtracting two 16-bit numbers was written and executed.

13
2. C. 16 BIT MULTIPLICATION USING 8085
AIM:

To multiply two 16 bit numbers and store the result in memory.

ALGORITHM:

1. Start the program.


2. Get the multiplier and multiplicand.
3. Initialize a register to store partial product.
4. Add multiplicand, multiplier times.
5. Store the result in consecutive memory locations.
6. Stop the program.
PROGRAM:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


4300 LXI B,0003H 01,00,03 Load BC register with 0003
4303 LXI SP,0004H 31,00,04 Load SP register with 0004
4306 LXI D,0000H 11,00,00 Load DE register with 0000
4309 LXI H,0000H 21,00,00 Load HL register with 0000
430C L2 DAD SP 39 Double add SP with accumulator
430D JNC L1 D2,11,43 Jump on no carry to specified address
4310 INX D 13 Increment the DE register by 1
4311 L1 DCX B 0B Decrement the BC register by 1
4312 MOV A,C 79 Move C register content to accumulator
4313 ORA B B0 Perform OR operation between B & A
4314 JNZ L2 C2,0C,43 Jump on no carry to specified address
4317 SHLD 4100H 22,41,00 Store the HL content in 4100
431A XCHG EB Interchange HL & DE pair contents
431B SHLD 4102H 22,02,41 Store the HL content in 4102
431E HLT 76 End the program

OBSERVATION:

INPUT OUTPUT

RESULT:

Thus the 16-bit multiplication was done in 8085 p using repeated addition method.

14
2.D. 16 BIT DIVISION USING 8085
AIM:

To divide two 16-bit numbers and store the result in memory using 8085 mnemonics.

ALGORITHM:
1. Start the program.
2. Get the dividend and divisor.
3. Initialize the register for quotient.
4. Repeatedly subtract divisor from dividend till dividend becomes less than divisor.
5. Count the number of subtraction which equals the quotient.
6. Store the result in memory.
7. Stop the program.

PROGRAM:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


4700 LXI H,0008H 21,08,00 Load HL register with 0008
4703 LXI B,0004H 01,04,00 Load BC register with 0004
4706 LXI D,0000H 11,00,00 Load DE register with 0000
4709 L3 MOV A,H 7C Move H register content to accumulator
Compare B with accumulator and update
470A CMP B B8
carry flag
470B JC L1 DA,1B,47 Jump on carry to specified address
470E JNZ L2 C2,16,47 Jump on zero to specified address
4711 MOV A,L 7D Move L register content to accumulator
Compare C with accumulator and update
4712 CMP C B9
carry flag
4713 JC L1 DA,1B,47 Jump on carry to specified address
4716 L2 DSUB B 08 Double subtract from accumulator
4717 INX D 13 Increment the DE register by 1
4718 JMP L3 C3,09,47 Jump unconditionally to specified address
471B L1 SHLD 4400H 22,00,44 Store the HL content in 4400
471E XCHG EB Interchange HL & DE pair contents
471F SHLD 4402H 22,02,44 Store the HL content in 4402
4722 HLT 76 End the program

OBSERVATION:

INPUT OUTPUT

RESULT:

Thus the 16-bit Division was done in 8085 p using repeated subtraction method.

15
3. A. SORTING IN ASCENDING ORDERUSING 8085
AIM:

To sort the given number in the ascending order using 8085 microprocessor.

ALGORITHM:

1. Start the program.


2. Get the numbers to be sorted from the memory locations.
3. Compare the first 2 numbers and if the 1st number is larger than 2nd then interchange the number.
4. If the first number is smaller, go to step 5.
5. Repeat steps 2 and 3 until the numbers are in required order.
6. Stop the program.

PROGRAM:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


4100 AHEAD MVI B,00 06,00 Clear B register
4102 LXI H,4150 21,50,41 Load data to HL pair
4105 MOV C,M 4E Move data pointed by HL to C register
4106 DCR C 0D Decrement the C register by 1
4107 INX H 23 Increment HL by 1
4108 L2 MOV A,M 7E Move data pointed by HL to A register
4109 INX H 23 Increment the HL register by 1
410A CMP M BE Compare HL content with acc and update C flag
410B JC L1 DA,15,41 Jump on carry to specified address
410E MOV D,M 56 Move data pointed by HL to D register
410F MOV M,A 77 Move A regto memory location pointed by HL
4110 DCX H 2B Decrement the HL register by 1
4111 MOV M,D 72 Move D reg to memory location pointed by HL
4112 INX H 23 Increment the HL register by 1
4113 MVI B,01 06,01 Move 01 to B register
4115 L1 DCR C 0D Decrement C register by 1
4116 JNZ L2 C2,08,41 Jump on no zero to specified address
4119 DCR B 05 Decrement B register by 1
411A JZ AHEAD CA,00,41 Jump on zero to specified address
411D HLT 76 End the program

OBSERVATION:
INPUT OUTPUT

RESULT:
Thus the ascending order program is executed and thus the numbers are arranged in ascending
order.

16
3. B. SORTING IN DESCENDING ORDERUSING 8085
AIM:
To sort the given number in the descending order using 8085 microprocessor.
ALGORITHM:
1. Start the program.
2. Get the numbers to be sorted from the memory locations.
3. Compare the first two numbers and if the first number is smaller than second then
interchange the number.
4. If the first number is larger, go to step 5.
5. Repeat steps 2 and 3 until the numbers are in required order.
6. Stop the program.

PROGRAM:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


4100 AHEAD MVI B,00 06,00 Clear B register
4102 LXI H,4150 21,50,41 Load data to HL pair
4105 MOV C,M 4E Move data pointed by HL to C register
4106 DCR C 0D Decrement the C register by 1
4107 INX H 23 Increment HL by 1
4108 L2 MOV A,M 7E Move data pointed by HL to A register
4109 INX H 23 Increment the HL register by 1
Compare HL content with accumulator
410A CMP M BE
and update carry flag
410B JNC L1 DA,15,41 Jump on no carry to specified address
410E MOV D,M 56 Move data pointed by HL to D register
410F DCX H 2B decrement the HL register by 1
Move D register content to memory
4110 MOV M,D 72
location pointed by HL
4111 INX H 23 Increment the HL register by 1
4112 MVI B,01 06,01 Move 01 to B register
4114 L1 DCR C 0D Decrement C register by 1
4115 JNZ L2 C2,08,41 Jump on no zero to specified address
4118 DCR B 05 Decrement B register by 1
4119 JZ AHEAD CA,00,41 Jump on zero to specified address
411C HLT 76 End the program

OBSERVATION:

INPUT OUTPUT

RESULT:

Thus the descending order program is executed and thus the numbers are arranged in descending
order.

17
4.A. SEARCHING THE SMALLEST NUMBER USING 8085

AIM:
To find the smallest element in an array.
ALGORITHM:
1. Start the program.
2. Place all the elements of an array in the consecutive memory locations.
3. Fetch the first element from the memory location and load it in the accumulator.
4. Initialize a counter (register) with the total number of elements in an array.
5. Decrement the counter by 1.
6. Increment the memory pointer to point to the next element.
7. Compare the accumulator content with the memory content (next element).
8. If the accumulator content is smaller, then move the memory content (largest element) to the
accumulator. Else continue.
9. Decrement the counter by 1 and repeat steps 5 to 8 until the counter reaches zero
10. Store the result (accumulator content) in the specified memory location.
11. Stop the program.
PROGRAM:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


4150 LXI H,4300H 21,00,43 Load data to HL pair
4153 MOV A,M 7E Move data pointed by HL to A register
4154 MVI C,04 0E,04 Move 04 to C register
4156 L2 INX H 23 Increment the HL register by 1
Compare HL content with accumulator and
4157 CMP M BE
update carry flag
4158 JC L1 DA,5C,41 Jump on carry to specified address
415B MOV A,M 7E Move data pointed by HL to A register
415C L1 DCR C OD decrement the C register by 1
415D JNZ L2 C2,56,41 Jump on no carry to specified address
4160 STA 4350 32,50,43 Store the result
4163 HLT 76 End the program

OBSERVATION:

INPUT OUTPUT

RESULT:
Thus the smallest number in the given array is found out.

18
4. B. SEARCHING THE LARGEST NUMBER USING 8085
AIM:
To find the largest element in an array.
ALGORITHM:
1. Start the program.
2. Place all the elements of an array in the consecutive memory locations.
3. Fetch the first element from the memory location and load it in the accumulator.
4. Initialize a counter (register) with the total number of elements in an array.
5. Decrement the counter by 1.
6. Increment the memory pointer to point to the next element.
7. Compare the accumulator content with the memory content (nextelement).
8. If the accumulator content is smaller, then move the memory content(largest element) to the
accumulator. Else continue.
9. Decrement the counter by 1 and repeat steps 5 to 8 until the counter reaches zero
10. Store the result (accumulator content) in the specified memory location.
11. Stop the program.

PROGRAM:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


4150 LXI H,4200H 21,00,42 Load data to HL pair
4153 MOV A,M 7E Move data pointed by HL to A register
4154 MVI C,04 0E,04 Move 04 to C register
4156 L2 INX H 23 Increment the HL register by 1
Compare HL content with accumulator
4157 CMP M BE
and update carry flag
4158 JNC L1 D2,5C,41 Jump on no carry to specified address
415B MOV A,M 7E Move data pointed by HL to A register
415C L1 DCR C OD decrement the C register by 1
415D JNZ L2 C2,56,41 Jump on no carry to specified address
4160 STA 4400 32,00,44 Store the result
4163 HLT 76 End the program

OBSERVATION:
INPUT OUTPUT

RESULT:
Thus the largest number in the given array is found out.

19
5. A. ASCII TO DECIMAL CONVERSION USING 8085
AIM:
To convert the given ASCII value to decimal number.
ALGORITHM:

1. Start the program.


2. Load the immediate data to a register pair
3. Move the content of memory to accumulator
4. Subtract the immediate data 30 from A and store the result in accumulator
5. Compare the data 0A with accumulator.
6. If carry go to step 8 and if no carry go to step 7
7. Move the immediate data FF to accumulator
8. Increment the HL register pair
9. Move the content of accumulator to memory
10. Stop the program.
PROGRAM:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS

4100 LXI H,4150 21,50,41 Load the immediate data to BC register pair

Move the content of memory to


4103 MOV A,M 7E
accumulator
Subtract the immediate data 30 from A and
4104 SUI 30 DE,30
store the result in accumulator
Compare the immediate data with
4106 CPI 0A FE,0A
accumulator

4108 JC L1 DA,0D,41 Jump on carry to loop L1

410B MVI A,FF 3E,FF Move the immediate data FF to accumulator

410D L1 INX H 23 Increment the HL register pair

Move the content of accumulator to


410E MOV M,A 77
memory

410F HLT 76 End the program

OBSERVATION:

INPUT OUTPUT

RESULT:
Thus an ALP program for conversion of ASCII to decimal was written and executed.

20
5. B. BCD TO HEXA CONVERSION USING 8085

AIM:
To convert the given BCD value to Hexadecimal number.
ALGORITHM:
1. Start the program.
2. Load the immediate data to BC register pair
3. Move the content of memory to accumulator
4. Add the content of A with A and store the result in accumulator
5. Move the content of accumulator to B register
6. Add the content of A with A and store the result in accumulator
7. Add the content of A with A and store the result in accumulator
8. Add the content of B register with A and store the result in accumulator
9. Increment the HL register pair
10. Add the content of memory with A and store the result in accumulator
11. Increment the HL register pair and move the content of accumulator to memory
12. Stop the program
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS
4100 LXI H,4150 21,50,41 Load the immediate data to BC register pair
4103 MOV A,M 7E Move the content of memory to accumulator
Add the content of A with A and store the result
4104 ADD A 87
in accumulator
4105 MOV B,A 47 Move the content of accumulator to B register
Add the content of A with A and store the result
4106 ADD A 87
in accumulator
Add the content of A with A and store the result
4107 ADD A 87
in accumulator
Add the content of B register with A and store
4108 ADD B 80
the result in accumulator
4109 INX H 23 Increment the HL register pair
Add the content of memory with A and store the
410A ADD M 86
result in accumulator
410B INX H 23 Increment the HL register pair
410C MOV M,A 77 Move the content of accumulator to memory
410D HLT 76 End the program

OBSERVATION:
INPUT OUTPUT

RESULT:
Thus an ALP program for conversion of BCD value to Hexadecimal number was written and
executed.
21
6. A INTERFACING A/D AND D/A CONVERTER WITH 8085

AIM:

To write an assembly language program to convert an analog signal into a digital signal
and a digital signal into an analog signal using an ADC interfacing and DAC interfacing
respectively.
ADC INTERFACING WITH 8085
PROBLEM STATEMENT:
To program starts from memory location 4100H. The program is executed for various
values of analog voltage which are set with the help of a potentiometer. The LED display is
verified with the digital value that is stored in the memory location 4150H.
THEORY:
An ADC usually has two additional control lines: the SOC input to tell the ADC when
to start the conversion and the EOC output to announce when the conversion is complete. The
following program initiates the conversion process, checks the EOC pin of ADC 0419 as to
whether the conversion is over and then inputs the data to the processor. It also instructs the
processor to store the converted digital data at RAM 4200H.
ALGORITHM:
1. Select the channel and latch the address.
2. Send the start conversion pulse.
3. Read EOC signal.
4. If EOC =1 continue else go to step (3)
5. Read the digital output.
6. Store it in a memory location.

ADC CIRCUIT:

22
PROGRAM:

DAC INTERFACINGWITH 8085

(a) SQUARE WAVE GENERATION:

The basic idea behind the generation of waveforms is the continuous generation of
Analog output of DAC. With 00(HEX) as input to DAC2, the analog output is -5V.
Similarly, with FF (Hex) as input, the output is +5V. Outputting digital data 00 and FF at
regular intervals, to DAC2, results in a square wave of amplitude I5 Volts

23
ALGORITHM:
1. Load the initial value (00) to Accumulator and move it to DAC.
2. Call the delay program
3. Load the final value (FF) to accumulator and move it to DAC.
4. Call the delay program.
5. Repeat steps 2 to 5.
PROGRAM:

(b) SAW TOOTH GENERATION:


ALGORITHM:
1. Load the initial value (00) to Accumulator
2. Move the accumulator content to DAC.
3. Increment the accumulator content by 1.
4. Repeat steps 3 and 4.
Output digital data from 00 to FF constant steps of 01 to DAC1 repeat this sequence again and
again. As a result a saw – tooth wave will be generated at DAC1 output.
PROGRAM:

24
(c) TRIANGULAR WAVE GENERATION:
ALGORITHM:
1. Load the initial value (00) to Accumulator.
2. Move the accumulator content to DAC
3. Increment the accumulator content by 1.
4. If accumulator content is zero proceed to next step. Else go to step 3.
5. Load value (FF) to accumulator.
6. Move the accumulator content to DAC.
7. Decrement the accumulator content by 1.
8. If accumulator content is zero go to step 2. Else go to step 2.
The following program will generate a triangular wave at DAC2 output.
PROGRAM:

DAC CIRCUIT:

25
WAVEFORMS:

OBSERVATION:

RESULT:
Thus the conversion of an analog signal into a digital signal and a digital signal into an
analog signal was done using interfacing of ADC and DAC respectively with 8085.

26
7.B TRAFFIC LIGHT CONTROLLER WITH 8085

AIM
To write an assembly language program to simulate the traffic light at an intersection
using a traffic light interface.
ALGORITHM:
1. Initialize the ports.
2. Initialize the memory content, with some address to the data.
3. Read data for each sequence from the memory and display it through the ports.
4. After completing all the sequences, repeat from step2.
A SAMPLE SEQUENCE:
1. (a) Vehicles from south can go to straight or left.
(b) Vehicles from west can cross the road.
(c) Each pedestrian can cross the road.
(d) Vehicles from east no movement.
(e) Vehicles from north, can go only straight.
2. All ambers are ON, indicating the change of sequence.
3. (a) Vehicles from east can go straight and left.
(b) Vehicles from south, can go only left.
(c) North pedestrian can cross the road.
(d) Vehicles from north, no movement.
(e) Vehicles from west, can go only straight.
4. All ambers are ON, indicating the change of sequence.
5. (a) Vehicles from north can go straight and left.
(b) Vehicles from east, can go only left.
(c) West pedestrian can cross the road.
(d) Vehicles from west, no movement.
(e) Vehicles from south, can go only straight.
6. All ambers are ON, indicating the change of sequence.
7. (a) Vehicles from west can go straight and left.
(b) Vehicles from north, can go only left.
(c) South pedestrian can cross the road.
(d) Vehicles from south, no movement.
(e) Vehicles from east, can go only straight.
8. All ambers are ON, indicating the change of sequence.

27
9. (a) All vehicles from all directions no movement.
(b) All pedestrian can cross the road.
BIT ALLOCATION:

PATH REPRESENTATION:

28
29
30
RESULT:
Thus an assembly language program to simulate the traffic light at an intersection using a
traffic light interfaces was written and implemented.

31
8051 MICROCONTROLLER

32
9A. 8-BIT ADDITION

AIM:

To write a program to add two 8-bit numbers using 8051 microcontroller and also to
verify the result.
APPARATUS REQUIRED:

8051 microcontroller kit ,key board.

ALGORITHM:

1. Clear Program Status Word.


2. Select Register bank by giving proper values to RS1 & RS0 of PSW.
3. Load accumulator A with any desired 8-bit data.
4. Load the register R 0 with the second 8- bit data.
5. Add these two 8-bit numbers.
6. Store the result.
7. Stop the program.
PROGRAM:

ADDRESS LABEL MNEMONIC OPERAND HEX CODE COMMENTS


4100 CLR C Clear CY Flag

4101 MOV A, data1 Get the data1 in


Accumulator
4103 ADDC A, # data 2 Add the data1 with
data2
4105 MOV DPTR, # Initialize the memory
4500H location
4108 MOVX @ DPTR, A Store the result in
memory location
4109 L1 SJMP L1 Stop the program

33
OBSERVATION:

OUTPUT
MEMORY LOCATION DATA

Data1: 08,data2: 07 4500 0F

RESULT:

Thus the 8051 ALP for addition of two 8 bit numbers is executed and the result is
verified.

34
9.B. 8-BIT SUBTRACTION

AIM:

To perform subtraction of two 8 bit data using the 8051 microcontroller and store the
result in memory.
APPARATUS REQUIRED:

8051 microcontroller kit ,key board.

ALGORITHM:

1. Clear the carry flag.


2. Initialize the register for borrow.
3. Get the first operand into the accumulator.
4. Subtract the second operand from the accumulator.
5. If a borrow results increment the carry register.
6. Store the result in memory.

PROGRAM:

ADDRESS LABEL MNEMONIC OPERAND HEXCODE COMMENTS


4100 CLR C Clear CY flag

4101 MOV A, # data1 Store data1 in


accumulator
4103 SUBB A, # data2 Subtract data2 from
data1
4105 MOV DPTR, # 4500 Initialize memory
location
4108 MOVX @ DPTR, A Store the difference
in memory location
4109 L1 SJMP L1 Stop

35
OBSERVATION:

OUTPUT
MEMORY LOCATION DATA

Data 1,2 : 08,07 4500 01

RESULT:

Thus the 8051 ALP for subtraction of two 8 bit numbers is executed and the result is
verified.

36
9.C. 8-BIT MULTIPLICATION
AIM:

To perform multiplication of two 8 bit data using 8051 microcontroller and to store the
result in memory.
APPARATUS REQUIRED:

8051 microcontroller kit ,key board.

ALGORITHM:

1. Get the multiplier in the accumulator.


2. Get the multiplicand in the B register.
3. Multiply A with B.
4. Store the product in memory.

PROGRAM:

ADDRESS LABEL MNEMONIC OPERAND HEX CODE COMMENTS


4100 MOV A ,#data1 Store data1 in
accumulator
4102 MOV B, #data2 Store data2 in B reg

4104 MUL A,B Multiply both

4106 MOV DPTR, # 4500H Initialize memory


location
4109 MOVX @ DPTR, A Store lower order
result
401A INC DPTR Go to next memory
location
410B MOV A,B
Store higher order
410D MOV @ DPTR, A result

410E STOP SJMP STOP Stop

Data1:04
Data 2:02

37
OBSERVATION:

OUTPUT
MEMORY LOCATION DATA
4500 08
4501 00

RESULT:

Thus the 8051 ALP for multiplication of two 8 bit numbers is executed and the result is
verified.

38
9.D. 8-BIT DIVISION
AIM:

To perform division of two 8 bit data using 8051 microcontroller and to store the result in
memory.
APPARATUS REQUIRED:

8051 microcontroller kit ,key board.

ALGORITHM:

1. Get the Dividend in the accumulator.


2. Get the Divisor in the B register.
3. Divide A by B.
4. Store the Quotient and Remainder in memory.

PROGRAM:

ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS


CODE
4100 MOV A, # data1 Store data1 in
accumulator
4102 MOV B, # data2 Store data2 in B reg

4104 DIV A,B Divide

4015 MOV DPTR, # 4500H Initialize memory


location
4018 MOVX @ DPTR, A Store remainder

4109 INC DPTR Go to next memory


location
410A MOV A,B
Store quotient
410C MOV @ DPTR, A

410D STOP SJMP STOP Stop

Data 1: 08
Data 2 :02

39
OBSERVATION:

OUTPUT
MEMORY LOCATION DATA
4500 (remainder) 00
4501 (quotient) 04

RESULT:

Thus the 8051 ALP for division of two 8 bit numbers is executed and the result is
verified.

40
10.A. INCREMENT / DECREMENT OPERATION

AIM:

Writing an assembly language program to demonstrate the increment and decrement operations using the
8051 microcontroller.

APPARATUS REQUIRED:

8051 microcontroller kit ,key board.


.
ALGORITHM

1. Start.
2. Initialize a register (e.g., register A) with an initial value of 0.
3. Implement a loop to continuously increment the register value until it reaches the maximum value of
20.
4. Within the loop:
• Use the INC instruction to increment the register value by 1.
• Perform desired operations with the incremented value.
5. Check if the register value has reached the maximum value of 20 using conditional branching
instructions.
6. If the maximum value is reached, implement a loop to continuously decrement the register value
until it reaches the minimum value of 0.
7. Within the loop:
• Use the DEC instruction to decrement the register value by 1.
• Perform desired operations with the decremented value.
8. Repeat the process indefinitely to create a continuous loop.
9. .Stop.
PROGRAM:

Memory Address Opcode Label Mnemonics Comments


0000H 74 00 START MOV A, #00H Initialize
register A with
00H

41
0002H 04 LOOP_INCREMENT INC A Increment the
value of A
0003H ; Perform operation with A
0004H B4 FD 14 CJNE A, #14H, Continue
LOOP_INCREMENT looping until A
reaches 14H

0007H 05 LOOP_DECREMENT DEC A Decrement the


value of A
0008H ; Perform operation with A
0009H B4 F9 00 CJNE A, #00H, Continue
LOOP_DECREMENT looping until A
reaches 00H
000CH 80 F3 SJMP START Jump back to
the start of the
program

OUTPUT:

MEMORY INPUT VALUES MEMORY OUTPUT VALUES


ADDRESS ADDRESS

0000H - 0000H 00H

0002H 00H 0002H 01H

0004H 01H 0004H 02H

... ... ... ...

0007H 14H 0007H 14H

0009H 13H 0009H 13H

000CH 12H 000CH 12H

- - - -

RESULT:

42
The output values correspond to the incremented and decremented values of register A in
the 8051 microcontroller program, with the initial input value being 00H and the maximum
value being 14H.The output was verified.

10.B. ASCENDING / DESCENDING OPERATION


AIM:

To demonstrate ascending and descending operations using the 8051 microcontroller.

APPARATUS REQUIRED:

8051 microcontroller kit ,key board.

ALGORITHM

1. Start.
2. Initialize register A with 00H and register B with 01H.
3. Implement a loop for ascending operation:
• Increment the value of register A by 1.
• Perform desired operations with register A if needed.
• Continue the loop until register A reaches 20H.
4. Implement a loop for descending operation:
• Decrement the value of register A by 1.
• Perform desired operations with register A if needed.
• Continue the loop until register A reaches 00H.
5. Repeat the process indefinitely.
6. Stop.

PROGRAM:

MEMORY OPCODE LABEL MNEMONICS COMMENTS


ADDRESS
0000H START Entry point of the program
0000H 74 00 MOV A, #00H Initialize register A with 00H
0002H 74 01 MOV B, #01H Initialize register B with 01H
LOOP_AS
0004H 01 AJMP ASCENDING Jump to ascending loop
C

ASCENDI
0005H Ascending loop label
NG
0005H 05 INC A Increment value of A
Perform operations with A if
0006H
needed

43
CJNE A, #20H, Continue loop until A reaches
0007H B4 FB 05
ASCENDING 20H
LOOP_DE AJMP
000AH 02 Jump to descending loop
SC DESCENDING
DESCEND
000BH Descending loop label
ING
000BH 05 DEC A Decrement value of A
Perform operations with A if
000CH
needed
CJNE A, #00H, Continue loop until A reaches
000DH B4 F8 0BH
DESCENDING 00H
Jump back to the start of the
0010H 80 F4 SJMP START
program

OUTPUT:

MEMORY INPUT VALUES MEMORY OUTPUT VALUES


ADDRESS ADDRESS
0000H - 0000H 00H

0002H 00H 0002H 01H

0004H 01H 0005H 02H

... ... ... ...

0010H 19H 0010H 18H

 Memory Address" column represents the memory address where the input or output value is stored.
 "Input Values" column represents the values of register A before any operation is performed.
 "Memory Address" column represents the memory address where the next operation takes place.
 "Output Values" column represents the values of register A after the operation is performed.

RESULT:

The program effectively performs ascending and descending operations, incrementing


from 00H to 20H and then decrementing back to 00H.And the output was verified.

44
10.C. MAXIMUM / MINIMUM NUMBERS OPERATION

AIM:

To demonstrate program and determine the maximum and minimum numbers among the
given input values using the 8051 microcontroller.

APPARATUS REQUIRED:

8051 microcontroller kit ,key board.

ALGORITHM

1. Start the program.

2. Initialize register A with 00H to store the maximum value.

3. Initialize register B with 01H to store the minimum value.

4. Load register A with the value from register R7 to find the maximum number.

5. Move the value from register A to register R7.

6. Move the value from register R7 to the program status word (PSW).

7. Jump to the end of the program.

8. Load register A with the value from register R7 to find the minimum number.

9. Move the value from register A to register R7.

10. Move the value from register R7 to the program status word (PSW).

11. End the program.


PROGRAM:

MEMORY OPCODE LABEL MNEMONICS COMMENTS


ADDRESS
0000H START Entry point of the program

0000H 74 00 MOV A, #00H Initialize register A with 00H

0002H 74 01 MOV B, #01H Initialize register B with 01H


LOOP_MA Load register A with register
0004H 7F MOV A, R7
X R7
Move value from register A to
0005H FE MOV R7, A
R7
Move value from register R7 to
0006H 8D MOV R7, PSW
PSW
45
0007H 02 AJMP END Jump to end of program

0008H
LOOP_MI Load register A with register
0009H 7F MOV A, R7
N R7
Move value from register A to
000AH FE MOV R7, A
R7
Move value from register R7 to
000BH 8C MOV PSW, R7
PSW
000CH END End of program

This table represents an assembly language program for the 8051 microcontroller that demonstrates
maximum and minimum number operations. The program initializes register A with 00H and register B with
01H, then loads register A with register R7 for maximum number operation and loads register A with register
R7 for minimum number operation. Finally, it ends the program.

OUTPUT:

MEMORY INPUT VALUES MEMORY OUTPUT VALUES


ADDRESS ADDRESS

0000H - 0000H 00H

0002H 00H 0002H 01H

0004H MAX_VALUE 0007H MAX_VALUE

0008H MIN_VALUE 000CH MIN_VALUE

 Memory Address" column represents the memory address where the input or output value is stored.
 "Input Values" column represents the values of registers or memory locations before any operation is
performed.
 "Memory Address" column represents the memory address where the next operation takes place.
 "Output Values" column represents the values of registers or memory locations after the operation is
performed.
RESULT:
The program effectively determines the maximum and minimum values among the provided input values
using the 8051 microcontroller.

46
10.D. ROTATE INSTRUCTIONS

AIM:

To demonstrate rotate instructions (RLC and RRC) using the 8051 microcontroller.
APPARATUS REQUIRED:

8051 microcontroller kit ,key board.

ALGORITHM

1. Start the program.

2. Load accumulator A with the value 55H.

3. Load register B with the value 03H.

4. Perform rotate operations label.

5. Rotate accumulator left through carry (RLC).

6. Perform additional operations if needed.

7. Decrement register B.

8. Load accumulator A with the value 05H.

9. Rotate accumulator right through carry (RRC).

10. Perform additional operations if needed.

11. End the program.

PROGRAM:

MEMORY OPCODE LABEL MNEMONICS COMMENTS


ADDRESS
0000H START Entry point of the program

0000H 74 55H MOV A, #55H Load accumulator with 55H

0002H 74 03H MOV B, #03H Load register B with 03H

0004H ROTATE Rotate operations label


Rotate accumulator left
0004H 03 RLC A
through carry
Perform additional operations
0005H
if needed
0006H 1B DEC B Decrement register B

47
0007H 74 05H MOV A, #05H Load accumulator with 05H
Rotate accumulator right
0009H 01 RRC A
through carry
Perform additional operations
000AH
if needed
000BH END End of program

This table represents an assembly language program for the 8051 microcontroller that demonstrates rotate
instructions. The program loads accumulator A with 55H and register B with 03H, then performs rotate left
through carry (RLC) operation on accumulator A and rotate right through carry (RRC) operation on
accumulator A. Finally, it ends the program.

OUTPUT:

MEMORY INPUT VALUES MEMORY OUTPUT VALUES


ADDRESS ADDRESS

0000H - 0000H 55H

0002H - 0002H 03H

0004H 55H 0004H EAH

0006H 03H 0007H 05H

0007H EAH 0007H D5H

0009H 05H 000AH 82H

 Memory Address" column represents the memory address where the input or output value is stored.
 "Input Values" column represents the values of registers or memory locations before any operation is
performed.
 "Memory Address" column represents the memory address where the next operation takes place.
 "Output Values" column represents the values of registers or memory locations after the operation is
performed.
RESULT:
The program successfully performs rotate left through carry (RLC) and rotate right through carry (RRC)
operations on given input values using the 8051 microcontroller.

48
10.E. Hex / ASCII / BCD code .
AIM:

To demonstrate hex to ASCII conversion using the 8051 microcontroller ,and also to verify the
result.
APPARATUS REQUIRED:

8051 microprocessor kit ,key board

ALGORITHM:
1. Start the program.

2. Load accumulator A with the hexadecimal value 41H.

3. Initialize ASCII value '0' in accumulator A.

4. Move the value from accumulator A to register R5.

5. Begin the loop for conversion.

6. Subtract the hexadecimal value 0AH from accumulator A.

7. Decrement register R5 and jump back to the loop if it's not zero.

8. End the program.

PROGRAM:

ADDRESS OPCODE LABEL MNEMONICS OPERAND COMMENT


000H START Entry point of the program
Load accumulator with hex
0000H 74 41H MOV A, #41H #41H
value 41H
HEX_TO_ Hex to ASCII conversion
0002H
ASC label
Load accumulator with
0002H E5 MOV A, '0' '0'
ASCII value '0'
Move value from
0003H F5 MOV R5, A A
accumulator to R5

0004H 24 LOOP Loop for conversion

Subtract 0AH from


0005H 93 SUBB A, #0AH #0AH
accumulator A
Decrement R5 and jump if
0006H D5 DJNZ R5, LOOP LOOP
not zero

49
0007H END End of program

OUTPUT:

MEMORY INPUT VALUES MEMORY OUTPUT VALUES


ADDRESS ADDRESS

0000H - 0000H 41H

0002H - 0002H '0'

0004H 41H 0004H 'A'

0006H '0' 0007H 'A'

In this table:

 The "Input Values" column represents the initial values present in memory or registers before any operation is
performed.
 For this particular program, the input value is the hexadecimal value '41H' stored in memory location 0004H.
 The "Output Values" column represents the values after the specified operations are executed. In this case, it's
the ASCII representation of the input value, which is 'A' stored in memory location 0006H.

Result :

The program successfully converts the hexadecimal value '41H' to its corresponding ASCII
representation 'A' using the 8051 microcontroller and also the result is verified.

50
10.F. BCD code Conversion .
AIM:

To demonstrate BCD to binary conversion using the 8051 microcontroller also to verify the
result.
APPARATUS REQUIRED:

8051 microprocessor kit ,key board

ALGORITHM:
9. Start the program.

10. Load accumulator A with the hexadecimal value 41H.

11. Initialize ASCII value '0' in accumulator A.

12. Move the value from accumulator A to register R5.

13. Begin the loop for conversion.

14. Subtract the hexadecimal value 0AH from accumulator A.

15. Decrement register R5 and jump back to the loop if it's not zero.

16. End the program.

PROGRAM:

ADDRESS OPCODE LABEL MNEMONICS OPERAND COMMENT


0000H START Entry point of the program
Load accumulator with BCD
0000H 74 78H MOV A, #78H #78H value 78H
BCD_TO_BI
0002H N BCD to binary conversion label

Move value from accumulator to


0002H F5 MOV R5, A R5
0003H 24 LOOP Loop for conversion

Rotate accumulator right


0004H 06 RRC A through carry
0005H 1B DEC R3 Decrement register R3
DJNZ R3, Decrement R3 and jump if not
0006H D5 LOOP LOOP zero

0007H END End of program

51
OUTPUT:

MEMORY INPUT VALUES MEMORY OUTPUT VALUES


ADDRESS ADDRESS

0000H - 0000H -

0002H - 0002H -

0004H 78H 0004H ECH

0006H - 0006H -

In this table:

 The "Memory Address" column represents the memory address where the input or output value is stored.
 The "Input Values" column represents the initial values present in memory or registers before any operation is
performed. In this case, there are no input values specified.
 The "Output Values" column represents the values of registers or memory locations after the operation is
performed. In this case, it represents the output values after the BCD to binary conversion operation.

Result :

The program successfully converts the BCD value 78H to its binary representation.

52
11.A. INTERFACING STEPPER MOTOR CONTROL USING 8051

AIM:
To interface a stepper motor with 8051 microcontroller and operate it.

THEORY:

A motor in which the rotor is able to assume only discrete stationary angular position is a
stepper motor. The rotary motion occurs in a step-wise manner from one equilibrium position to the
next. Stepper Motors are used very wisely in position control systems like printers, disk drives, process
control machine tools, etc.
The basic two-phase stepper motor consists of two pairs of stator poles. Each of the four poles
has its own winding. The excitation of any one winding generates a North Pole. A South Pole gets
induced at the diametrically opposite side. The rotor magnetic system has two end faces. It is a
permanent magnet with one face as South Pole and the other as North Pole.
The Stepper Motor windings A1, A2, B1, and B2 are cyclically excited with a DC current to run
the motor in clockwise direction. By reversing the phase sequence as A1, B2, A2, B1, anticlockwise
stepping can be obtained.
BLOCK DIAGRAM:

2-PHASE SWITCHING SCHEME:


In this scheme, any two adjacent stator windings are energized. The switching scheme is shown
in the table given below. This scheme produces more torque.

ANTICLOCKWISE CLOCKWISE

STEP A1 A2 B1 B2 DATA STEP A1 A2 B1 B2 DATA


1 1 0 0 1 9h 1 1 0 1 0 Ah
2 0 1 0 1 5h 2 0 1 1 0 6h
3 0 1 1 0 6h 3 0 1 0 1 5h
4 1 0 1 0 Ah 4 1 0 0 1 9h

53
ADDRESS DECODING LOGIC:
The 74138 chip is used for generating the address decoding logic to generate the device select
pulses; CS1 & CS2 for selecting the IC 74175.The 74175 latches the data bus to the stepper motor
driving circuitry.
Stepper Motor requires logic signals of relatively high power. Therefore, the interface circuitry that
generates the driving pulses uses silicon Darlington pair transistors. The inputs for the interface circuit are
TTL pulses generated under software control using the Microcontroller Kit. The TTL levels of pulse
sequence from the data bus are translated to high voltage output pulses using a buffer 7407 with open
collector.

PROCEDURE:

Enter the above program starting from location 4100.and execute the same. The stepper motor
rotates. Varying the count at R4 and R5 can vary the speed. Entering the data in the look-up TABLE in the
reverse order can vary direction of rotation.

54
PROGRAM:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS

4100 START MOV DPTR,#4500H 90,45,00 Port to DP location

4103 MOV R0,#04H 78,04 Move 04 to R0 Register


Move data from DP to
4105 J0 MOVX A,@DPTR E0
accumulator
4106 PUSH DPH C0,83

4108 PUSH DPL C0,82

410A MOV DPTR,#FFC0H 90,FF,C0 Move data to DPTR

410D MOV R2,#04H 7A,01 Move data to R2 register

410F MOV R1,#FFH 79,22 Move data to R1 register

4111 DLY 1 MOV R3,#FFH DB,FF

4113 DLY DJNZ R3,DLY DB,FE

4115 DJNZ R1,DLY1 D9,FC

4117 DJNZ R2,DLY1 DA,FA


Move the data from accumulator
4119 MOV @DPTR,A F0
to DPTR
411A POP DPL D0,82

411C POP DPH D0,83

411E INC DPTR A3 Increment the DPTR

411F DJNZ R0, J0 D8,E4

4121 SJMP START 80,DD


4123 END
39
LOOKUP TABLE

CLOCK WISE DIRECTION ANTI CLOCK WISE DIRECTION

ADDRESS OPCODE ADDRESS OPCODE


09 0A
4500 4500
05 06
4501 4501
06 05
4502 4502
0A 09
4503 4503

RESULT:

Thus a stepper motor was interfaced with 8051 and run in forward and reverse directions at
various
speeds.

40
11.B. INTERFACING DAC WITH 8051

AIM:
To interface DAC with 8051 to demonstrate the generation of square wave, triangular
wave and sawtooth wave
APPARATUS REQUIRED:

8051 microcontroller kit ,key board.


APPARATUS REQUIRED:
8051 Trainer Kit, DAC interface board

ALGORITHM:

SQUARE WAVE GENERATION:


1. Move the port address of DAC to DPTR
2. load the initial value 00 TO accumulator and move it to DAC
3. CALL THE DELAY PROGRAM
4. Load the final value FF to accumulator and move it to DAC
5. Call the delay program
6. Repeat steps 2 to 5
SAWTOOTH WAVE GENERATION:
1. Move the port address of DAC to DPTR
2. Load the initial value 00 TO accumulator
3. Move the accumulator content to DAC
4. Increment the accumulator content by 1.
5. Repeat Steps 3 and 4
TRIANGULAR WAVE GENERATION
1. Move the port address of DAC to DPTR
2. Load the initial value (00) to Accumulator
3. Move the accumulator content to DAC
4. Increment the accumulator content by 1.
5. If accumulator content is zero proceed to next step. Else go to step 3.

41
WAVEFORMS:

PROGRAM:

(A) Square Wave Generation

Address Label Mnemonics Opcode Comments


ORG 4100H

MOV DPTR,PORT MOV DPTR,PORT


ADDRESS OF DAC

4100 START MOV A,#00 Clear Accumulator


4102 MOVX @DPTR,A Move A DPTR
4103 LCALL DELAY Call delay

4104 MOV A,#FF Load FF A

4106 MOVX @DPTR,A Move A DPTR

42
4107 LCALL DELAY Call delay

410A LJUMP START Jump to start

410D DELAY: MOV R1,#05

410F LOOP: MOV R2,#FF

4111 HERE: DJNZ R2,HERE


Delay loop
4114 DJNZ R1,LOOP

4117 RET Return and jump to start

4118 SJMP START

(B) Saw tooth Wave Generation

Address Label Mnemonics Opcode Comments


ORG 4100H

MOV DPTR,PORT MOV DPTR,PORT


ADDRESS OF DAC
4100 START MOV A,#00 Clear Accumulator
4103 LOOP MOVX @DPTR,A Move A DPTR
4105 INC A Increment A
SJMP LOOP Jump to location loop

(C) Triangular Wave Generation


Address Label Mnemonics Opcode Comments
ORG 4100H

MOV DPTR,PORT MOV DPTR,PORT


ADDRESS OF DAC
4100 START MOV A,#00 Clear Accumulator
4102 LOOP1 MOVX @DPTR,A Move A DPTR
4103 INC A Increment A

4104 JNZ LOOP1 Jump not zero to location


loop1

43
4107 MOV A,#FF Load FF A

4109 LOOP2: MOVX @DPTR,A Move A DPTR

410A DEC A Decrement A

410B JNZ LOOP2 Jump not zero to location


loop2
411E LJMP START
Delay loop

RESULT:

Thus the square, triangular and saw tooth wave form were generated by interfacing
DAC with 8051 trainer kit.

44
11.C. TRAFFIC LIGHT CONTROLLER - INTERFACING WITH 8051
AIM:
To design traffic light controller using 8051 microcontroller

APPARATUS REQUIRED:

8051 kit, DC regulated power supply, Traffic light controller interface board.
PROGRAM:
ADDRESS OPCODES LABEL MNEMONICS OPERAND COMMENTS
0000H START Entry point of the program
Initialize GPIO ports for traffic
0000H
lights
Load accumulator with initial
0000H 74 FFH MOV A, #FFH #FFH
signal
Move accumulator data to
0002H 8E MOV P1, A
GPIO port P1
0003H Loop for traffic light sequence
0003H RED_ON Red light ON
Load accumulator with red
0003H 74 80H MOV A, #80H #80H
light signal
Move accumulator data to
0005H 8E MOV P1, A
GPIO port P1
0006H Delay for red light
(Implement appropriate delay
0006H
subroutine)
YELLOW
0010H Yellow light ON
_ON
Load accumulator with yellow
0010H 74 40H MOV A, #40H #40H
light signal
Move accumulator data to
0012H 8E MOV P1, A
GPIO port P1
0013H Delay for yellow light
(Implement appropriate delay
0013H
subroutine)
GREEN_
0018H Green light ON
ON
Load accumulator with green
0018H 74 20H MOV A, #20H #20H
light signal
Move accumulator data to
001AH 8E MOV P1, A
GPIO port P1
001BH Delay for green light
(Implement appropriate delay
001BH
subroutine)
0020H 1B DEC R3 Decrement loop counter
Jump back to loop until
0021H D5 DJNZ R3, LOOP LOOP
counter is zero
45
This table outlines an assembly language program for a traffic light controller interfaced with the 8051
microcontroller. It initializes the GPIO ports for the traffic lights, sequences through the red, yellow, and
green lights with appropriate delays, and repeats the sequence for a specified number of times before ending
the program.
ALGORITHM:-
1. Start.
2. Initialize the GPIO ports for the traffic lights.
3. Set the initial signal to activate all the lights (e.g., FFH).
4. Enter a loop for the traffic light sequence.
5. Turn on the red light.
6. Wait for a predetermined time (e.g., delay for red light).
7. Turn off the red light.
8. Turn on the yellow light.
9. Wait for a predetermined time (e.g., delay for yellow light).
10. Turn off the yellow light.
11. Turn on the green light.
12. Wait for a predetermined time (e.g., delay for green light).
13. Turn off the green light.
14. Decrement a loop counter.
15. If the loop counter is not zero, jump back to step 4 to repeat the sequence.
16. End the program.

OUTPUT:

MEMORY INPUT VALUES MEMORY OUTPUT VALUES


ADDRESS ADDRESS
0000H N/A 0000H Red light ON

0003H N/A 0003H Red light ON

0010H N/A 0010H Yellow light ON

0018H N/A 0018H Green light ON

46
0022H N/A 0022H End of program

This table represents the sequence of traffic light signals outputted by the program at different memory
addresses during its execution. The input values column is not applicable (N/A) as there are no explicit
input values in this scenario.

RESULT:
The program effectively controls the sequence of traffic lights, simulating a traffic light system using
8051 microcontroller .

47
12 . DISPLAYING A MOVING/ ROLLING MESSAGE USING 8051
AIM:
To display a moving/rolling message "WELCOME" using the 8051 microcontroller.

APPARATUS REQUIRED:

8051 kit, DC regulated power supply, Traffic light controller interface board.
PROGRAM:
ADDRESS OPCODES LABEL MNEMONICS OPERAND COMMENTS
0000H START Entry point of the program
Initialize memory locations for
0000H
message
Load accumulator with ASCII
0000H 74 57H MOV A, #57H #57H
code for 'W'
Initialize starting position on
0002H 75 00H MOV P0, #00H #00H
display
Loop for displaying the moving
0004H LOOP
message
Move current display position to
0004H E6 MOV A, P0
A
Move character from A to
0005H F6 MOV @R0, A
current display
0006H 04 INC A Increment display position
0007H 75 F0H MOV P0, #F0H #F0H Move display position leftwards
0009H A3 INC R0 Increment memory pointer
Check if end of message, skip if
000AH B4 07H CJNE R0, #07H, SKIP #07H
not
000CH 80 F6H SJMP LOOP Jump back to loop
000EH SKIP Skip point if end of message
Reset memory pointer to
000EH A3 MOV R0, #00H #00H
beginning
0010H END End of program

This table outlines an assembly language program for displaying a moving/rolling message "WELCOME" using
the 8051 microcontroller. It initializes the memory locations with the characters of the message, then
continuously moves the message across the display.

ALGORITHM:-
1. Start.
2. Initialize the memory locations with the ASCII codes for each character of the message "WELCOME".
3. Set the starting position on the display to the first character of the message.
4. Enter a loop to continuously display the moving message.
5. Move the current display position to the accumulator.
48
6. Move the character from the memory location pointed by the memory pointer to the current display
position.
7. Increment the display position to move the message.
8. Move the display position leftwards to create the effect of a moving message.
9. Increment the memory pointer to point to the next character of the message.
10. Check if the end of the message has been reached.
11. If not, repeat the loop by jumping back to step 4.
12. If the end of the message has been reached, reset the memory pointer to the beginning of the message.
13. End the program.

OUTPUT:

MEMORY INPUT VALUES MEMORY OUTPUT VALUES


ADDRESS ADDRESS

0000H "WELCOME" 0000H "ELCOMEW"

0002H "WELCOME" 0002H "LCOMEWE"

0004H "WELCOME" 0004H "COMEWEL"

0006H "WELCOME" 0006H "OMEWELC"

0008H "WELCOME" 0008H "MEWELCO"

000AH "WELCOME" 000AH "EWELCOM"

RESULT:
The program successfully displays the message "WELCOME" in a rolling fashion on the display using
8051 microcontroller .

49
13 . PROGRAMMING PIC ARCHITECTURE WITH SOFTWARE TOOLS.

Aim:
To create an assembly language program for a PIC microcontroller using MPLAB X IDE that blinks an
LED connected to pin RB0 in a continuous loop.

APPARATUS REQUIRED:

1. PIC microcontroller (such as PIC16F877A)


2. LED
3. Current-limiting resistor (if needed)
4. Breadboard
5. Connecting wires
6. Power supply or battery pack
7. MPLAB X IDE software (for programming the PIC microcontroller)
8. PICkit programmer (for programming the microcontroller)
9. Computer or laptop for running MPLAB X IDE and programming the microcontroller.

ALGORITHM
1. Initialize the microcontroller and configure the I/O pins.
2. Set the direction of the pin connected to the LED as output.
3. Enter a loop to continuously toggle the state of the LED.
4. Turn the LED on by setting the corresponding pin high.
5. Implement a delay to control the blinking rate.
6. Turn the LED off by setting the pin low.
7. Implement another delay.
8. Repeat the loop indefinitely.

PROGRAM:
ADDRESS OPCODES LABEL MNEMONICS OPERAND COMMENTS
0000h Start of program memory
0000h START Start of main program
0000h BANKSEL TRISB Select bank for TRISB register
0001h 0186 BSF TRISB,0 Set RB0 pin as output
0003h LOOP Start of loop
0003h 0185 BSF PORTB,0 Turn on LED connected to RB0
0005h CALL DELAY Call delay subroutine
0006h 0184 BCF PORTB,0 Turn off LED connected to RB0
0008h CALL DELAY Call delay subroutine
0009h 2802 GOTO LOOP Jump to LOOP
000Bh DELAY Start of delay subroutine
000Bh 3000 MOVLW 0xFF Load W register with delay count
50
000Dh 00FE MOVWF COUNT Move W to COUNT register
000Fh DELAY_L Start of delay loop
OOP
000Fh 18FF DECFSZ COUNT,F Decrement COUNT
0011h 280C GOTO DELAY_LOOP Continue loop if COUNT is not
zero
0013h 0009 RETURN Return from subroutine
End of program

This table provides a structured representation of the assembly language program for the PIC
microcontroller, including memory addresses, opcodes, labels, mnemonics, operands, and comments.

RESULT :

The result of the assembly language program execution is the LED connected to pin RB0 blinking on and
off repeatedly, indicating successful program execution.

51
8085 OPCODE SHEET

52
53
54
55
56

You might also like