314328
314328
To ensure that the Diploma Level Technical Education constantly matches the latest requirements of
technology and industry and includes the all-round personal development of students including social
concerns and to become globally competitive, technology led organization.
MISSION
To provide high quality technical and managerial manpower, information and consultancy services to the
industry and community to enable the industry and community to face the changing technological and
environmental challenges.
QUALITY POLICY
We, at MSBTE, are committed to offer the best in class academic services to the students and institutes to
enhance the delight of industry and society. This will be achieved through continual improvement in
management practices adopted in the process of curriculum design, development, implementation
evaluation and monitoring system along with adequate faculty development Programs.
CORE VALUES
Microcontroller and
Applications
(314328)
Semester-IV
(AO,DE,EJ,EK,ET,EX,IC,IE,IS,TE)
Maharashtra State
Board of Technical Education, Mumbai
(Autonomous) (ISO-9001-2008) (ISO/IEC 27001:2013)
Maharashtra State
Board of Technical Education, Mumbai
(Autonomous) (ISO-9001-2008) (ISO/IEC 27001:2013)
4th Floor, Government Polytechnic Building, 49, Kherwadi,
Bandra (East), Mumbai – 400051.
Maharashtra State
Board of Technical Education
Certificate
This is to certify that Mr. / Ms …………………………………….
Roll No……………………….of ………… Semester of Diploma
in ………………………………………………………….of
Institute……………………………………………………….
(Code……………….) has attained pre-defined practical outcomes
(PROs) satisfactorily in course Microcontroller and Applications
(314328) for the academic year 20…….to 20….... as prescribed in
the curriculum.
Seal of the
Institute
Microcontroller & Applications (314328)
Microcontroller & Applications (314328)
Preface
The primary focus of any engineering laboratory/ field work in the technical
education system is to develop the much needed industry relevant competencies and skills. With
this in view, MSBTE embarked on this innovative ‘K’ Scheme curricula for engineering diploma
programmes with outcome-based education as the focus and accumulator ordinally, relatively
large amount of time is allotted for the practical work. This displays the great importance of
laboratory work making each teacher; instructor and student to realize that every minute of the
laboratory time need to be effectively utilized to develop these outcomes, rather than doing other
mundane activities. Therefore, for the successful implementation of this outcome-based
curriculum, every practical has been designed to serve as a ‘vehicle’ to develop this industry
identified competency in every student. The practical skills are difficult to develop through ‘chalk
and duster’ activity in the classroom situation. Accumulator ordinally, the ‘K’ scheme laboratory
manual development team designed the practical’s to focus on the outcomes, rather than the
traditional age old practice of conducting practical’s to ‘verify the theory’ (which may become a
by-product along the way).
The lab manual development team wishes to thank MSBTE who took initiative
in the development of curriculum re-design project and implementation and also acknowledge the
contribution of individual course experts who have been involved in laboratory manual as well as
curriculum development (I scheme) directly or indirectly. The National Institute of Technical
Teachers’ Training and Research, Bhopal deserves our sincere appreciation for the guidance
provided.
Although all care has been taken to check for mistakes in this laboratory
manual, yet it is impossible to claim perfection especially as this is the first edition. Any such
errors and suggestions for improvement can be brought to our notice and are highly welcome.
PO 1. Basic and Discipline specific knowledge: Apply knowledge of basic mathematics, sciences
and engineering fundamentals and engineering specialization to solve the engineering problems.
PO 2. Problem analysis: Identify and analyze well-defined engineering problems using codified
standard methods.
PO 4. Engineering tools, Experimentation and Testing: Apply modern engineering tools and
appropriate technique to conduct standard tests and measurements.
PO 7. Life-long learning: Ability to analyze individual needs and engage in updating in the context
of technological challenge.
Guidelines to Teachers
1. Teacher is expected to refer complete curriculum document and follow guidelines for
implementation
2. Teacher should provide the guideline with demonstration of practical to the students with all
features.
3. Teacher shall explain prior concepts to the students before starting of each practical
4. Involve students in performance of each practical.
5. Teacher should ensure that the respective skills and competencies are developed in the
students after the completion of the practical exercise.
6. Teachers should give opportunity to students for hands on experience after the demonstration.
7. Teacher is expected to share the skills and competencies to be developed in the students.
8. Teacher may provide additional knowledge and skills to the students even though not covered
in the manual but are expected the students by the industry.
9. Give practical assignment and assess the performance of students based on task assigned to
check whether it is as per the instructions.
10. Assess the skill achievement of the students and COs of each unit.
11. At the beginning Teacher should make the students acquainted with any of the simulation
software environment as few experiments are based on simulation.
12. It is desirable to paste the photo of actual experimental setup or draw block diagram of
experimental setup.
13. Practical No.1 should not be consider for Practical (ESE-End Semester Exam).
14. Conduct workshops teaching students how to safely and properly dispose of electronic waste,
fostering a culture of sustainability within the lab environment.
15. Introduce zero-waste challenges where students are encouraged to create projects using only
recycled or repurposed components from existing e-waste, promoting creativity and
resourcefulness.
Content Page
List of Practical’s and Progressive Assessment Sheet
It has inbuilt components such as CPU, internal RAM and ROM, timers/counters, serial ports,
interrupts and I/O ports. AT80C51 is compatible with MCS-51. The 8051 is an 8-bit processor.
The CPU can work on only 8 bits of data at a time.
1. It is an 8-bit microcontroller
2. It has 128 bytes of Internal RAM
3. It has 4 kilo bytes of Internal ROM
4. It has two 16-bit internal timers/counters
5. It has four 8-bit parallel ports
6. It has one full duplex serial port
7. It has three internal and two external interrupts.
Sr. Instrument
Specification Quantity
No. /Components
1. Microcontroller Single board system with 8K RAM,ROM memory with 1 No.
kit battery backup,16X4,16X2LCD display, PC keyboard
interfacing facility, Hex keypad facility, single user cross
c-compiler,RS-232,USB, interfacing facility with built in
power supply.
2. Desktop PC Loaded with open-source IDE, simulation and program 1 No.
downloading software.
IX. Procedure
Steps for creating a project using Keil software:
1. Start Keil by double clicking on Keil icon. (Keil automatically opens the last
project which was opened previously, when Keil was closed).
2. To create new project, Click on Project and select new project.
3. Select appropriate location for new project and type project name, click on save
button.
4. “Select device for Target Target-1” window will open. It displays a list of
manufacturers of microcontrollers.
5. Double click on ATMEL or INTEL, list of supported microcontrollers gets displayed.
Select 80C51AH from INTEL or AT89C51 (or as per the target board) for ATMEL
then click ok.
6. Click file pull down menu. Select new, a text editor window will open. Save this
file in a same folder where project was stored. Give extension as .ASM or. A51.
7. On left hand project work space window will display Target1 and Source group1.
8. Right click on source group; Add files to source group 1.
9. Select file type as asm source file. Now all .asm file names will be displayed.
Select appropriate file, click ADD and close.
10. Project work space window will display ‘Target 1’ and ‘Source group 1’ with added
file name.
11. Type assembly language program. End with END directive. Save the file periodically.
12. Right click on source group, click on Build target or press F7.
13. Output window will display the errors if any. If there are some errors, then remove the
errors and repeat from step number 12 until no errors.
This step is optional for the experiments which need only simulation method to observe the
results.
14. To start the simulation. Click on Debug pull down. Then select start/Stop debug session.
15. On start of debug session, project window will display all internal registers of 8051 and
their contents. To execute the program step by step, go on clicking on “step over” button.
16. Observe the logic levels of port pins, timers, interrupt etc. by clicking on PERIPHERALS
and select appropriate option.
Execute the program step by step and observe the logic levels on port pins.
17. Observe the serial communication by clicking VIEW pull down and select serial window-
1 Option.
18. Observe the contents of internal, external and code memory contents.
a. Click on memory window button
b. Memory window will get displayed near output window with address bar.
c. Type “i: address 8-bit H” for internal memory.” X: address16 bit H” for external memory
for code memory type “C: address”.
d. To modify the contents of memory, right click on contents of any memory location and
enter new valued to be loaded in that memory location
Please note that the features of Sr. no.16 to 18 are available only in debug mode
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
X. Resources Used
2.
XI. Actual procedure followed (use blank sheet provided if space is not sufficient)
1. …………………………………………………………………………………
2. …………………………………………………………………………………
3. …………………………………………………………………………………
4. …………………………………………………………………………………
5. …………………………………………………………………………………
XII. Observations
Observe development board and list various components and write their
functions.
Table no. 1
……………………………………………………………..……………………………
…………………………………………………………………………………………
……………………………………….…………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
……………………………………….…………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
……………………………………….…………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
……………………………………….…………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
……………………………………….…………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
……………………………………….…………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
……………………………………….…………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
……………………………………….…………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
I Practical Significance
The addressing modes specifies the way data can be moved or copied from source to
destination location thus providing various options and flexibility for data transfer.
This allows the programmer to write structured program which is essential to code
maintainability.
Develop an Assembly Language Program (ALP) for addition of two number bers
using various addressing modes and assembler directives.
Addressing Modes
A microcontroller provides various methods for accumulator essing data needed in the
execution of an instruction. The various methods of accumulator essing the data are
called addressing modes.
1. Immediate addressing mode:
The data is provided in instruction itself.
Ex: MOV A, #05H (The immediate data 05H provided in instruction is moved into A
register).
Ex: ADD A, #05H (The immediate data 05H provided in instruction is added with
contents of A register and the result is stored in A register).
Ex: ADD A, 40H Content of RAM address 40H is added with content of
Accumulator and result is stored into Accumulator
Assembler Directives:
The assembler directives are instructions to the assembler to carry out certain
activity during the assembly process. The common assembler directives are:
❖ ORG: Indicates the beginning of the address.
❖ DB: Used to define 8-bit data in decimal, binary, hexadecimal, ASCII formats.
❖ EQU: Used to define a constant without occupying a memory location.
❖ END: Indicates end of the source file.
Instrument
Sr. No. Specification Quantity
/Components
1. Desktop PC Loaded with open-source IDE, simulation and 1 1 No.
program downloading software.
VIII Precautions to be followed
IX Procedure
Develop Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL or INTEL and select 80c51AH or AT89C51.
5. Type the program in text editor and save as .asm or .a51.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
X Resources Used
S. No. Instrument /Components Specification Quantity
1.
2.
SAMPLE PROGRAM 1: Write a program to add two 8-bit numbers using immediate and
direct addressing mode.
Step 1: Algorithm
1. Start
2. Move the immediate data 02H into accumulator
3. Add the data in accumulator with immediate data 03H
4. Initialize R1 with memory address 30H
5. Move the result of addition from accumulator to the memory address pointed by R1.
6. Stop
Step 2-Flowchart
Fig 2.1 Flowchart to add data from accumulator with immediate data
Output Window
Step 1-Algorithm
1. Start.
2. Use ORG directive to set memory location at 0000H.
3. Initialize data pointer to memory location pointed by label MYDATA.
4. Clear Accumulator.
5. Move into accumulator a byte of data located at address pointed by DPTR.
6. Move data in accumulator to register r0
7. Increment data pointer
8. Clear Accumulator.
9. Move into accumulator a byte of data located at address pointed by DPTR.
10. Add data in accumulator with data in register R0
11. Initialize Data pointer to new memory location 2000H.
12. Move the contents of Accumulator to address pointed by DPTR.
13. Use data directive to write data 02H at memory location 0010H and data 03H at
memory location 0011H
Step 2-Flowchart
Output Window
Problem statement #1 for student: Write a program to add two data bytes stored in internal
RAM locations using direct and indirect addressing Mode.
X Resources used
XI Actual Procedure Followed (use blank sheet provided if space not sufficient)
1. ……………………………………………………………………………………….
2. ……………………………………………………………………………………….
3. ……………………………………………………………………………………….
4. ……………………………………………………………………………………….
5. ……………………………………………………………………………………….
6. ……………………………………………………………………………………….
7. ……………………………………………………………………………………….
8. …………………………………………………………………………………………
9. …………………………………………………………………………………………
Accumulator Accumulator
Immediate data R0
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
XIV Interpretation of Results (Give meaning of the above obtained results)
………………………………………………………………………………………………
….…………………………………………………………………………………………
………….…………………………………………………………………………………
………………………………………………………………….…………………………
…..…………………………………………………………………………………….……
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
………………………………………………….………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
……………………………………
1. The 8051 Microcontroller and Embedded system Using Assembly and C- Muhammad
Ali Mazidi, Janice Gillispie Mazidi, Rolin D. Mckinlay- Pearson /Prentice Hall, , 2nd
edition, Delhi,2008, ISBN 978-8177589030
2. https://nptel.ac.in/courses/Webcourse-contents/IISc-
BANG/Microprocessors%20and%20Microcontrollers/pdf/Teacher_Slides/mod2/M2
L2.pdf
3. https://nptel.ac.in/courses/Webcourse-contents/IIT
KANPUR/microcontrollers/chap2.pdf
4. https://www.youtube.com/watch?v=nlT5B3JEAak
I Practical Significance
Arithmetic Instructions:
ADD A, #number Add the immediate number with accumulator and stores result in
accumulator
ADD A, Rn Add the data in Rn with accumulator and stores result in accumulator
ADD A, add Add the data in add with accumulator and stores result in accumulator
ADD A, @Rp Add the data at the address in Rp with accumulator and stores result in
accumulator
ADDC A,# number Add the immediate number with accumulator and carry, stores result in
accumulator
ADDC A, Rn Add the data in Rn with accumulator and carry, stores result in accumulator
ADDC A, add Add the data in add with accumulator and carry, stores result in accumulator
ADDC A, @Rp Add the data at the address in Rp with accumulator and carry, stores result
in accumulator
SUBB A, #number Subtract immediate number and carry from accumulator; stores the result in
accumulator
SUBB A, add Subtract the content of add and carry from accumulator; stores the result in
accumulator
SUBB A, Rn Subtract the data in Rn and carry from accumulator; stores the result in
accumulator
SUBB A, @Rp Subtract the data at the address in Rp and carry from accumulator; stores the
result in accumulator
MUL AB Multiply accumulator and register B. store the lower byte of result in
remainder in B
Instrument
Sr. No. Specification Quantity
/Components
1. Desktop PC Loaded with open-source IDE, simulation and program 1 1 No.
downloading software.
XIV Procedure
Develop Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL or INTEL and select 80c51AH or AT89C51.
5. Type the program in text editor and save as .asm or .a51.
Compile the Program
6. Right click on source group and build the target.
7. Check for any errors in the output window and remove if any.
Run, Debug the Program
8. Click on Debug and start simulation and start/stop debug session.
9. Run the program step by step.
10. Observe the output on the project window. It will display all internal registers
of 8051 and their contents.
11. Note the contents of the registers in observation table
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
SAMPLE PROGRAM 1: Write a program to add, subtract, multiply and divide two 8 bit
numbers.
Step 1: Algorithm
1. Move data 04H in Accumulator.
2. Add data 03H to the number stored in accumulator (04 H).
3. Store result of addition operation in register R1
4. Clear Carry flag
5. Move data 08H in accumulator.
6. Subtract data 02H from number stored in accumulator (08 H).
7. Store result of subtraction operation in register R2
8. Move data 05H in accumulator and data 03H in register B.
9. Multiply the two number.
10. Store lower byte of product in R3 and higher byte of product R4.
11. Move data 10 H in Accumulator and 06 H in register B.
12. Divide the two number.
13. Store quotient in register R5 and remainder in register R6
14. Stop
Step 2-Flowchart
Memory Hex
Label Mnemonics Comments
Address Code
ORG 0000H
C:0x0000 7404 MOV A, #04H ; Move the data 04H in accumulator
; Add the contents of accumulator
C:0x0002 2403 ADD A, #03H
with 03H
C:0x0004 F9 MOV R1, A ; Store the result in R1 register
C:0x0005 C3 CLR C ;Clear the carry flag
C:0x0006 7408 MOV A, #08H ;Move the data 08H in accumulator
;Subtract the 02H from data in
C:0x0008 9402 SUBB A, #02H
accumulator with borrow(cy)
C:0x000A FA MOV R2, A ;Store the result in R2 register
C:0x000B 7405 MOV A, #05H ;Move the data 05H in accumulator
C:0x000D 75F003 MOV B, #03H ;Move the data 03H in register B
C:0x0010 A4 MUL AB ;Multiply the contents of A and B
C:0x0011 FB MOV R3, A ;Store the lower byte result in R3
C:0x0012 ACF0 MOV R4, B ;Store the higher byte result in R4
C:0x0014 7410 MOV A, #10H ;Move the data 10H in accumulator
C:0x0016 75F006 MOV B, #06H ;Move the data 06 in register B
C:0x0019 84 DIV AB ;Divide the contents of A and B
C:0x001A FD MOV R4, A ;Store the quotient in R4 register
C:0x001B AEF0 MOV R5, B ;Store the Remainder in R5 register
END ;Stop
Output Window
Problem statement for student: Write a program to perform multiplication and division of
two 8 bit numbers taken from external memory locations and store the result in Registers R0
to R3.
XV Resources used
XVI Actual Procedure Followed (use blank sheet provided if space not sufficient)
1. ………………………………………………………………………………………………
2. ………………………………………………………………………………………………
3. ………………………………………………………………………………………………
4. ………………………………………………………………………………………………
5. ………………………………………………………………………………………………
6. ………………………………………………………………………………………………
7. ………………………………………………………………………………………………
8. ………………………………………………………………………………………………
XII Observations for sample program (use blank sheet provided if space not sufficient)
………………………………………………………………………………………………
………………………………………………………………………………………………
……………………………………………………………………………………………
………………………………………………………………………………………………
….…………………………………………………………………………………………..
………………………………………………………………………………………………
……………………………………………………………………….……………………
…………………………………………………………………………………….………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
………………………………………………………………………………………………..
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
………………………………………….………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
………………………………………………………………………………………………..
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XVII References/Suggestions for further reading
1. https://www.tutorialspoint.com/arithmetic-group-in-8051
2. https://technobyte.org/arithmetic-instructions-8051/
3. https://technobyte.org/arithmetic-instructions-8051/
I Practical Significance
8051 microcontrollers have single instruction arithmetic operations. Applications such as BCD
and ASCII conversions and checksum byte testing require arithmetic operations. This practical
will help the students to develop skills to write assembly program for arithmetic operations.
8051 uses DPTR, a 16 bit register to access the 16-bit data from external memory. It is used in
MOVX, MOVC command
Arithmetic operations affect flags in PSW register of 8051
The 8051 microcontroller supports various arithmetic operations using specific instructions.
Here's an overview of the key instructions used for arithmetic operations:
Addition Instructions
ADD A, source: Adds the source operand to the accumulator (A). Source can be a register
(R0-R7), a direct address, or an immediate value.
Example: ADD A, R1: Adds the value in register R1 to the accumulator
ADDC A, source: Adds the source operand to the accumulator along with the carry bit. Used
for multi-byte (e.g., 16-bit) addition where carry needs to be considered.
Example: ADDC A, R2: Adds the value in register R2 and the carry bit to the accumulator
Subtraction Instructions
SUBB A, source: Subtracts the source operand and the carry bit from the accumulator. Source
can be a register, a direct address, or an immediate value.
Example: SUBB A, #10H: Subtracts the immediate value 10H and the carry bit from the
accumulator
Sr.
Instrument /Components Specification Quantity
No.
1 Desktop PC Loaded with open-source IDE, 1 No.
simulation and program downloading
software
IX Procedure
Write Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL and select AT89C51.
5. Type the program in text editor and save as filename.asm extension.
Compile the Program
6. Right click on source group and build the target.
7. Check for any errors in the output window and remove if any.
Run, Debug the Program
8. Click on Debug and start simulation and start/stop debug session.
9. Run the program step by step.
10. Observe the output on the project window.
11. Note the values of the result of various operations in the observation table.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
Step 1-Algorithm
1. Select register bank 2.
2. Initialize Carry Counter to get result > 16 bit.
3. Load LSB of first number in Accumulator.
4. Add LSB of Second number with LSB of first number.
5. Store LSB of result.
6. Load MSB of first number in Accumulator.
7. Add MSB of second number with MSB of first Number.
8. If Carry is not 1, then go to step 10.
9. Increment Carry Counter by 1.
10. Store MSB of result.
11. Store Carry of result.
12. Stop.
Memory Hex
Label Mnemonics Comments
Address Code
ORG 0000H
Load the contents of memory
C:0x0000 E540 MOV A, 40H location 40H in A register (Lower
8-bits of first number)
Memory Hex
Label Mnemonics Comments
Address Code
Load the contents of memory
C:0x0002 8542F0 MOV B, 42H location 42H in B register (Lower 8
bits of second number)
C:0x0005 25F0 ADD A, B Add the contents of A and B
Store the result in memory location
C:0x0007 F544 MOV 44H, A
44H
Load the content of 41H in register
C:0x0009 E541 MOV A, 41H
A (Higher 8 bits of first number)
Load the contents of 43H in register
C:0x000B 8543F0 MOV B, 43H
B (Higher 8 bits of second number)
ADD the contents of A and B with
C:0x000E 35F0 ADDC A,B
previous carry
C:0x0010 F545 MOV 45H, A Store the result at location 45H
END
Output Window
Memory Hex
Label Mnemonics Comments
Address Code
X Resources Used
XI Actual Procedure Followed (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
……………………….…………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XII Observations for sample program (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
I Practical Significance
8051 microcontrollers have single instruction arithmetic operations. Applications such as BCD
and ASCII conversions and checksum byte testing require arithmetic operations. This practical
will help the students to develop skills to write assembly program for arithmetic operations.
DAA Instruction:
The DAA (Decimal Adjust Accumulator) instruction is used in the 8051 microcontrollers to
correct the result of a binary-coded decimal (BCD) addition operation. After adding two BCD
numbers, the result might not be a valid BCD number. The DAA instruction adjusts the
accumulator to ensure the result is a valid BCD number.
1. If the lower 4 bits (nibble) of the accumulator are greater than 9, or if the auxiliary
carry (AC) flag is set, 6 is added to the lower nibble.
2. If the upper 4 bits (nibble) of the accumulator are greater than 9, or if the carry (C)
flag is set, 6 is added to the upper nibble.
Ex: If the result of the addition is 0x3C (which is not a valid BCD), DA A will correct it to
0x42 (which is a valid BCD for the number 42).
Sr. Quantit
Instrument /Components Specification
No. y
1 Desktop PC Loaded with open-source IDE, 1 No.
simulation and program downloading
software
IX Procedure
Write Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL and select AT89C51.
5. Type the program in text editor and save as filename.asm extension.
Compile the Program
6. Right click on source group and build the target.
7. Check for any errors in the output window and remove if any.
Run, Debug the Program
8. Click on Debug and start simulation and start/stop debug session.
9. Run the program step by step.
10. Observe the output on the project window.
11. Note the values of the result of various operations in the observation table.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
SAMPLE PROGRAM 1: To perform addition of BCD data stored at external and store the
result in internal memory.
Step 1-Algorithm
1. Initialize Data pointer [DPTR] with memory location 2000H
2. Load the contents of memory location pointed by DPTR to Accumulator
3. Transfer the contents of A register to R0.
4. Increment DPTR
5. Load the contents of memory location pointed by DPTR to Accumulator
6. Perform the addition of contents of A register with R0 register.
Memory Hex
Label Mnemonics Comments
Address Code
ORG 00H
Initialize Data pointer [DPTR]
C:0x0000 902000 MOV DPTR, #2000H
with memory location 2000H
Load the contents of memory
C:0x0003 E0 MOVX A, @DPTR location pointed by DPTR to
Accumulator
Transfer the contents of A
C:0x0004 F8 MOV R0, A
register to R0.
C:0x0005 A3 INC DPTR Increment DPTR
Memory Hex
Label Mnemonics Comments
Address Code
Load the contents of memory
C:0x0006 E0 MOVX A ,@DPTR location pointed by DPTR to
Accumulator
Perform the addition of
C:0x0007 28 ADD A, R0 contents of A register with R0
register
Perform BCD adjustment on
C:0x0008 D4 DA A the result by using DA A
instruction.
Transfer the result to internal
C:0x0009 F530 MOV 30H, A
memory location 30H.
END
X Resources Used:
Instrument
S. No. Specification Quantity
/Components
XI Actual Procedure Followed (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
……………………….…………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XIII Precautions Followed (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XIV Observations for sample program (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
1. Give the significance of Auxiliary carry and Carry flag while performing BCD
operations.
2. Give the types of BCD number system.
3. List the applications of BCD number systems.
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XX Assessment Scheme
The given performance indicators should serve as a guideline for assessment regarding process
and product related marks:
I Practical Significance
The series addition in the 8051 microcontroller is a fundamental aspect of its programming and
functionality. Series addition is a basic arithmetic operation that is used extensively in various
programming tasks within the microcontroller. It is often employed in loop mechanisms where
iterative addition of values is required, essential for tasks like averaging or cumulative sums.
DEC (Decrement Instruction): The DEC instruction decreases the value of a byte by one.
Syntax: DEC operand
Operands: Similar to INC, it can target the accumulator, a register, a direct address, or an indirectly
addressed memory location.
Example: DEC A: Decrements the accumulator and result stored in accumulator.
Sr.
Instrument /Components Specification Quantity
No.
1 Desktop PC Loaded with open-source IDE, 1 No.
simulation and program downloading
software
IX Procedure
Write Program
1. Start Keil by double clicking on Keil icon.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical trainer kits
and subsequently reducing e-waste
SAMPLE PROGRAM 1: Develop an ALP for sum of series stored in RAM locations 40 to 49H.
Find the sum of the values at the end of program the lower byte stored in 30H and the high byte in
31H.
Step 1-Algorithm
1. Initialize Register R0 with the starting memory address.
2. Initialize Register R1 as counter to count the number of data values.
3. Initially clear register R2 and Accumulator.
4. Add the contents of Register A and contents of memory location pointed by R0.
5. Check whether carry flag is set or not. If carry flag is set then Increment register R2
6. Increment Register R0 to point to next number.
7. Decrement register R1 to check whether all additions are performed or not
8. If zero flag is not set then go to step 4 and repeat the process till all numbers are added
9. Move the contents of Accumulator (result) and Register R2 to memory location 30H and 31H.
10. Stop.
Memory Hex
Label Mnemonics Comments
Address Code
ORG 00H
Initialize Register R0 with
C:0x0000 7840 MOV R0, #40H
memory location 40H
Initialize Register R1 with
C:0x0002 790A MOV R1, #0AH
count value of 10 [0AH]
C:0x0004 7A00 MOV R2, #00H Clear Register R2
C:0x0006 E4 CLR A Clear Accumulator
Input
Output Window
Problem statement 1 for student: Write a program to perform Series addition of five numbers taken
from external memory locations and store the result in registers R0 and R1 respectively.
X Resources Used:
XI Actual Procedure Followed (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
……….…………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
……………………………………………………………………………………………………..…
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
XI Observations for sample program (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
……………………………………………………………………………………….………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
………………………………………………………………………………………..………………
1. MOV A, # 55H
RLC A
Give the Contents of accumulator and status of carry flag after execution of the above two
instructions.
2. Give the instructions used to set and clear the carry flag.
3. Give the sequence of instructions used to perform subtraction without borrow.
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………..……
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
……………………………………………………………………………………………………….…
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………….……
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
………………………………………………………………………………………..………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
XX Assessment Scheme
The given performance indicators should serve as a guideline for assessment regarding process and
product related marks:
I Practical Significance
The 8051 microcontroller uses data transfer instructions to move data between internal RAM
locations, as well as between internal and external RAM.
Mnemonics Description
MOVX A. @DPTR Copy the contents of the external memory address in DPTR to A.
MOVX @DPTR, A Copy data from A to the external memory address in DPTR.
Instrument
Sr. No. Specification Quantity
/Components
1. Desktop PC Loaded with open-source IDE, simulation and program 1 1 No.
downloading software.
XIX Procedure
Develop Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL or INTEL and select 80c51AH or AT89C51.
5. Type the program in text editor and save as .asm or .a51.
Compile the Program
6. Right click on source group and build the target.
7. Check for any errors in the output window and remove if any.
Run, Debug the Program
8. Click on Debug and start simulation and start/stop debug session.
9. Run the program step by step.
10. Observe the output on the project window. It will display all internal registers of 8051
and their contents.
11. Observe the contents of internal and external data memory.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
SAMPLE PROGRAM 1: Write a program to transfer a block of 5 data bytes from internal source
data memory locations 40H onwards to destination memory locations 50H onwards.
Step 1: Algorithm
Step 2-Flowchart
Memory Hex
Label Mnemonics Comments
Address Code
C:0x0000 ORG 0000H
C:0x0000 ;Initialize source memory pointer R0 to
7840 MOV R0, #40H
40H
C:0x0002 ;Initialize destination memory pointer
7950 MOV R1, #50H
R1 to 50H
C:0x0004 7A05 MOV R2, #05H ;Initialize iteration count to 05H
C:0x0006 ;Move the contents of source memory
E6 UP: MOV A, @R0
pointed by R0 to Accumulator
C:0x0007 ;Move the contents of Accumulator to
F7 MOV @R1, A
destination memory pointed by R1
C:0x0008 08 INC R0 ;Increment the contents of R0
C:0x0009 09 INC R1 ;Increment the contents of R1
C:0x000A DAFA DJNZ R2, UP ; Decrement counter by one, Is it zero?
No ,jump to UP
END
Output Window
Problem statement for student: Write a program to transfer a block of 05 bytes from internal data
memory location 20H onwards to external data memory location 2000H onwards
XX Resources used
XXI Actual Procedure Followed (use blank sheet provided if space not sufficient)
1. ……………………………………………………………………………………………..
2. ………………………………………………………………………………………………
3. ……………………………………………………………………………………………….
4. ………………………………………………………………………………………………
5. ………………………………………………………………………………………………
6. ………………………………………………………………………………………………
7. ………………………………………………………………………………………………
8. ………………………………………………………………………………………………
XII Observations for problem statement 1 (use blank sheet provided if space not sufficient)
……………………………………………………………………………………………………
……………………………………………………………………………………………………
…………………………………………………………………………………………………….
………………………………………………………………………………………………….…
…………………………………………………………………………………………………….
……………………………………………………………………………………………….……
……………………………………………………………………….……………………………..
…………………………………………………………………………………….………………..
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
………………….………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
1. https://www.silabs.com/documents/public/presentations/8051_Instruction_Set.pdf
2. https://www.daenotes.com/electronics/digital-electronics/8051-microcontroller-instruction-
types
3. https://www.electronicshub.org/8051-microcontroller-memory-organization/
I Practical Significance
Data transfer is a process of moving or copying information from one location to other location
within internal or external data memory. To save the results of certain operations, to create
lookup tables etc. these data transfer programs are required. Block data transfer is more
efficient than byte-by-byte operations, especially when dealing with large data sets.
It minimizes overhead by reducing the number of instruction cycles required for data
movement.
The 8051 microcontroller includes 128 bytes of internal RAM and up to 4 KB of internal
ROM:
1. RAM (128 bytes): Divided into working registers, bit-addressable area, and general
storage.
2. ROM (4 KB): Stores the microcontroller's firmware, typically used for storing the
program that the 8051 executes. Locations from 0000H to 0FFFH are internal
locations and that exceeds 0FFFH are external locations.
These memory components are integral for the operation and flexibility of the 8051 in
various applications.
Sr.
Instrument /Components Specification Quantity
No.
1 Desktop PC Loaded with open-source IDE, 1 No.
simulation and program
downloading software
IX Procedure
Write Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL and select AT89C51.
5. Type the program in text editor and save as filename.asm extension.
Compile the Program
6. Right click on source group and build the target.
7. Check for any errors in the output window and remove if any.
Run, Debug the Program
8. Click on Debug and start simulation and start/stop debug session.
9. Run the program step by step.
10. Observe the output on the project window.
11. Note the values of the result of various operations in the observation table.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
SAMPLE PROGRAM 1: Write and execute a program to exchange five data bytes of
internal memory location from 50H to 60H onwards.
Step 1-Algorithm
1. Start
2. Initialize memory pointer as a source.
3. Initialize memory pointer as a destination.
4. Initialize counter.
5. Move the content of first location into accumulator.
6. Move the content of accumulator to first destination location.
7. Increment source location.
8. Increment destination location.
9. Move the contents of Accumulator to source locations
Maharashtra State Board of Technical Education ‘K-Scheme’
82
Microcontroller & Applications (314340)
10. If zero flag is not set then go to step 4 and repeat the process till all numbers are added
11. Decrement iteration count and if not zero jump to step 5.
12. Stop.
Memory Hex
Label Mnemonics Comments
Address Code
ORG 00H
Initialize memory pointer R0
C:0x0000 7850 MOV R0,#50H
as a source
Initialize memory pointer R1
C:0x0002 7960 MOV R1, #60H
as a destination
C:0x0004 7F05 MOV R7, #05H Initialize counter.
Move the content of first
C:0x0006 E6 UP MOV A, @R0 location in to
accumulator.
Exchange with destination
C:0x0007 C7 XCH A, @R1
memory
Move the contents of
C:0x0008 F6 MOV @R0,A Accumulator to source
locations
C:0x0009 08 INC R0 Increment source location
C:0x0009 09 INC R1 Increment destination location
Decrement iteration count and
C:0x000A DFF9 DJNZ R7, UP if not zero
jump to step 5.
END
Problem statement 1 for student: Write a program to perform Block Exchange from source
to destination using external memory locations.
X Resources Used:
XI Actual Procedure Followed (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
……………………….…………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XI Observations for sample program (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
1. Write program to perform block transfer from source to destination memory locations.
2. Give the significance of DPTR in using external memory locations.
̅̅̅̅ pin in 8051
3. Give the importance of 𝐸𝐴
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XX Assessment Scheme
The given performance indicators should serve as a guideline for assessment regarding process
and product related marks:
Practical No. 9: Finding the smallest number from the given data bytes
I Practical Significance
Microcontrollers use compare operation to test or compare register values. The results of
these operations can update flag bits, which can then be used to change program flow
through conditional execution. This practical will help the students to develop skills to use
the compare and loop instructions to find smallest number from a block of data bytes.
Mnemonic Description
CJNE A,direct,rel Compares direct byte to the accumulator and jumps if not equal.
CJNE A,#data,rel Compares immediate data to the accumulator and jumps if not equal
CJNE Rn,#data,rel Compares immediate data to the register and jumps if not equal.
CJNE @Ri,#data,rel Compares immediate data to indirect register and jumps if not equal.
Instrument
Sr. No. Specification Quantity
/Components
1. Desktop PC Loaded with open-source IDE, simulation and program 1 1 No.
downloading software.
IX Procedure
Develop Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL or INTEL and select 80c51AH or AT89C51.
5. Type the program in text editor and save as .asm or .a51.
Compile the Program
6. Right click on source group and build the target.
7. Check for any errors in the output window and remove if any.
Run, Debug the Program
8. Click on Debug and start simulation and start/stop debug session.
9. Run the program step by step.
10. Observe the output on the project window. It will display all internal registers of 8051
and their contents.
11. Note down the readings in observation table
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
SAMPLE PROGRAM 1: Write a program to find smallest number from the given array of 05 data
bytes stored in internal RAM locations 30H onwards and store the smallest number in location 40H.
Step 1: Algorithm
1. Initialize the comparison count to 04H which is number of data bytes minus one.
2. Initialize source memory pointer R0 to 30H.
3. Move the contents of source location pointed by R0 to Accumulator
4. Increment source memory pointer
5. Move the contents of source location to register B
6. Compare the two numbers.
7. If number in A is less than number in B, then go to step 9.
Memory Hex
Label Mnemonics Comments
Address Code
ORG 0000H
C:0x0000 7A04 MOV R2,#04H ;Initialize Comparison count
C:0x0002 ;Initialize Source memory pointer
7830 MOV R0,#30H
R0=30H
Output Window
Problem statement for student: Write a program to find smallest number from the given array of
05 data bytes stored in External RAM locations 3000H onwards and store the smallest number in
location 4000H.
X Resources used
XI Actual Procedure Followed (use blank sheet provided if space not sufficient)
1. ………………………………………………………………………………………………
2. ………………………………………………………………………………………………
3. ………………………………………………………………………………………………
4. ………………………………………………………………………………………………
5. ………………………………………………………………………………………………
6. ………………………………………………………………………………………………
7. ………………………………………………………………………………………………
8. ………………………………………………………………………………………………
XII Observations for problem statement (use blank sheet provided if space not sufficient)
……………………………………………………………………………………………………
……………………………………………………………………………………………………
…………………………………………………………………………………………………….
………………………………………………………………………………………………….…
…………………………………………………………………………………………………….
……………………………………………………………………………………………….……
……………………………………………………………………….……………………………..
…………………………………………………………………………………….………………..
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
………………….………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
1. https://josephscollege.ac.in/lms/Uploads/pdf/material/Instruction_set_of_Microcontroller_8
051.pdf
2. https://www.refreshnotes.com/2016/04/8051-program-smallest-element-in-array.html
3. https://www.daenotes.com/electronics/digital-electronics/8051-microcontroller-instruction-
types
4. https://www.keil.com/support/man/docs/a51/a51_cjne.htm
Practical No. 10: Finding the Largest number from the given data bytes
I Practical Significance
Microcontrollers use compare operation to test or compare register values. The results of
these operations can update flag bits, which can then be used to change program flow
through conditional execution. This practical will help the students to develop skills to use
the compare and loop instructions to find largest number from a block of data bytes.
Instrument
Sr. No. Specification Quantity
/Components
1. Desktop PC Loaded with open-source IDE, simulation and program 1 1 No.
downloading software.
IX Procedure
Develop Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL or INTEL and select 80c51AH or AT89C51.
5. Type the program in text editor and save as .asm or .a51.
Compile the Program
6. Right click on source group and build the target.
7. Check for any errors in the output window and remove if any.
Run, Debug the Program
8. Click on Debug and start simulation and start/stop debug session.
9. Run the program step by step.
10. Observe the output on the project window. It will display all internal registers of 8051
and their contents.
11. Note down the readings in observation table
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
SAMPLE PROGRAM 1: Write a program to find Largest number from the given array of 05 data
bytes stored in external RAM locations 3000H onwards and store the Largest number in location
3010H.
Step 1: Algorithm
1. Initialize the comparison count to 04H which is number of data bytes minus one.
2. Initialize external source memory pointer DPTR to 3000H.
3. Move the contents of external source location pointed by DPTR to Accumulator
4. Move data in register A to register B
5. Increment source memory pointer
6. Move the contents of source location to register A
7. Compare the two numbers.
8. If number in A is larger than number in B, then go to step 10.
Memory Hex
Label Mnemonics Comments
Address Code
ORG 0000H
C:0x0000 7A04 MOV R2,#04H ;Initialize Comparison count
C:0x0002 ;Initialize Source memory pointer
903000 MOV DPTR,#3000H
R0=30H
C:0x0005 E0 MOVX A,@DPTR ;Move first number to register B
C:0x0006 F5F0 UP: MOV B,A
C:0x0008 A3 INC DPTR ;Increment memory pointer
Output Window
Problem statement for student: Write a program to find Largest number from the given array of
10 data bytes stored in internal RAM location 50H onwards and store the Largest number in location
60H.
X Resources used
XI Actual Procedure Followed (use blank sheet provided if space not sufficient)
1. ………………………………………………………………………………………………
2. ………………………………………………………………………………………………
3. ………………………………………………………………………………………………
4. ………………………………………………………………………………………………
5. ………………………………………………………………………………………………
6. ………………………………………………………………………………………………
7. ………………………………………………………………………………………………
8. ………………………………………………………………………………………………
XII Observations for problem statement (use blank sheet provided if space not sufficient)
……………………………………………………………………………………………………
……………………………………………………………………………………………………
XIV Interpretation of Results (Give meaning of the above obtained results)
………………………………………………………………………………………………….…
…………………………………………………………………………………………………….
……………………………………………………………………….……………………………..
…………………………………………………………………………………….………………..
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
………………….………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
1. https://electronicsforyou.in/8051-program-to-find-the-largest-number-in-an-array/
2. https://josephscollege.ac.in/lms/Uploads/pdf/material/Instruction_set_of_Microcontroller_8
051.pdf
3. https://www.refreshnotes.com/2016/04/8051-program-smallest-element-in-array.html
4. https://www.daenotes.com/electronics/digital-electronics/8051-microcontroller-instruction-
types
I Practical Significance
Sorting is any process of arranging information systematically in ascending or descending order.
This allows us to write better programs like indexing to fetch the information faster, allows faster
search techniques, removes duplicate information and has many uses in statistical applications.
Arranging numbers in ascending order is critical for highlighting significant values, optimizing
processes, and enhancing the effectiveness of data analysis and presentation. This practical will
help the students to develop skills to understand how to access data from external memory, use of
branch instructions and arranging numbers in ascending order.
Sr.
Instrument /Components Specification Quantity
No.
1 Desktop PC Loaded with open-source IDE, 1 No.
simulation and program downloading
software
IX Procedure
Write Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL and select AT89C51.
5. Type the program in text editor and save as filename.asm extension.
Compile the Program
6. Right click on source group and build the target.
7. Check for any errors in the output window and remove if any.
Run, Debug the Program
8. Click on Debug and start simulation and start/stop debug session.
9. Run the program step by step.
10. Observe the output on the project window.
11. Note the values of the result of various operations in the observation table.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical trainer
kits and subsequently reducing e-waste
SAMPLE PROGRAM 1: Write and execute a program to arrange the ten data values in
external memory in descending order
Step 1-Algorithm
Step 1: Initialize a counter for comparison (Pass counter).
Step2: Initialize memory pointer to read number from the array.
Step3: Initialize byte counter.
Step 4: Read numbers from array.
Step 5: Compare two numbers.
Problem statement 1 for student: Write a program to arrange the numbers in ascending order.
Assume internal memory locations.
Memory Hex
Label Mnemonics Comments
Address Code
X Resources Used:
XI Actual Procedure Followed (use blank sheet provided if space not sufficient)
………………………………………………………………………………………………………
………………………………………………………………………………………………………
…………….………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
…………………………………………………………………………………………………..…
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
…………………………………………………………………………………………..…………
XI Observations for sample program (use blank sheet provided if space not sufficient)
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
…………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………..……
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
…………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XX Assessment Scheme
The given performance indicators should serve as a guideline for assessment regarding process
and product related marks:
I Practical Significance
Sorting is any process of arranging information systematically in ascending or descending order.
Helps in decision-making processes where resources are to be allocated based on priority, with the
most critical or valuable cases handled first. Arranging numbers in descending order is critical for
highlighting significant values, optimizing processes, and enhancing the effectiveness of data
analysis and presentation. This practical will help the students to develop skills to understand how
to access data from external memory and use of branch instructions.
Sr.
Instrument /Components Specification Quantity
No.
1 Desktop PC Loaded with open-source IDE, 1 No.
simulation and program downloading
software
IX Procedure
Write Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL and select AT89C51.
5. Type the program in text editor and save as filename.asm extension.
Compile the Program
6. Right click on source group and build the target.
7. Check for any errors in the output window and remove if any.
Run, Debug the Program
8. Click on Debug and start simulation and start/stop debug session.
9. Run the program step by step.
10. Observe the output on the project window.
11. Note the values of the result of various operations in the observation table.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical trainer
kits and subsequently reducing e-waste
SAMPLE PROGRAM 1: Write and execute a program to arrange the ten data values in
external memory in descending order
Step 1-Algorithm
Algorithm:
Step 1: Initialize a counter for comparison (Pass counter).
Step2: Initialize memory pointer to read number from the array.
Memory Hex
Label Mnemonics Comments
Address Code
ORG 00H
C:0X0000 780A MOV R0, #0AH Initialize pass counter.
C:0X0002 904000 REP1 MOV DPTR, #4000H Initialize memory pointer
C:0X0005 7909 MOV R1, #09H Initialize byte counter
C:0X0007 AA82 REPEAT MOV R2, DPL Save the lower byte address
C:0X0009 E0 MOVX A, @DPTR Read the number from array
C:0X000A F5F0 MOV 0F0H, A Store the number in register B
C:0X000C A3 INC DPTR Increment memory pointer
Take the next number from
C:0X000D E0 MOVX A, @DPTR
array
Compare number with next
C:0X000E B5F002 CJNE A, 0F0H, NEXT
number
C:0X0011 AJMP SKIP Jump to SKIP unconditionally
If number < next number then
C:0X0013 4007 NEXT: JC SKIP
go to skip
Else exchange the number
C:0X0015 8A82 MOV DPL, R2
with next number
Copy greater number to
C:0X0017 F0 MOVX@DPTR, A
memory locations
C:0X0018 A3 INC DPTR Increment memory pointer
C:0X0019 E5F0 MOV A, 0F0H
C:0X001B F0 MOVX @DPTR, A
SKIP: DJNZ R1, REPEAT Decrement byte counter by 1,
if byte counter≠ 0 then go to
C:0X001C D9E9
REPEAT.
Problem statement 1 for student: Write a program to arrange the numbers in descending order.
Assume internal memory locations.
Memory Hex
Label Mnemonics Comments
Address Code
X Resources Used:
XI Actual Procedure Followed (use blank sheet provided if space not sufficient)
………………………………………………………………………………………………………
………………………………………………………………………………………………………
…………….………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
…………………………………………………………………………………………………..…
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
…………………………………………………………………………………………..…………
XI Observations for sample program (use blank sheet provided if space not sufficient)
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
…………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………..……
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
…………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
……………………………………………………………………………………………..………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
…………………………………………………………………………………………………..…
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XX Assessment Scheme
The given performance indicators should serve as a guideline for assessment regarding process
and product related marks:
I Practical Significance
Generation of time delay is most important concept in embedded systems. The purpose of the
delay program is to introduce a pause or delay in program execution for a specified amount
of time. Most of the times, precise time delay needs to be generated between two actions in
microcontroller applications, like blinking of LED, Pulse generation, monitoring switch etc.
We can generate the time delay using the Loop technique. Precise time delay can be generated
using inbuilt timers in microcontroller. This practical will help the students to develop skills
to create the time delay by using timer registers and microcontroller crystal frequency.
TMOD Register:
TMOD register is used to select various timer operation modes for Timer 0 and Timer 1
GATE : When TRX (in TCON) is set and GATE=1 , TIMER/COUNTER will run only while
INTX pin is high( hardware control), when GATE=0 , TIMER/COUNTER will run only while
TRX=1 regardless of state of INTX pin (software control)
M1 M0 MODE DESCRIPTION
0 0 0 13-bit timer/counter
0 1 1 16 bit timer/counter
1 0 2 8 bit auto-reload
1 1 3 Split mode:
(Timer 0) TL0 is an 8-bit timer/counter controlled by the
standard timer 0 Control bits.
TH0 is an8-bit timer and is controlled by timer 1 control bits.
Timer1 / counter1 is stopped
TCON Register:
TCON is 8 bit SFR used to control the Timer/Counter operations
10 ms Delay generation:
Required time delay = 10 ms
Oscillator frequency is Fosc. = 11.0592MHz
Sr . Instrument
Specification Quantity
No. /Components
1. Desktop PC Loaded with open source IDE, simulation and 1 No.
program downloading software.
IX Procedure
1. Write algorithm for given problem.
2. Draw flowchart for the same.
3. Develop assembly program using Integrated Development Environment (Keil IDE) or any
other relevant software tool.
4. Debug program on IDE.
5. Execute program on IDE.
6. Create hex file for the program.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical trainer kits
and subsequently reducing e-waste
SAMPLE PROGRAM : To toggle Port Pin P1.5 with 10ms delay using Timer
Step 1: Algorithm
1. Load the TMOD value register indicating which timer (Timer 0 or Timer 1) is to be used and
which timer mode(0 or 1) is selected.
2. Load registers TL and TH with initial count values.
3. Start the timer.
4. Keep monitoring the timer flag (TF) with the “JNB TFx, target” instruction to see if it is
raised. Get out of the loop when TF becomes high.
5. Stop the timer.
6. Toggle Port pin high and low
7. Clear the TF flag for the next round.
8. Go back to Step 2 to load TH and TL again.
Step 2: Flowchart
Memory
Hex Code Label Mnemonics Comments
Address
ORG 0000H
C:0x0000 758901 MOV TMOD ,#01H ;Timer 0, mode 1
C:0x0003 758AFF REPEAT: MOV TL0,#0FFH ;TL0=FFH
C:0x0006 758CDB MOV TH0,#0DBH ;TH0=DBH
C:0x0009 D28C SETB TR0 ;start Timer 0
C:0x000B 308DFD AGAIN: JNB TF0, AGAIN ;monitor Timer 0 overflow
flag until it rolls over
C:0x000E C28C CLR TR0 ;stop Timer 0
C:0x0010 B295 CPL P1.5 ;toggle P1.5
Output Window
X Resources used
XI Actual Procedure Followed (use blank sheet provided if space not sufficient)
1. ………………………………………………………………………………………………
2. ………………………………………………………………………………………………
3. ………………………………………………………………………………………………
4. ………………………………………………………………………………………………
5. ………………………………………………………………………………………………
6. ………………………………………………………………………………………………
7. ………………………………………………………………………………………………
8. ………………………………………………………………………………………………
XII Observations for problem statement (use blank sheet provided if space not sufficient)
Draw Square wave and show TON and TOFF time
……………………………………………………………………………………………………
……………………………………………………………………………………………………
XIV Interpretation of Results (Give meaning of the above obtained results)
………………………………………………………………………………………………….…
…………………………………………………………………………………………………….
……………………………………………………………………….……………………………..
…………………………………………………………………………………….………………..
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
………………….………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
XVII References/Suggestions for further reading
1. http://nptel.ac.in/courses/Webcourse-contents/IIT-
KANPUR/microcontrollers/micro/ui/Course_home2_8.htm
2. http://www.circuitstoday.com/8051-timers-counters.
3. The 8051 Microcontroller and Embedded system Using Assembly and C- Muhammad Ali
Mazidi, Janice Gillispie Mazidi, Rolin D. Mckinlay- Pearson /Prentice Hall, , 2nd edition,
Delhi,2008, ISBN 978-8177589030.
I Practical Significance
Many applications require microcontrollers to either accept the data in serial form or output
the data in serial form. Serial communication is commonly used in applications such as
industrial automation systems, scientific analysis and certain consumer products. This
practical will help the students to develop skills to understand the concepts of serial port
and serial 8 bit data transfer.
Table No: 14.1 Values of Timer 1 Register for various Baud Rates
Baud Rate TH1(Decimal) TH1(Hex)
SMOD=0 SMOD=1
9600 19200 -3 FDH
4800 9600 -6 FAH
2400 4800 -12 F4H
1200 2400 -24 E8H
Note: XTAL = 11.0592 MHZ.
Sr . Instrument
Specification Quantity
No. /Components
Single board systems with 8K RAM, ROM memory
with battery back up,16X4,16 X2, LCD display, PC
1 Microcontroller kit keyboard interfacing facility, Hex keypad facility, 1 No.
single user cross c-compiler, RS-232, USB,
interfacing facility with built in power supply.
2. Desktop PC Loaded with open source IDE, simulation and 1 No.
program downloading software.
IX Procedure
Write Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL or INTEL and select 80c51AH 0r AT89C51.
5. Type the program in text editor and save as .asm or .a51.
Compile the Program
6. Right click on source group and build the target.
7. Check for any errors in the output window and remove if any.
Run, Debug the Program
8. Click on Debug and start simulation and start/stop debug session.
9. Run the program step by step.
10. Observe the output on the project window. It will display all internal registers of 8051 and
their contents. The output can be observed in UART1 window.
11. Hyper Terminal, a Windows XP application, can be used to receive or transmit serial data
through RS232. To open Hyper Terminal, go to Start Menu, select all programs, go to
Accessories, click on Communications and select Hyper Terminal.
12. To start a new connection, go to File menu and click on new connection. The connection
window opens up. Give a name to your connection and select 1st icon and click on OK.
Connection property window opens here. Select Bit rate as 9600bps, Data bits 8, Parity as
none, stop bit 1, Flow control none and click OK. Now the serial data can be read on hyper
terminal.
13. In program, Timer1 is used with auto reload setting. The baud rate is fixed to 9600bps by
loading TH1 to 0xFD. The value 0x50 is loaded in the SCON register. This will initialize the
serial port in Mode1. The program continuously transmits a character (say ‘A’) from 8051serial
port to Serial port of the computer.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical trainer kits
and subsequently reducing e-waste
SAMPLE PROGRAM: Write an ALP to transfer 8-bit data serially on serial port.
Step 1: Algorithm
Step 2: Flowchart
Output Window
Problem statement for student: Write a program to transfer message “MAA” at baud rate 4800 bps
X Resources used
XI Actual Procedure Followed (use blank sheet provided if space not sufficient)
1. ………………………………………………………………………………………………
2. ………………………………………………………………………………………………
3. ………………………………………………………………………………………………
4. ………………………………………………………………………………………………
5. ………………………………………………………………………………………………
6. ………………………………………………………………………………………………
7. ………………………………………………………………………………………………
8. ………………………………………………………………………………………………
XII Observations for problem statement (use blank sheet provided if space not sufficient)
(UART window)
……………………………………………………………………………………………………
……………………………………………………………………………………………………
XIV Interpretation of Results (Give meaning of the above obtained results)
………………………………………………………………………………………………….…
…………………………………………………………………………………………………….
……………………………………………………………………….……………………………..
…………………………………………………………………………………….………………..
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
1. https://embetronicx.com/tutorials/tech_devices/serial-communication-basics-tutorial-for-
beginners/
2. https://ebooks.inflibnet.ac.in/csp13/chapter/serial-port-communication/
3. https://www.codrey.com/embedded-systems/serial-communication-basics/
4. https://www.electronicwings.com/8051/8051-uart
Interrupt is a subroutine call that interrupts microcontrollers main operations or work and
causes it to execute any other program, which is more important at the time of operation. The
feature of Interrupt is very useful as it helps in case of emergency operations. An Interrupts
gives us a mechanism to put on hold the ongoing operations, execute a subroutine and then
again resume its original task.
̅̅̅̅̅̅̅ and
1. Generally five interrupt sources are there in 8051 Microcontroller. Out of these, INT0
̅̅̅̅̅̅̅
INT1 are external interrupts that could be negative edge triggered or low level triggered.
They are located on pins P3.2 and P3.3of port 3 respectively. They are enabled or disabled
using the IE register when the external interrupt flag is edge triggered, the CPU clears
interrupt flag in response to the interrupt call. When it is level triggered then the interrupt
flag is cleared at high level of the interrupt signal.
2. The table shows the vector addresses for the interrupts:
Light emitting diodes: LEDs are the most commonly used components in many
applications. It has two terminals positive and negative as shown in the figure:
Commonly used LEDs will have voltage drop of 1.9v to 2.1v and current of 15mA (Typically)
or 20mA(high brightness) to glow at full intensity. This is applied through the output pin of the
microcontroller.
VII Actual Circuit diagram used in laboratory with related equipment rating
a) Sample Circuit diagram
b) Practical setup
c) Simulation diagram
Sr. Instrument
Specification Quantity
No. /Components
1. Microcontroller Single board system with 8K RAM, ROM memory with 1 No.
kit battery backup,16X4,16X2LCD display, PC keyboard
interfacing facility, Hex keypad facility, single user cross
c-compiler, RS-232, USB, interfacing facility with built in
power supply.
2. Desktop PC Loaded with open-source IDE, simulation and program 1 No.
downloading software.
IX Precautions to be followed
1. Use always current limiting resistor before LED connected to microcontroller
X Procedure
1. Write algorithm for given problem.
2. Draw flowchart for the same.
3. Develop assembly program using Integrated Development Environment (Keil IDE) or
any other relevant software tool.
4. Debug program on IDE.
5. Execute program on IDE.
6. Create hex file for the program.
7. Download hex code in EPROM/Flash memory of microcontroller.
8. Interface LED to microcontroller as per circuit diagram shown in fig.
9. Observe the LED to glow when external interrupt occurs on P3.2.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
Step 1: Algorithm
Main Program
1. Initialize port P1 as output.
2. Initialize port P3 as input.
3. Clear pin P1.1
4. Enable interrupt INT0.
5. Wait for Interrupt.
INT0 ISR
1. Set pin P1.1
2. Return from ISR
Step 2: Flowchart
Memory
Hex Code Label Mnemonics Comments
Address
ORG 0000H
C:0x0000 020006 LJMP START
ORG 0003H Interrupt service routine for INT0
Problem statement for student Interface two LEDs with microcontroller and turn them ON
with microcontroller interrupts.
Step 1: Algorithm Step 2: Flowchart
XI Resources Used
2.
3.
XII Actual Procedure Followed (use blank sheet provided if space not sufficient)
1. …………………………………………………………………………………………
2. …………………………………………………………………………………………
3. …………………………………………………………………………………………
4. …………………………………………………………………………………………
5. …………………………………………………………………………………………
6. …………………………………………………………………………………………
7. …………………………………………………………………………………………
8. …………………………………………………………………………………………
……………………………………………………………………………………………..
………………………………………………………………………..……………………
………………………………………………………………………..…………………………
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………......
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………......
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………......
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………......
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
………………………………………………………………………………………………………………………………………………….....
Practical No. 16: Generating Pulse and Square wave using timer delay
I Practical Significance
The input/output (I/O) ports allow the microcontroller to connect to external devices and
peripherals. In 8051 timers are used to generate delays or as counters to count events
happening outside the microcontroller. In time required applications two available 16-bit
timers are operated in different modes to generate specific delay. This practical will help
the students to develop skills to program timers and generate delays for generating square
wave on I/O port pin.
Port pin can be toggled by using instruction CPL bit-address and /or by setting and resetting the
port pin by using instruction SETB bit-address and CLR bit address respectively.
To generate a Pulse / square wave of a particular pulse width , the delay time equal to pulse
width has to be generated using Timer.
Frequency = 2 KHZ
Time period T= 1/2 KHZ = 0.5 ms
Required time delay = TON = TOFF = T /2 = 0.5 ms / 2 = 0.25ms
b) Simulation diagram
Sr. Instrument
Specification Quantity
No. /Components
1. Microcontroller kit S Single board system with 8K RAM,ROM memory with 1 No.
battery backup,16X4,16X2LCD display, PC keyboard
interfacing facility, Hex keypad facility, single user cross
C-compiler,RS-232,USB, interfacing facility with built
in power supply.
2. Desktop PC Loaded with open source IDE, simulation and program 1 No.
downloading software.
3. CRO Bandwidth AC 10Hz ~ 20MHz (-3dB). DC ~ 20MHz (- 1 No.
3dB), X10 Probe
IX Precautions to be followed
1) Check rules / syntax of assembly language programming.
X Procedure
1. Write algorithm for given problem.
2. Draw flowchart for the same.
3. Develop assembly program using Integrated Development Environment (Keil IDE) or
any other relevant software tool.
4. Debug program on IDE.
5. Execute program on IDE.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical trainer
kits and subsequently reducing e-waste
SAMPLE PROGRAM: To generate Pulse with pulse width of 1ms on P1.0 using Timer 0 Mode1.
Assume XTAL = 11.0592MHz
Step 1: Algorithm
1. Load the TMOD register with value 01H, indicating Timer 0, Mode1
2. Clear Port pin P1.0
3. Call 1ms delay subroutine
4. Load registers TL0 and TH0 with initial count values for 1ms delay
5. Start the Timer 0.
6. Keep monitoring the timer flag (TF0) with the “JNB TF0, target” instruction to see if it is
raised. Get out of the loop when TF0 becomes high.
7. Stop Timer0
8. Clear the TF0 flag for the next round.
9. Set Port pin P1.0
10. Go back to Step 3.
Step 2: Flowchart
Memory
Hex Code Label Mnemonics Comments
Address
ORG 0000H
C:0X0000 758901 MOV TMOD ,#01H ;Timer 0, mode 1
C:0X0003 C290 UP: CLR P1.0 ; Clear port pin P1.0
C:0X0005 110D ACALL DELAY ; call 1ms delay subroutine
C:0X0007 D290 SETB P1.0 ; Set port pin P1.0
C:0X0009 110D ACALL DELAY ; call 1ms delay subroutine
C:0X000B 80F6 SJMP UP ; Repeat
C:0X000D 758A66 DELAY: MOV TL0,#66H ;TL0=66H
C:0X0010 758CFC MOV TH0,#0FCH ;TH0=FCH
C:0X0013 D28C SETB TR0 ;start Timer 0
C:0X0015 308DFD WAIT: JNB TF0, WAIT ;monitor Timer 0 overflow
flag until it rolls over
C:0X0018 C28C CLR TR0 ;stop Timer 0
C:0X001A C28D CLR TF0 ;clear Timer 0 overflow flag
C:0X001C 22 RET ;Return to main program
END
Problem statement for student: Write a program to generate square wave of frequency 2KHZ on
port pin P2.5 Using Timer 1, Mode 1. Assume XTAL = 11.0592MHz
XI Resources used
XII Actual Procedure Followed (use blank sheet provided if space not sufficient)
1. ………………………………………………………………………………………………
2. ………………………………………………………………………………………………
3. ………………………………………………………………………………………………
4. ………………………………………………………………………………………………
5. ………………………………………………………………………………………………
6. ………………………………………………………………………………………………
7. ………………………………………………………………………………………………
8. ………………………………………………………………………………………………
XIII Observations for problem statement (use blank sheet provided if space not sufficient)
Draw Square wave and show TON and TOFF time
……………………………………………………………………………………………………
……………………………………………………………………………………………………
XV Interpretation of Results (Give meaning of the above obtained results)
………………………………………………………………………………………………….…
…………………………………………………………………………………………………….
……………………………………………………………………….……………………………..
…………………………………………………………………………………….………………..
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
………………….………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
1. https://www.nbcafe.in/ports-in-8051-microcontroller/#google_vignette
2. https://econtent.msbte.edu.in/econtent/econtent_home.php
3. https://www.circuitstoday.com/delay-using-8051-timer
I Practical Significance
An LED matrix keyboard is a specialized input device that incorporates an LED matrix to enhance
visual feedback and aesthetic appeal. LED matrix displays are used as stadium displays, decorative
displays and as visual signals to human eye, to convey a message or meaning. LED matrix displays
are interfaced with microcontroller I/O port to display characters and different patterns. This practical
will help the students to develop skills to interface LED matrix display to microcontroller and display
various pattern.
Specifications: LED
1. Current: 20 mA
2. Voltage drop: 1.9 to 2.1 V
3. Power dissipation: 40 mW
4. Color: RED
Operation: Voltage +5V to anode with respect to cathode ground LED will turn ON.
Accessing individual LEDs :User can turn ON an individual LED by setting its row and column pins
to the proper logic 1.
For example, referring to figure 17.2 LED matrix the switch in column 2 is closed which ties the
anodes of all of the LEDs in that column to positive voltage and on the left the switch in row 1 is
closed causing a ground level to be applied to the cathode of all of the LEDs in that row. The LED at
the intersection of column 2 and row 1 is forward biased and turns on.
Fig 17.2 Addressing individual LED: 2nd column and 1st row
Sr. Instrument
Specification Quantity
No. /Components
1 Microcontroller Single board system with 8K RAM,ROM memory with 1 No.
kit battery backup,16X4,16X2LCD display, PC keyboard
interfacing facility, Hex keypad facility, single user
cross c-compiler,RS-232,USB, interfacing facility with
built in power supply.
2 Desktop PC Loaded with open source IDE, simulation and program 1 No.
downloading software.
3 4X4 LED Suitable to interface with 8051 trainer kit 1 No
matrix
IX Precautions to be Followed
1. Check rules / syntax of assembly programming.
X Procedure
Write Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL and select AT89C51.
5. Type the program in text editor and save as filename.asm extension.
Compile the Program
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical trainer kits
and subsequently reducing e-waste
SAMPLE PROGRAM 1: Write program to display various patterns on 4x4 LED matrix.
Step 1: Algorithm
1. Make port P2 used to interface 4x4 LED matrix as an output port.
2. Send F1H value to the port to turn ON first column all LED.
3. Add delay.
4. Send 1FH value to the port to display first row all LED.
5. Add delay.
6. Send 11H value to the port to display first column first row LED.
7. Add delay.
8. Send 88H value to the port to display fourth column fourth row LED.
9. Add delay.
10. For repeat operation go to step 2.
Step 2: Flowchart
Problem statement for student: Develop assembly program to turn ON and OFF all LEDs connected
to port 2 with 30 msec delay.
Memory Hex
Label Mnemonics Comments
Address Code
XI Resources Used:
XII Actual Procedure Followed (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
……….…………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
XIII Observations for sample program (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
1. Give the difference between Common Anode and Common Cathode Display.
2. Specify the power requirement for 4x4 LED Matrix.
3. List the applications of 4 x 4 matrix keyboard.
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
I Practical Significance
Seven segment display is a output display device used to display information in the form of
decimal numbers from 0 to 9 and in some cases, basic characters also. It is widely used in
digital clocks, basic calculators, electronic meters, and other electronic devices that display
numerical information. This practical will help the students to develop skills to interface
7-segment display to microcontroller and display decimal numbers.
Common Cathode: In common cathode type, the cathodes of all LEDs are tied together to a
single terminal which is usually labeled as ‘com’ and the anode of all LEDs are left alone as
individual pins labeled as a, b, c, d, e, f, g and h (or dot). To glow Common Cathode Segment
LED, common terminal is grounded and Logic 1 is applied on segment pin.
Common Anode: In common anode type, the anode of all LEDs are tied together as a single
terminal and cathodes are left alone as individual pins. Common Anode is tied to logic 1 and to
glow segment Led logic 0 is applied on segment Pin
Driving Pattern for Digit: Digit drive pattern of a seven segment LED display is simply the different
logic combinations of its terminals ‘a’ to ‘h’ in order to display different digits and characters. The
common digit drive patterns (0 to 9) of a seven-segment display are shown in the table below.
Digit Dp g f e d c b a HEX
CODE
Port P2.7 P2.6 P2.5 P2.4 P2.3 P2.2 P2.1 P2.0
0 1 1 0 0 0 0 0 0 C0H
1 1 1 1 1 1 0 0 1 F9H
2 1 0 1 0 0 1 0 0 A4H
3 1 0 1 1 0 0 0 0 B0H
4 1 0 0 1 1 0 0 1 99H
5 1 0 0 1 0 0 1 0 92H
6 1 0 0 0 0 0 1 0 82H
7 1 1 1 1 1 0 0 0 F8H
8 1 0 0 0 0 0 0 0 80H
9 1 0 0 1 0 0 0 0 90H
b) Practical Setup
c) Simulation diagram
Sr. Instrument
Specification Quantity
No. /Components
1. Microcontroller kit S Single board system with 8K RAM, ROM memory with 1 No.
battery backup,16X4,16X2LCD display, PC keyboard
interfacing facility, Hex keypad facility, single user cross
C-compiler, RS-232, USB, interfacing facility with built
in power supply.
2. Desktop PC Loaded with open-source IDE, simulation and program 1 No.
downloading software.
3.
7- Seven Segment LED0. 0. 56 in 1-digit Red, common anode/common cathode 1 No.
Display display.
IX Precautions to be followed
1) Always use current limiting resistor before interfacing 7-segment display to
microcontroller.
2) For safe operation use seven segment displays at 25° temperature.
3) Check rules / syntax of assembly language programming.
X Procedure
1. Write algorithm for given problem.
2. Draw flowchart.
3. Develop assembly program using Integrated Development Environment (Keil IDE) or
any other relevant software tool.
4. Debug program on IDE.
5. Execute program on IDE.
6. Create hex file.
7. Download hex code in EPROM/Flash memory of microcontroller.
8. Interface Common Anode type 7 segment display to microcontroller as per circuit
diagram shown in fig 18.4.
9. Observe and draw the display of numbers on 7-seven segment display.
10. Record the hex value in observation table.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
Step 1: Algorithm
1. Make the Port P2 as output port.
2. Set counter register R2 =10 for 0 to 9 digits.
3. Load DPTR with memory address where table is stored.
4. Clear Accumulator.
5. Read stored hex code of decimal digit from memory into Accumulator.
6. Send code to output port where 7-segment display is connected.
7. Increment memory pointer i.e., DPTR.
8. Decrement the counter register R2 and compare with 0 is counter =0? NO- go to step 4
to send next digit code.
9. For repeat operation go to step 2.
10. Stop
Step 2: Flowchart
Memory Hex
Label Mnemonics Comments
Address Code
ORG 0000H
C:0x0000 75A000 MOV P2,#00H ;Make Port2 as output port
C:0x0003 ;Set register as counter of 10
7A0A REPEAT: MOV R2,#10
bytes
C:0x0005 ;Load address of memory into
900300 MOV DPTR,#TABLE
Data pointer
C:0x0008 E4 UP: CLR A ;Clear accumulator
C:0x0009 ;Read hex code from memory
93 MOVC A,@A+DPTR
into accumulator
C:0x000A F5A0 MOV P2,A ;Send hex code to port2
C:0x000C 1113 ACALL DELAY
C:0x000E ;Increment memory pointer to
A3 INC DPTR
read next digit hex code
C:0x000F ; Decrement counter & jump if
DAF7 DJNZ R2,UP
not equal to zero to label UP.
C:0x0011 80F0 SJMP REPEAT ;Repeat loop
C:0x0013 7B19 DELAY: MOV R3, #25 ;Delay Subroutine
C:0x0015 7C64 L3: MOV R4,#100
C:0x0017 7D64 L2: MOV R5,#100
C:0x0019 DDFE L1: DJNZ R5,L1
C:0x001B DCFA DJNZ R4,L2
C:0x001D DBF6 DJNZ R3,L3
C:0x001F 22 RET
ORG 0300H
TABLE: DB 0C0H, 0F9H,
;Decimal 0 to 9 hex code stored at
0A4H, 0B0H, 99H,
code memory starting at location
92H, 82H, 0F8H, 80H,
0200H onward
90H
END
Memory
Hex Code Label Mnemonics Comments
Address
XI Resources used
XII Actual Procedure Followed (use blank sheet provided if space not sufficient)
1. ………………………………………………………………………………………………
2. ………………………………………………………………………………………………
3. ………………………………………………………………………………………………
4. ………………………………………………………………………………………………
5. ………………………………………………………………………………………………
6. ………………………………………………………………………………………………
7. ………………………………………………………………………………………………
8. ………………………………………………………………………………………………
XIII Observations for Problem statement (use blank sheet provided if space not sufficient)
……………………………………………………………………………………………………
……………………………………………………………………………………………………
XV Interpretation of Results (Give meaning of the above obtained results)
………………………………………………………………………………………………….…
…………………………………………………………………………………………………….
……………………………………………………………………….……………………………..
…………………………………………………………………………………….………………..
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
………………….………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
XVIII References/Suggestions for further reading
1. https://www.geeksforgeeks.org/seven-segment-displays/
2. https://www.electronics-tutorials.ws/blog/7-segment-display-tutorial.html
3. https://www.circuitstoday.com/interfacing-seven-segment-display-to-8051
I Practical Significance
Electromagnetic or solid-state relays are used in electronic applications to switch or control high
voltages or high currents. In Industrial applications low power devices microcontrollers drive
relays are used to control electrical loads beyond their direct drive capability. Electromechanical
protective relays are used to detect overload and other faults on electrical lines by opening and
closing circuit breakers. This practical will help the students to develop skills to interface relay
to microcontroller and turn it ON and OFF.
IX Precautions to be Followed
1. Check rules / syntax of assembly programming.
2. Use always driver circuit before interfacing relay to the microcontroller.
3. Use fly back diode to avoid voltage spikes
X Procedure
Write Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL and select AT89C51.
5. Type the program in text editor and save as filename.asm extension.
Compile the Program
6. Right click on source group and build the target.
7. Check for any errors in the output window and remove if any.
Run, Debug the Program
8. Click on Debug and start simulation and start/stop debug session.
9. Run the program step by step.
10. Observe the output on the project window.
11. Note the values of the result of various operations in the observation table.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical trainer kits
and subsequently reducing e-waste
SAMPLE PROGRAM 1: Write program to display various patterns on 4x4 LED matrix.
Step 1: Algorithm
1. Make the Port pin P1.0 used to Interface relay as an output pin.
2. Turn on relay by setting port bit.
3. Add delay
Step 2: Flowchart
XI Resources Used:
XII Actual Procedure Followed (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
……….…………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
……………………………………………………………………………………………………….
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
……………………………………………………………………………………………….…………
XIII Observations for sample program (use blank sheet provided if space not sufficient)
Sr. NO. Step Port Pin Status Logic 1 (+5V) / Logic 0 Relay Status
(0V) ON/OFF
1 Step 1 P2.0
2 Step 2 P2.0
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
……………………………………………………………………………………………………..…
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
……………………………………………………………………………………………………..…
1. Give the effect of driver circuit not connected while interfacing relay with microcontroller.
2. Draw the Interfacing diagram of microcontroller with relay using ULN 2803A IC.
3. Write Steps for testing a relay.
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………..……
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Practical No. 20: LCD interfacing to 8051 to display characters and decimal
numbers
I Practical Significance
Display units are the most important output devices in embedded projects and electronics
products. 16x2 LCD is one of the most used display unit. LCDs find application in consumer
appliances such as CD players, DVD players, digital watches, computers, etc. These are
commonly used in the screen industries. This practical will help the students to develop skills
to interface LCD with microcontroller to display the given integer and character.
LCD Commands:
Table 20.2 LCD Commands
Command Code
Sr.No. Instruction
(Hex)
1 0x30 Function Set: 8-bit, 1 Line, 5x7 Dots
2 0x38 Function Set: 8-bit, 2 Line, 5x7 Dots
3 0x20 Function Set: 4-bit, 1 Line, 5x7 Dots
4 0x28 Function Set: 4-bit, 2 Line, 5x7 Dots
5 0x06 Entry Mode
6 0x08 Display off Cursor off
7 0x0E Display on Cursor on
8 0x0C Display on Cursor off
9 0x0F Display on Cursor blinking
10 0x18 Shift entire display left
11 0x1C Shift entire display right
12 0x10 Move cursor left by one character
13 0x14 Move cursor right by one character
14 0x01 Clear Display (also clear DDRAM content)
15 0x80 + address* Set DDRAM address or cursor position on display
16 0x40 + address** Set CGRAM address or set pointer to CGRAM
location
Note: For more details of the commands refer Data sheet of LCD.
b) Practical Setup
c) Simulation diagram
Sr. Instrument
Specification Quantity
No. /Components
1. Microcontroller kit S Single board system with 8K RAM,ROM memory with 1 No.
battery backup,16X4,16X2LCD display, PC keyboard
interfacing facility, Hex keypad facility, single user cross
C-compiler,RS-232,USB, interfacing facility with built
in power supply.
2. Desktop PC Loaded with open source IDE, simulation and program 1 No.
downloading software.
3.
L LCD Trainer board0. Suitable to interface with 8051 trainer kit 1 No.
IX Precautions to be followed
1) Ensure proper connection before turning ON power supply to the kit.
2) Don’t apply pressure to the display surface.
2) Check rules / syntax of assembly language programming.
X Procedure
1. Write algorithm for given problem.
2. Draw flowchart for the same.
3. Develop assembly program using Integrated Development Environment (IDE) or any
other relevant software tool.
4. Debug program on IDE.
5. Execute program on IDE.
6. Create hex file for the above program.
7. Interface LCD display to microcontroller as per circuit diagram shown in Fig 20.2
8. Download hex code in EPROM/Flash memory of microcontroller
9. Observe output on LCD display
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
Step 1-Algorithm
1. Define control signals RS, RW and EN for LCD
2. Make LCD connected port as an output port.
3. Initialize LCD by sending commands.
4. Load DPTR with program memory address.
5. Set register as counter R2 =10(decimal) for to display “MICRO-8051"
6. Clear Accumulator
7. Read ASCII from code memory into Accumulator.
8. Send code to output port where LCD is connected.
9. Increment memory pointer.
10. Decrement R2 counter. Is count = 0 , then go to step 6.
11. Stop
Step 2: Flowchart
Memory Hex
Label Mnemonics Comments
Address Code
;Replace a bit address by a
RS EQU P2.3
symbol
RW EQU P2.4
EN EQU P2.5
ORG 0000H
;Set P1 as o/p port where
C:0x0000 759000 MOV P1, #00H
LCD is connected
;Call LCD initialize
C:0x0003 120015 LCALL LCD_INIT
subroutine
; Load program memory
C:0x0006 900100 MOV DPTR, #MSG
address into DPTR
C:0x0009 7A0A MOV R2, #10 ;Set counter of 10
C:0x000B E4 UP: CLR A
;Read data from memory
C:0x000C 93 MOVC A,@A+DPTR
into A register
C:0x000D 120037 LCALL DATAWRT
;Increment pointer to next
C:0x0010 A3 INC DPTR
location
C:0x0011 DAF8 DJNZ R2, UP ;Repeat loop for 10 times
C:0x0013 80FE HERE: SJMP HERE ; stop
; 2 lines and 5×7 matrix (8-
C:0x0015 7438 LCD_INIT: MOV A, #38H
bit mode)
C:0x0017 112A ACALL CMD
C:0x0019 740E MOV A, #0EH ; Display on, cursor on
C:0x001B 112A ACALL CMD
; Increment cursor (shift
C:0x001D 7406 MOV A, #06H
cursor to right)
C:0x001F 112A ACALL CMD
C:0x0021 7401 MOV A, #01H ; Clear display screen
C:0x0023 112A ACALL CMD
; Force cursor to beginning
C:0x0025 7480 MOV A, #80H
to 1st line
C:0x0027 112A ACALL CMD
C:0x0029 22 RET
C:0x002A F590 CMD: MOV P1,A ;Send command to lcd
C:0x002C C2A3 CLR RS ;Select command register
C:0x002E C2 A4 CLR RW ;Select write operation
C:0x0030 D2A5 SETB EN
C:0x0032 C2A5 CLR EN ;Latch command to lcd
C:0x0034 1144 ACALL DELAY ;Wait for sometime
C:0x0036 22 RET
Problem statement for student: Develop assembly language program to display “MSBTE” on
second line of LCD
Memory
Hex Code Label Mnemonics Comments
Address
XI Resources used
XII Actual Procedure Followed (use blank sheet provided if space not sufficient)
1. ………………………………………………………………………………………………
2. ………………………………………………………………………………………………
3. ………………………………………………………………………………………………
4. ………………………………………………………………………………………………
5. ………………………………………………………………………………………………
6. ………………………………………………………………………………………………
7. ………………………………………………………………………………………………
8. ………………………………………………………………………………………………
9. ………………………………………………………………………………………………
XIII Observations for Problem statement (use blank sheet provided if space not sufficient)
……………………………………………………………………………………………………
……………………………………………………………………………………………………
XV Interpretation of Results (Give meaning of the above obtained results)
………………………………………………………………………………………………….…
…………………………………………………………………………………………………….
……………………………………………………………………….……………………………..
…………………………………………………………………………………….………………..
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
………………….………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
XVIII References/Suggestions for further reading
1. https://circuitdigest.com/article/16x2-lcd-display-module-pinout-datasheet
2. https://www.dnatechindia.com/Interfacing-LCD-to-8051.html
3. https://circuitdigest.com/microcontroller-projects/lcd-interfacing-with-8051-microcontroller-
89s52
4. https://www.elprocus.com/lcd-interfacing-with-8051-microcontroller/
I Practical Significance
Keyboards allow users to input data directly into an embedded system. This interaction is
essential for devices that require user configuration, command entry, or data input, enhancing
usability and functionality. A keyboard interface with an 8051 microcontroller can be
customized to handle various types of keyboards and input methods. This flexibility allows
developers to design interfaces that best suit their specific application needs. This practical
will help the students to develop skills to interface given keyboard to the microcontroller and
display key pressed.
Table 21.1 4x4 Keypad: - Rows (R1, R2, R3, R4) Columns (C1, C2, C3, C4)
(Refer Fig.15.2)
Step1:- Make R1- 0 Checks C1, C2, C3,C4 Step3:- Make R3- 0 Checks C1, C2, C3,C4
If C1=0 – ‘0’ is pressed If C1=0 – ‘8’ is pressed
If C2=0 – ‘1’ is pressed If C2=0 – ‘9’ is pressed
If C3=0 – ‘2’ is pressed If C3=0 – ‘A’ is pressed
If C3=0 – ‘3’ is pressed If C3=0 – ‘B’ is pressed
Step2:- Make R2- 0 Checks C1, C2, C3,C4 Step4:- Make R4- 0 Checks C1, C2, C3,C4
If C1=0 – ‘4’ is pressed If C1=0 – ‘C’ is pressed
If C2=0 – ‘5’ is pressed If C2=0 – ‘D’ is pressed
If C3=0 – ‘6’ is pressed If C3=0 – ‘E’ is pressed
If C3=0 – ‘7’ is pressed If C3=0 – ‘F’ is pressed
b) Practical Setup:
c) Simulation Diagram:
IX Precautions to be Followed
1. Check rules / syntax of assembly programming.
X Procedure
Write Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL and select AT89C51.
5. Type the program in text editor and save as filename.asm extension.
Compile the Program
6. Right click on source group and build the target.
7. Check for any errors in the output window and remove if any.
Run, Debug the Program
8. Click on Debug and start simulation and start/stop debug session.
9. Run the program step by step.
10. Observe the output on the project window.
11. Note the values of the result of various operations in the observation table.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
Memory
Hex Code Label Mnemonics Comments
Address
C:0x003D 309453 JNB COL1,KC
C:0x0040 309556 JNB COL2,KD
C:0x0043 309659 JNB COL3,KE
C:0x0046 30975C JNB COL4,KF
C:0x0049 80BA SJMP KEYSCAN ;repeat scanning
C:0x004B 7430 K0: MOV A,#”0” ;key 0 detected
C:0x004D 11CD ACALL DISPLAY
C:0x004F 0105 AJMP KEYSCAN
C:0x0051 7431 K1: MOV A,#”1” ;key 1 detected
C:0x0053 11CD ACALL DISPLAY
C:0x0055 0105 AJMP KEYSCAN
C:0x0057 7432 K2: MOV A,#”2” ;key 2 detected
C:0x0059 11CD ACALL DISPLAY
C:0x005B 0105 AJMP KEYSCAN
C:0x005D 7433 K3: MOV A,#”3” ;key 3 detected
C:0x005F 11CD ACALL DISPLAY
C:0x0061 0105 AJMP KEYSCAN
C:0x0063 7434 K4: MOV A,#”4” ;key 4 detected
C:0x0065 11CD ACALL DISPLAY
C:0x0067 0105 AJMP KEYSCAN
C:0x0069 7435 K5: MOV A,#”5” ;key 5 detected
C:0x006B 11CD ACALL DISPLAY
C:0x006D 0105 AJMP KEYSCAN
C:0x006F 7436 K6: MOV A,#”6” ;key 6 detected
C:0x0071 11CD ACALL DISPLAY
C:0x0073 0105 AJMP KEYSCAN
C:0x0075 7437 K7: MOV A,#”7” ;key 7 detected
C:0x0077 11CD ACALL DISPLAY
C:0x0079 0105 AJMP KEYSCAN
C:0x007B 7438 K8: MOV A,#”8” ;key 8 detected
C:0x007D 11CD ACALL DISPLAY
C:0x007F 0105 AJMP KEYSCAN
C:0x0081 7439 K9: MOV A,#”9” ;key 9 detected
C:0x0083 11CD ACALL DISPLAY
C:0x0085 0105 AJMP KEYSCAN
Maharashtra State Board of Technical Education ‘K-Scheme’
224
Microcontroller & Applications (314340)
Memory
Hex Code Label Mnemonics Comments
Address
C:0x0087 7441 KA: MOV A,#”A” ;key A detected
C:0x0089 11CD ACALL DISPLAY
C:0x008B 0105 AJMP KEYSCAN
C:0x008D 7442 KB: MOV A,#”B” ;key B detected
C:0x008F 11CD ACALL DISPLAY
C:0x0091 0105 AJMP KEYSCAN
C:0x0093 7443 KC: MOV A,#”C” ;key C detected
C:0x0095 11CD ACALL DISPLAY
C:0x0097 0105 AJMP KEYSCAN
C:0x0099 7444 KD: MOV A,#”D” ;key D detected
C:0x009B 11CD ACALL DISPLAY
C:0x009D 0105 AJMP KEYSCAN
C:0x009F 7445 KE: MOV A,#”E” ;key E detected
C:0x00A1 11CD ACALL DISPLAY
C:0x00A3 0105 AJMP KEYSCAN
C:0x00A5 7446 KF: MOV A,#”F” ;key F detected
C:0x00A7 11CD ACALL DISPLAY
C:0x00A9 0105 AJMP KEYSCAN
C:0x00AB 7438 LCDINIT: MOV A,#38H ;init LCD 2 lines, 5x7 matrix
C:0x00AD 11C0 ACALL COMMAND
C:0x00AF 740E MOV A,#0EH ;LCD on cursor on
C:0x00B1 11C0 ACALL COMMAND
C:0x00B3 7406 MOV A,#06H ;clear LCD command
C:0x00B5 11C0 ACALL COMMAND
C:0x00B7 7401 CLEAR: MOV A,#01H ;shift cursor right
C:0x00B9 11C0 ACALL COMMAND
;Force cursor to beginning of 1st
C:0x00BB 7480 MOV A,#80H
line
C:0x00BD 11C0 ACALL COMMAND
C:0x00BF 22 RET
COMMAND
C:0x00C0 F580 MOV P0,A ;issue command code
:
C:0x00C2 C2A5 CLR RS
C:0x00C4 C2A6 CLR RW
C:0x00C6 D2A7 SETB EN
Memory
Hex Code Label Mnemonics Comments
Address
C:0x00C8 11DE ACALL DELAY
C:0x00CA C2A7 CLR EN
C:0x00CC 22 RET
C:0x00CD F580 DISPLAY: MOV P0,A ;issue data
C:0x00CF D2A5 SETB RS
C:0x00D1 C2A6 CLR RW
C:0x00C3 D2A7 SETB EN
C:0x00D5 11DE ACALL DELAY
C:0x00D7 C2A7 CLR EN
C:0x00D9 11DE ACALL DELAY ;add delay
C:0x00DB 11B7 ACALL CLEAR ;LCD clear
C:0x00DD 22 RET
C:0x00DE 7B32 MOV R3,#50
C:0x00E0 7CFF MOV R4,#255
C:0x00E2 DCFE DELAY: DJNZ R4,LOOP1
C:0x00E4 DBFA LOOP2: DJNZ R3,LOOP2
C:0x00E6 22 LOOP1: RET
END
XI Resources Used:
XII Actual Procedure Followed (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
……………………….…………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XIII Observations for sample program (use blank sheet provided if space not sufficient)
1 4
2 5
3 A
4 C
5 F
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
1. If the switch 3 is pressed which column & row show logic 0 at respective port pin?.
2. Explain debounce effect.
3. Write down following requirement of port pins and number of switches.
No of switches Rows Port Columns Port
Matrix Keypad
Pins Pins
1x4 Matrix Keypad
3x4 Matrix Keypad
4x4 Matrix Keypad
8x8 Matrix Keypad
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
I Practical Significance
ADC (Analog to digital converter) forms a very essential part in many embedded projects. In
industry and automated instruments, the signals sensed and processed by humans are analog
signals. Analog-to-digital conversion is the means by which analog signals are converted into
digital data that can be processed by computers for various purposes. This practical will help
the students to develop skills to interface given ADC to the microcontroller and verify the input
and output.
b) Practical Setup:
c) Simulation Diagram:
IX Precautions to be Followed
1. Check rules / syntax of assembly programming.
2. Refer datasheet for to provide clock frequency to ADC 0808 chip.
3. Care must be taken while taking observations during power up.
4. Use current limiting resistors for LED’s.
X Procedure
Write Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL and select AT89C51.
5. Type the program in text editor and save as filename.asm extension.
Compile the Program
6. Right click on source group and build the target.
7. Check for any errors in the output window and remove if any.
Run, Debug the Program
8. Click on Debug and start simulation and start/stop debug session.
9. Run the program step by step.
10. Observe the output on the project window.
11. Note the values of the result of various operations in the observation table.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
SAMPLE PROGRAM 1: Write a program to read the data from ADC and display on LEDs.
Step1- Algorithm
1. Select an analog channel by providing bits to A, B, and C addresses according to the
analog signal selection table.
Maharashtra State Board of Technical Education ‘K-Scheme’
234
Microcontroller & Applications (314340)
Note: In ADC0808 that there is no self-clocking and the clock must be provided from
an external source to the CLK pin. Although the speed of conversion depends on the
frequency of the clock connected to the CLK pin, it cannot be faster than 100
microseconds.
ACALL DELAY
C:0X0011 112F
Sets ALE high
C:0X0013 D2A4 SETB P2.4
ACALL DELAY
C:0X0015 112F
Sends a command to start of
C:0X0017 D2A6 SETB P.26
conversion pulse.
C:0X0019 112F ACALL DELAY
CLR P2.4
C:0X001B C2A4 Makes ALE low
Makes start pin low
C:0X001D C2A6 CLR P2.6
Waits for low pulse at EOC
C:0X001F 20A7FD HERE: JB P2.7, HERE
HERE1:
C:0X0022 30A7FD JNB P2.7, HERE1 Waits for low pulse to finish
Enables OE pin to extract data from
C:0X0025 D2A5 SETB P2.5 ADC
ACALL DELAY
C:0X0027 112F
Moves acquired data to accumulator
C:0X0029 E590 MOV A, P1
Clears OE
C:0X002B C2A5 CLR P2.5
SJMP BACK
C:0X002D 80DC Repeatedly gets data from ADC
DELAY: MOV R3, #50
C:0X002F 7B32
HERE2: MOV R4, #255
C:0X0031 7CFF
DJNZ R4, HERE3
C:0X0033 DCFE
Memory Hex
Label Mnemonics Comments
Address Code
C;0X0035 DBFA DJNZ R3, HERE 2
RET
C:0X0037
END
XI Resources Used:
XII Actual Procedure Followed (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
……………………….…………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XIII Observations for sample program (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
I Practical Significance
The digital to analog converter (DAC) is a device widely used to convert digital pulses to
analog signals. This practical will help the students to develop skills to interface DAC with
8051 and generate different analog waveforms.
II Industry/Employer expected outcome(s)
Maintain microcontroller-based systems.
𝐷7 𝐷6 𝐷5 𝐷4 𝐷3 𝐷2 𝐷1 𝐷0
𝐼𝑜𝑢𝑡 = 𝐼𝑟𝑒𝑓 ( + + + + + + + )
2 4 8 16 32 64 128 256
The Iref is the input current. This must be provided into the pin 14. Generally, 2.0mA is used as
Iref. Iout pin is connected to the resistor to convert the current to voltage.
b) Practical Setup:
c) Simulation Diagram:
Sr. Instrument
Specification Quantity
No. /Components
1 Microcontroller Single board systems with 8K RAM,ROM 1 No.
kit memory with battery backup,16X4,16X2LCD
display, PC keyboard interfacing facility, Hex
keypad facility, single user cross c-compiler,RS-
232,USB, interfacing facility with built in power
supply.
2 Desktop PC Loaded with open source IDE, simulation and 1 No.
program downloading software
3 DAC (0808) Suitable to interface 8051 board. 1 No
trainer board
IX Precautions to be Followed
1. Check rules / syntax of assembly programming.
2. Operate DAC chip as per specifications given in the datasheet otherwise damage may
occur to the device.
X Procedure
Write Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL and select AT89C51.
5. Type the program in text editor and save as filename.asm extension.
Compile the Program
6. Right click on source group and build the target.
7. Check for any errors in the output window and remove if any.
Run, Debug the Program
8. Click on Debug and start simulation and start/stop debug session.
9. Run the program step by step.
10. Observe the output on the project window.
11. Note the values of the result of various operations in the observation table.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
4. Call Delay
5. Send FFH value to port 1
6. Call Delay.
7. For repeat operation go to step3.
Memory
Hex Code Label Mnemonics Comments
Address
ORG 0000h
C:0x0000 7400 MAIN: MOV A, #00h Clear A
C:0x0002 F590 MOV P1, A Send value to P1
C:0x0004 110E ACALL DELAY Call Delay
Move Highest value in
C:0x0006 74FF MOV A, #FFH
Accumulator
C:0x0008 F590 MOV P1, A Send value to P1
C:0x000A 110E ACALL DELAY Decrement value
Compare with lowest
C:0x000C SJMP MAIN
value
DELAY
Memory
Hex Code Label Mnemonics Comments
Address
C:0x000E 78FF MOV R0, #100 Initialize Delay register
C:0X0010 79FF HERE 1: MOV R1, #100
C:0x0012 D9FE Repeat till R1 becomes
HERE: DJNZ R1, HERE
zero
C:0X0014 D8FA Repeat till R1 becomes
DJNZ R0, HERE1
zero
C:0X0016 22 RET
END
Problem statement for student: Develop assembly program to generate a square wave with
ON time of 3msec and OFF time of 5 msec. {Assume suitable crystal frequency}
Step 1-Algorithm Step 2-Flowchart
XI Resources Used:
XII Actual Procedure Followed (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
……………………….…………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XIII Observations for sample program (use blank sheet provided if space not sufficient)
Trace the waveform for the square waveform observed on CRO.
…………………………………………………………………………………………………
…………………………………………………………………………………………………
Maharashtra State Board of Technical Education ‘K-Scheme’
248
Microcontroller & Applications (314340)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XV Interpretation of Results (Give meaning of the above obtained results)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
Maharashtra State Board of Technical Education ‘K-Scheme’
249
Microcontroller & Applications (314340)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
I Practical Significance
The digital to analog converter (DAC) is a device widely used to convert digital pulses to
analog signals. This practical will help the students to develop skills to interface DAC with
8051 and generate different analog waveforms.
𝐷7 𝐷6 𝐷5 𝐷4 𝐷3 𝐷2 𝐷1 𝐷0
𝐼𝑜𝑢𝑡 = 𝐼𝑟𝑒𝑓 ( + + + + + + + )
2 4 8 16 32 64 128 256
The Iref is the input current. This must be provided into the pin 14. Generally, 2.0mA is used as
Iref. Iout pin is connected to the resistor to convert the current to voltage.
b) Practical Setup:
c) Simulation Diagram:
Sr. Instrument
Specification Quantity
No. /Components
1 Microcontroller Single board systems with 8K RAM, ROM 1 No.
kit memory with battery backup,16X4,16X2LCD
display, PC keyboard interfacing facility, Hex
keypad facility, single user cross c-compiler, RS-
232, USB, interfacing facility with built in power
supply.
2 Desktop PC Loaded with open-source IDE, simulation and 1 No.
program downloading software
3 DAC (0808) Suitable to interface 8051 board. 1 No
trainer board
IX Precautions to be Followed
1. Check rules / syntax of assembly programming.
2. Operate DAC chip as per specifications given in the datasheet otherwise damage may
occur to the device.
X Procedure
Write Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL and select AT89C51.
5. Type the program in text editor and save as filename.asm extension.
Compile the Program
6. Right click on source group and build the target.
7. Check for any errors in the output window and remove if any.
Run, Debug the Program
8. Click on Debug and start simulation and start/stop debug session.
9. Run the program step by step.
10. Observe the output on the project window.
11. Note the values of the result of various operations in the observation table.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
Memory
Hex Code Label Mnemonics Comments
Address
ORG 0000h
C:0x0000 7400 REPEAT: MOV A, #00h Clear A
C:0x0002 F590 INCR: MOV P0, A Send value to P1
C:0x0004 04 INC A Increment value
Compare with highest
C:0x0005 B4FFFA CJNE A,#0FFh,INCR
value
C:0x0008 F590 DECR: MOV P0, A Send value to P1
C:0x000A 14 DEC A Decrement value
Compare with lowest
C:0x000B B400FA CJNE A, #00h, DECR
value
C:0x000E 80F0 SJMP REPEAT Repeat
END
Problem statement for student: Develop assembly program to generate sawtooth waveform
using DAC 0808
XI Resources Used:
XII Actual Procedure Followed (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
……………………….…………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XIII Observations for sample program (use blank sheet provided if space not sufficient)
Trace the waveform for the triangular waveform observed on CRO.
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
3. https://peripheralinterfacing.wordpress.com/digital-to-analog-converter-using-8051-
microcontroller/
I Practical Significance
Stepper motors are commonly used in a wide range of applications such as robotics, CNC
machines, 3D printers, medical equipment, and automated manufacturing machinery where
precise speed control and accuracy are necessary. Stepper motors are controlled by
microcontrollers in areas such as computer peripherals, Business machines, process control
and for making robots. This practical will help the students to develop skills to interface
stepper motor to 8051 and rotate in clockwise direction at the given angles
Interface stepper motor to microcontroller and rotate in clockwise direction at the given angles
Stepper motor converts electrical energy into precise mechanical motion. It rotates a
specific incremental distance per step. Every discrete step of a stepper motor is measured
in degree (it can be 1.8° or even smaller depending on the stepper motor type and stepping
technique).
It works on the principle of electromagnetism. There is a magnetic rotor shaft of soft iron which is
surrounded by the electromagnetic stators. When the stators are energized the rotor moves to
align itself along with the stator (in case of a permanent magnet type stepper) or moves to have a
minimum gap with the stator (in case of variable reluctance stepper). In this way the stators are
energized in a sequence to rotate stepper motor
Generally, stepper motors are classified into two types according to windings as:
• Unipolar
• Bipolar
The unipolar stepper motors, has one winding per phase, with a center tap. It has five or six wires
and four coils (actually two coils divided by center connections on each coil). The centre
connections of the coils are tied together and used as the power connection. They are called unipolar
stepper motors because power always comes in one pole.
The Bipolar stepper motor has four wires with no common center connection. It has two
independent sets of coils.
Step angle:
Step angle is defined as the minimum degree of rotation with a single step.
Number of steps per revolution = 360° / step angle
Steps per second = (RPM x steps per revolution) / 60
2
3
4
0
0
0
1
0
0
0
1
0
0
0
1
b. Full Drive Stepping Mode (TWO PHASE ON)
Anti-
Clockwise Step # Winding A Winding B Winding C Winding D
Clockwise
1 1 0 0 1
2
3
4
1
0
0
1
1
0
0
1
1
0
0
1
Half Step Sequence:
• Half Drive mode:
To allow for finer resolution, all stepper motors allow an 8-step switching sequence.
Clockwise Step Winding A Winding B Winding C Winding D Clockwise
1 1 0 0 1
2 1 0 0 0
3 1 1 0 0
4
5
6
0
0
0
1
1
0
0
1
1
0
0
0
7 0 0 1 1
8 0 0 0 1
b) Practical setup
c) Simulation diagram
Sr. Instrument
Specification Quantity
No. /Components
1. Microcontroller kit S Single board system with 8K RAM,ROM memory with 1 No.
battery backup,16X4,16X2LCD display, PC keyboard
interfacing facility, Hex keypad facility, single user cross
C-compiler,RS-232,USB, interfacing facility with built
in power supply.
2. Desktop PC Loaded with open source IDE, simulation and program 1 No.
downloading software.
3.S Stepper Motor 0. 1.8° Step angle, 50/100 RPM Stepper motor with 1 No.
Trainer ULN 2003/2803 Driver.
IX Precautions to be followed
1) Ensure proper connection before turning ON power supply to the kit.
2) Always use driver circuit while interfacing stepper motor to microcontroller.
3) Check rules / syntax of assembly language programming.
X Procedure
1. Write algorithm for given problem.
2. Draw flowchart for the same.
3. Develop assembly program using Integrated Development Environment (IDE) or any other
relevant software tool.
4. Debug program on IDE.
5. Execute program on IDE.
6. Create hex file for the above program.
7. Download hex code in EPROM/Flash memory of the microcontroller.
8. Interface stepper motor to microcontroller as per circuit diagram shown in fig 25.3
9. Observe rotation of stepper motor and record in observation Table.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical trainer kits
and subsequently reducing e-waste
SAMPLE PROGRAM: Write a program to rotate stepper motor in clockwise direction by 3600
Assume step angle of 1.8o
Step 1-Algorithm
Fig 25.6 Flowchart for stepper motor to rotate in clockwise direction by 360o
Memory
Hex Code Label Mnemonics Comments
Address
ORG 0000H
C:0x0000 7932 MOV R1,#50 ; Load count =50 for 3600 rotation
C:0x0002 759099 UP: MOV P1,#99H ; Send first step sequence to Port 1
C:0x0005 111A ACALL DELAY ; Call delay subroutine
C:0x0007 7590CC MOV P1,#0CCH ; Send second step sequence to Port 1
C:0x000A 111A ACALL DELAY ; Call delay subroutine
C:0x000C 759066 MOV P1,#66H ; Send third step sequence to Port 1
C:0x000F 111A ACALL DELAY ; Call delay subroutine
C:0x0011 759033 MOV P1,#33H ; Send fourth step sequence to Port 1
C:0x0014 111A ACALL DELAY ; Call delay subroutine
C:0x0016 D9EA DJNZ R1,UP ;Repeat 50 times
C:0x0018 80FE HERE: SJMP HERE ;stop
C:0x001A 7BFF DELAY: MOV R3,#255 ;Delay subroutine
C:0x001C 7CFF L2: MOV R4,#255
C:0x001E DCFE L1: DJNZ R4,L1
C:0x0020 DBFA DJNZ R3,L2
C:0x0022 22 RET
END
Problem statement for student: Write a program to rotate stepper motor in clockwise direction by
1800. Use Full step sequence
XI Resources used
XII Actual Procedure Followed (use blank sheet provided if space not sufficient)
1. ………………………………………………………………………………………………
2. ………………………………………………………………………………………………
3. ………………………………………………………………………………………………
4. ………………………………………………………………………………………………
5. ………………………………………………………………………………………………
6. ………………………………………………………………………………………………
7. ………………………………………………………………………………………………
8. ………………………………………………………………………………………………
XIII Observations sample program (use blank sheet provided if space not sufficient)
……………………………………………………………………………………………………
……………………………………………………………………………………………………
XV Interpretation of Results (Give meaning of the above obtained results)
………………………………………………………………………………………………….…
…………………………………………………………………………………………………….
……………………………………………………………………….……………………………..
…………………………………………………………………………………….………………..
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
………………….………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
1. https://www.monolithicpower.com/learning/resources/stepper-motors-basics-types-uses
2. https://www.portescap.com/en/products/stepper-motor-control
3. http://vlabs.iitkgp.ernet.in/rtes/exp10/index.html#
4. https://www.tutorialspoint.com/interfacing-stepper-motor-with-8051microcontroller
Practical No. 26: Stepper Motor interfacing to 8051 for rotating anticlockwise
I Practical Significance
Stepper motors are commonly used in a wide range of applications such as robotics, CNC
machines, 3D printers, medical equipment, and automated manufacturing machinery where
precise speed control and accuracy are necessary. Stepper motors are controlled by
microcontrollers in areas such as computer peripherals, Business machines, process control
and for making robots. This practical will help the students to develop skills to interface
stepper motor to 8051 and rotate in clockwise direction at the given angles
It works on the principle of electromagnetism. There is a magnetic rotor shaft of soft iron which is
surrounded by the electromagnetic stators. When the stators are energized the rotor moves to
align itself along with the stator (in case of a permanent magnet type stepper) or moves to have a
minimum gap with the stator (in case of variable reluctance stepper). In this way the stators are
energized in a sequence to rotate stepper motor
Generally, stepper motors are classified into two types according to windings as:
• Unipolar
• Bipolar
The unipolar stepper motors, has one winding per phase, with a center tap. It has five or six wires
and four coils (actually two coils divided by center connections on each coil). The centre
connections of the coils are tied together and used as the power connection. They are called unipolar
stepper motors because power always comes in one pole.
The Bipolar stepper motor has four wires with no common center connection. It has two
independent sets of coils.
Step angle:
Step angle is defined as the minimum degree of rotation with a single step.
Number of steps per revolution = 360° / step angle
Steps per second = (RPM x steps per revolution) / 60
Anti-
Clockwise Step # Winding A Winding B Winding C Winding D
Clockwise
1 1 0 0 0
2
3
4
0
0
0
1
0
0
0
1
0
0
0
1
b. Full Drive Stepping Mode (TWO PHASE ON)
Table 26.3 Wave Drive Stepping Mode (ONE PHASE ON )
Anti-
Clockwise Step # Winding A Winding B Winding C Winding D
Clockwise
1 1 0 0 1
2
3
4
1
0
0
1
1
0
0
1
1
0
0
1
Half Step Sequence:
• Half Drive mode:
To allow for finer resolution, all stepper motors allow an 8-step switching sequence.
Table 26.4 8 Step Switching Sequence (ONE PHASE ON )
3 1 1 0 0
4
5
6
0
0
0
1
1
0
0
1
1
0
0
0
7 0 0 1 1
8 0 0 0 1
b) Practical setup
Sr. Instrument
Specification Quantity
No. /Components
1. Microcontroller kit S Single board system with 8K RAM, ROM memory with 1 No.
battery backup,16X4,16X2LCD display, PC keyboard
interfacing facility, Hex keypad facility, single user cross
C-compiler, RS-232, USB, interfacing facility with built
in power supply.
2. Desktop PC Loaded with open-source IDE, simulation and program 1 No.
downloading software.
3.S Stepper Motor 0. 1.8° Step angle, 50/100 RPM Stepper motor with 1 No.
Trainer ULN 2003/2803 Driver.
IX Precautions to be followed
1) Ensure proper connection before turning ON power supply to the kit.
2) Always use driver circuit while interfacing stepper motor to microcontroller.
3) Check rules / syntax of assembly language programming.
X Procedure
1. Write algorithm for given problem.
2. Draw flowchart for the same.
3. Develop assembly program using Integrated Development Environment (IDE) or any other
relevant software tool.
4. Debug program on IDE.
5. Execute program on IDE.
6. Create hex file for the above program.
7. Download hex code in EPROM/Flash memory of the microcontroller.
8. Interface stepper motor to microcontroller as per circuit diagram shown in fig 26.3
9. Observe rotation of stepper motor and record in observation Table.
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical trainer kits
and subsequently reducing e-waste
SAMPLE PROGRAM: Write a program to rotate stepper motor in anti-clockwise direction by1800
Assume step angle of 1.8o Use half step sequence
Step 1-Algorithm
Fig 26.6 Flowchart for stepper motor to rotate in anti-clockwise direction by 180o
Memory Hex
Label Mnemonics Comments
Address Code
ORG 0000H
C:0x0000 759000 MOV P1,#00H ;Define port P1 as output port
;Set register as counter of 25 for
C:0x0003 7A19 MOV R2,#25
1800 rotation
;set counter of 8 for half step code
C:0x0005 7B08 UP1: MOV R3,#8
sequence
;load address of program memory
C:0x0007 900200 MOV DPTR,#TABLE
into Data pointer
C:0x000A E4 UP: CLR A ;clear accumulator
;read step code from memory into
C:0x000B 93 MOVC A,@A+DPTR
accumulator
C:0x000C F590 MOV P1,A ;send step code to port
C:0x000E 1117 ACALL DELAY ;add delay
;increment memory pointer to read
C:0x0010 A3 INC DPTR
next step code
; decrement counter & jump to
C:0x0011 DBF7 DJNZ R3,UP memory location labeled as UP if
not equal to zero.
; decrement counter & jump to
C:0x0013 DAF0 DJNZ R2,UP1 memory location labeled as UP1 if
not equal to zero.
C:0x0015 80FE HERE: SJMP HERE ;wait
C:0x0017 7C64 DELAY: MOV R4,#100 ;delay Subroutine
C:0x0019 7D19 L3: MOV R5,#25
C:0x001B 7E19 L2: MOV R6,#25
C:0x001D DEFE L1: DJNZ R6,L1
C:0x001F DDFA DJNZ R5,L2
C:0x0021 DCF6 DJNZ R4,L3
C:0x0023 22 RET
ORG 0050H
DB 01H,03H,02H,
; Step code stored at code memory
C:0x0050 TABLE: 06H, 04H, 0CH,08H,
starting at location 0050H onward.
09H,
END
Problem statement for student: Write a program to rotate stepper motor in anti-clockwise direction
by 3600. Use full step sequence. Assume step angle of 1.80
XI Resources used
XII Actual Procedure Followed (use blank sheet provided if space not sufficient)
1. ………………………………………………………………………………………………
2. ………………………………………………………………………………………………
3. ………………………………………………………………………………………………
4. ………………………………………………………………………………………………
5. ………………………………………………………………………………………………
6. ………………………………………………………………………………………………
7. ………………………………………………………………………………………………
8. ………………………………………………………………………………………………
XIII Observations for sample Program (use blank sheet provided if space not sufficient)
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
XV Interpretation of Results (Give meaning of the above obtained results)
………………………………………………………………………………………………….…
…………………………………………………………………………………………………….
………………………………………………………………………………………………….…
……………………………………………………………………….……………………………..
…………………………………………………………………………………….………………..
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
………………….………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
1. https://www.monolithicpower.com/learning/resources/stepper-motors-basics-types-uses
2. https://www.portescap.com/en/products/stepper-motor-control
3. http://vlabs.iitkgp.ernet.in/rtes/exp10/index.html#
4. https://www.tutorialspoint.com/interfacing-stepper-motor-with-8051microcontroller
I Practical Significance
The control of water levels is critical in various environmental and industrial contexts. Water
level control is essential for flood control, water supply management, ecosystem stability,
energy production, climate resilience, infrastructure protection, and navigational safety. This
practical will help the students to develop water level controller using 8051 and display the
status of Water tank on LCD.
II Industry/Employer expected outcome(s)
Maintain microcontroller-based systems.
a) Simulation Diagram:
Sr. Instrument
Specification Quantity
No. /Components
1 Microcontroller Single board systems with 8K RAM, ROM 1 No.
kit memory with battery backup,16X4,16X2LCD
display, PC keyboard interfacing facility, Hex
keypad facility, single user cross c-compiler, RS-
232, USB, interfacing facility with built in power
supply.
2 Desktop PC Loaded with open-source IDE, simulation and 1 No.
program downloading software
3 Resistor 10 Kilo Ohms 1No.
4. Liquid Crystal 16 x 2 LCD 1 No.
Display
5. Simple DC Nominal Voltage 12V, Load Resistance 12 Ohms 1No.
Motor
IX Precautions to be Followed
1. Check rules / syntax of assembly programming.
2. Operate DAC chip as per specifications given in the datasheet otherwise damage may
occur to the device.
X Procedure
Write Program
1. Start Keil by double clicking on Keil icon.
2. Create a new project.
3. Select device for Target.
4. Double click on ATMEL and select AT89C51.
5. Type the program in text editor and save as filename.asm extension.
Compile the Program
6. Right click on source group and build the target.
7. Check for any errors in the output window and remove if any.
Run, Debug the Program
8. Click on Debug and start simulation and start/stop debug session.
9. Run the program step by step.
10. Observe the output on the project window.
11. Note the values of the result of various operations in the observation table.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical
trainer kits and subsequently reducing e-waste
SAMPLE PROGRAM 1: Write a program to detect and control the water level in tank and
display the status on LCD.
STEP1- Algorithm
1. Configure the Port 0 and Port 2 as an output port.
2. Configure Port 3 pin 5 as output port pin to make the motor ON and OFF.
3. Configure Port 3 pin 3.0 to pin 3.3 as input pins to sense the status of Water level in tank.
4. Determine the water level by reading status of sensors connected.
5. If water tank is full then turn off the motor and display full on LCD.
6. Else keep the motor ON and display the status on LCD.
7. Repeat the process by going back to step 4.
Step 2-Flow Chart
Memory Hex
Label Mnemonics Comments
Address Code
RS BIT P1.0
RW BIT P1.1
E BIT P1.2
Maharashtra State Board of Technical Education ‘K-Scheme’
291
Microcontroller & Applications (314340)
Memory Hex
Label Mnemonics Comments
Address Code
ORG 0000H
Check the status of water
C:0X0000 30B00E CHECK: JNB P3.0, LCDDISPLAY
level
Check the status of water
C:0X0003 30B10B JNB P3.1, LCDDISPLAY
level
C:0X0006 C285 CLR P3.5
Check the status of water
C:0X0008 30B206 JNB P3.2, LCD DISPLAY
level
C:0X000B D2B5 SETB P3.5
C:0X000D 1111 ACALL LCD DISPLAY
C:0X000F 80EF SJMP CHECK
C:0X0011 C290 LCDDISPLAY: CLR RS
C:0X0013 C291 CLR RW
C:0X0015 C292 CLR E
C:0X0017 7438 MOV A, #38H Initialize LCD
C:0X0019 1162 ACALL LCDCMD
C:0X001B 117C ACALL DELAY
C:0X001D 740E MOV A, #0EH
C:0X001F 1162 ACALL LCDCMD
C:0X0021 117C ACALL DELAY
C:0X0023 7406 MOV A, #06H
C:0X0025 1162 ACALL LCDCMD
C:0X0027 117C ACALL DELAY
C:0X0029 7401 MOV A, #01H
C:0X002B 1162 ACALL LCDCMD
C:0X002D 117C ACALL DELAY
C:0X002F 7480 MOV A, #80H
C:0X0031 1162 ACALL LCDCMD
C:0X0033 117C ACALL DELAY
C:0X0035 30B008 JNB P3.0, F_DISPLAY
C:0X0038 30B10F JNB P3.1, H_DISPLAY
C:0X003B 30B214 JNB P3.2, Q_DISPLAY
C:0X003E 115A ACALL E_DISPLAY
C:0X0040 7446 F_DISPLAY: MOV A, # “F” Display Tank Full
C:0X0042 1164 Call Subroutine for LCD
ACALL LCDDATA
display
C:0X0044 117C ACALL DELAY Call Delay
C:0X0046 C2B5 CLR P3.5
C:0X0048 80B6 SJMP CHECK
C:0X004A 7448 H_DISPLAY: MOV A, # “H” Display Tank Half Full
Memory Hex
Label Mnemonics Comments
Address Code
C:0X004C 116F Call Subroutine for LCD
ACALL LCDDATA
display
C:0X004E 117C ACALL DELAY Call Delay
C:0X0050 80AE SJMP CHECK
C:0X0052 7451 Q_DISPLAY: MOV A, # “Q” Display Tank Quarter Full
C:0X0054 116F Call Subroutine for LCD
ACALL LCDDATA
display
C:0X0056 117C ACALL DELAY Call Delay
C:0X0058 80A6 SJMP CHECK
C:0X005A 7445 E_DISPLAY: MOV A, # “E” Display Tank Empty
C:0X005C 116F Call Subroutine for LCD
ACALL LCDDATA
display
C:0X005E 117C ACALL DELAY Call Delay
C:0X0060 809E SJMP CHECK
C:0X0062 C290 Subroutine for LCD
LCDCMD: CLR RS
Commands
C:0X0064 C291 CLR RW
C:0X0066 F5A0 MOV P2, A
C:0X0068 D292 SETB E
C:0X006A 117C ACALL DELAY
C:0X006C C292 CLR E
C:0X006E 22 RET
C:0X006F D290 Subroutine for LCD data
LCDDATA: SETB RS
display
C:0X0071 C291 CLR RW
C:0X0073 F5A0 MOV P2, A
C:0X0075 D292 SETB E
C:0X0077 117C ACALL DELAY
C:0X0079 C292 CLR E
C:0X007B 22 RET
C:0X007C A8FF DELAY: MOV RO, #FFH Delay Subroutine
C:0X007E 79FF BACK1: MOV R1, #FFH
C:0X0080 D9FE HERE: DJNZ R1, HERE
C:0X0082 D8FA DJNZ R0, BACK1
C:0X0084 22 RET
END
XI Resources Used:
XII Actual Procedure Followed (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
……………………….…………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XIII Observations for sample program
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
I Practical Significance
The measurement of temperature by using appropriate sensors and controllers is not only
important in environmental or weather monitoring but also crucial for many industrial
processes. Usually, a temperature sensor converts the temperature into an equivalent
voltage output. IC LM35 is such a sensor. This practical will help the students to develop
skills to interface temperature sensor to the microcontroller, read temperature and display
its value on LCD.
The LM35 series are precision integrated-circuit analog temperature sensor with an output voltage
linearly proportional to the Centigrade temperature around it. It is a small and cheap IC which can
be used to measure temperature anywhere between -55°C to 150°C. The LM35 comes already
calibrated hence requires no external calibration.
LM35 Features:
1. Calibrated Directly in Celsius (Centigrade)
2. Operates From 4 V to 30 V. Typically 5V.
3. Can measure temperature ranging from -55°C to 150°C
4. Output voltage is directly proportional (Linear) to temperature
5. ±0.5°C Accuracy
ADC0808:
b) Simulation diagram
Instrument
Sr. No. Specification Quantity
/Components
IX Precautions to be followed
1) Care should be taken while operating LM 35 as it is rated to operate over −55°C to 150°C
temperature range
2) Refer datasheet for to provide clock frequency to ADC 0808 chip.
3) Care must be taken while taking observations during power up.
4) Check rules / syntax of assembly language programming.
X Procedure
1. Write algorithm for given problem.
2. Draw flowchart for the same.
3. Develop assembly program using Integrated Development Environment (IDE) or
any other relevant software tool.
4. Debug program on IDE.
5. Execute program on IDE.
6. Create hex file for the above program.
7. Download hex code in EPROM/Flash memory of the microcontroller.
8. Interface LM 35 to ADC 0808 IC and connect ADC output and LCD display to the
microcontroller as per circuit diagram shown in fig 28.4
9. Vary temperature of LM 35 and observe ADC output on LCD display.
E-Waste Management
1. Identify pin configuration of the ICs and test the ICs on the IC tester.
2. If the IC is faulty then keep it in the proper e-waste bin.
3. If the IC is in OK condition, then mount it on breadboard or the trainer kit.
4. Utilize software-based simulations for training, decreasing the reliance on physical trainer
kits and subsequently reducing e-waste
SAMPLE PROGRAM: Write a program to read the temperature, convert it to decimal and
display on LCD
.Step 1-Algorithm
1. Define control signals RS, RW and EN for LCD and initialize LCD by sending
commands.
2. Select an analog channel by providing bits to A, B, and C addresses according to the
analog signal selection table.
3. Activate the ALE (address latch enable) pin.
4. Activate SC (start conversion) to initiate conversion.
5. Monitor EOC (end of conversion) to see whether conversion is finished. H-to-L output
indicates that the data is converted and is ready to be picked up. If we do not use EOC,
we can read the converted digital data after a brief time delay. The delay size depends on
the speed of the external clock we connect to the CLK pin.
6. Activate OE (output enable) to read data out of the ADC chip.
Note: In ADC0808 that there is no self-clocking and the clock must be provided from an
external source to the CLK pin. Although the speed of conversion depends on the frequency
of the clock connected to the CLK pin, it cannot be faster than 100 microseconds.
Memory Hex
Label Mnemonics Comments
Address Code
RS EQU P3.3
RW EQU P3.4
EN EQU P3.5
ALE BIT P2.0
SC BIT P2.1
EOC BIT P2.2
OE BIT P2.3
Memory Hex
Label Mnemonics Comments
Address Code
ADDR_A BIT P2.4
ADDR_B BIT P2.5
ADDR_C BIT P2.6
ORG 0000H
C:0x0000 758000 MOV P0,#00H ;make P0 as output
C:0x0003 1163 BACK: ACALL LCD
C:0x0005 7590FF MOV P1,#0FFH ;make P1 as input
C:0x0008 D2A6 SETB EOC ;make EOC an input
C:0x000A C2A4 CLR ALE ;clear ALE
C:0x000C C2A3 CLR SC ;clear WR
C:0x000E C2A5 CLR OE ;clear RD
C:0x0010 C2A2 CLR ADDR_C ;C=0
C:0x0012 C2A1 CLR ADDR_B ;B=0
C:0x0014 C2A0 CLR ADDR_A ;A=0 (select channel 0)
C:0x0016 D2A4 SETB ALE ;latch address
C:0x0018 1131 ACALL DELAY
C:0x001A D2A3 SETB SC ;start conversion
C:0x001C 1131 ACALL DELAY
C:0x001E C2A4 CLR ALE
C:0x0020 C2A3 CLR SC
C:0x0022 20A6FD HERE: JB EOC,HERE ;wait
C:0x0025 30A6FD HERE1: JNB EOC,HERE1
C:0x0028 D2A5 SETB OE
C:0x002A 1131 ACALL DELAY
C:0x002C E590 MOV A,P1 ;Read ADC data
Memory Hex
Label Mnemonics Comments
Address Code
C:0x002E C2A5 CLR OE
C:0x0030 1143 ACALL CONV ;call hex to ASCII
C:0x0032 1158 ACALL WRITETMP ; display temperature
C:0x0034 80CD SJMP BACK
C:0x0036 7B19 DELAY: MOV R3,#25 ;Delay Subroutine
C:0x0038 7C64 L3: MOV R4,#100
C:0x003A 7D64 L2: MOV R5,#100
C:0x003C DDFE L1: DJNZ R5,L1
C:0x003E DCFA DJNZ R4,L2
C:0x0040 DBF6 DJNZ R3,L3
C:0x0042 22 RET
MOV B,#10
C:0x0043 75F00A CONV: ; HEX to ASCII conversion
C:0x0046 DIV AB
84
C:0x0047 MOV R7,B
AFF0
C:0x0049 MOV B,#10
75F00A
C:0x004C DIV AB
84
C:0x004D MOV R6,B
AEF0
C:0x004F MOV A,R6
EE
C:0x0050 ADD A,#30H
2430
C:0x0052 MOV R6,A
FE
C:0x0053 MOV A,R7
EF
C:0x0054 ADD A,#30H
2430
C:0x0056 MOV R7,A
FF
Memory Hex
Label Mnemonics Comments
Address Code
C:0x0057 22 RET
MOV A,R6
C:0x0058 EE
ACALL LCDWRITE
C:0x0059 119E
MOV A,R7
C:0x005B EF
ACALL LCDWRITE
C:0x005C 119E
MOV A,#'C'
C:0x005E 7443
ACALL LCDWRITE
C:0x0060 119E
RET
C:0x0062 22
LCD: ACALL LCD_INIT
C:0x0063 117C
MOV DPTR, #MSG
C:0x0065 9000AB
C:0x0068 MOV R2, #12
7A0C
C:0x006A UP:CLR A
E4
C:0x006B MOVC A,@A+DPTR
93
C:0x006C ACALL LCDWRITE
119E
C:0x006E INC DPTR
A3
C:0x006F DJNZ R2, UP
DAF9
C:0x0071 22 RET
LCD_INIT: MOV A, #38H
C:0x0072 7438 ;LCD initialization
C:0x0074 ACALL CMD
1191
C:0x0076 MOV A, #0EH
740E
C:0x0078 ACALL CMD
1191
Memory Hex
Label Mnemonics Comments
Address Code
C:0x007A MOV A, #01H
7401
C:0x007C ACALL CMD
1191
C:0x007E MOV A, #06H
7406
C:0x0080 ACALL CMD
1191
C:0x0082 MOV A, #80H
7480
C:0x0084 ACALL CMD
1191
C:0x0086 22 RET
C:0x0089 CLR RS
C2B3
C:0x008B CLR RW
C2B4
C:0x008D SETB EN
D2B5
C:0x008F CLR EN
C2B5
C:0x0091 ACALL DELAY
1136
C:0x0093 22 RET
LCDWRITE: MOV P0, A
C:0x0094 F580 ;LCD data subroutine
SETB RS
C:0x0096 D2B3
C:0x0098 CLR RW
C2B4
C:0x009A SETB EN
D2B5
C:0x009C CLR EN
C2B5
C:0x009E ACALL DELAY
1136
Memory Hex
Label Mnemonics Comments
Address Code
C:0x00A0 RET
22
DB
MSG: "TEMPERATURE:"
END
XI Resources Used
XII Actual Procedure Followed (use blank sheet provided if space not sufficient)
1. ………………………………………………………………………………………………
2. ………………………………………………………………………………………………
3. ………………………………………………………………………………………………
4. ………………………………………………………………………………………………
5. ………………………………………………………………………………………………
6. ………………………………………………………………………………………………
7. ………………………………………………………………………………………………
XIII Observations for sample Program (use blank sheet provided if space not sufficient)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XV Interpretation of Results (Give meaning of the above obtained results)
………………………………………………………………………………………………….
…………………………………………………………………………………………………
……………………………………………………………………….…………………………
…………………………………………………………………………………….……………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
1. https://www.ti.com/product/LM35
2. https://bravelearn.com/interface-lm35-temperature-sensor-with-8051-at89c51/
3. https://www.electronicshub.org/digital-temperature-sensor-circuit/
4. https://www.youtube.com/watch?v=S5IBc_epa1A
5. https://circuitdigest.com/microcontroller-projects/interfacing-adc0808-with-8051-
microcontroller