0% found this document useful (0 votes)
16 views79 pages

Workbook 8051 Microcontroller - N

The document outlines the lab course CA-154-P for the First Year Bachelor of Computer Applications under the CBCS syllabus, focusing on 8051 Microcontroller Programming. It includes a list of assignments related to the 8051 microcontroller, such as interfacing with various components and programming tasks. The course is set to be implemented in the academic year 2024-2025 and is affiliated with Savitribai Phule Pune University.

Uploaded by

ginevep979
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views79 pages

Workbook 8051 Microcontroller - N

The document outlines the lab course CA-154-P for the First Year Bachelor of Computer Applications under the CBCS syllabus, focusing on 8051 Microcontroller Programming. It includes a list of assignments related to the 8051 microcontroller, such as interfacing with various components and programming tasks. The course is set to be implemented in the academic year 2024-2025 and is affiliated with Savitribai Phule Pune University.

Uploaded by

ginevep979
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 79

FYBCA(Science)

Lab course on CA-101 – T

(Faculty of Science & Technology)


(For Colleges Affiliated to Savitribai Phule Pune
University)

Choice Based Credit System (CBCS) Syllabus Under National Education Policy
(NEP)
To be implemented from Academic Year 2024-2025
Title of the Course: B.C.A./B.Sc.(CA)

First Year of Bachelor of Computer Applications


Semester-II
CA- 154 - P Lab course on CA- 153 - T

Work Book
Name:

College Name:

Roll No.: Division:

Academic Year :

Editor:
Prof. Dr. Deepak S. Kumbhar
PES Modern College of Arts, Science & Commerce, Ganeshkhind, Pune 411016

1
F.Y.B.C.A
Semester-II
CA- 154 - P Lab course on CA- 153 - T
CERTIFICATE
This is to certify that
Mr./Ms. _________________________________________ has successfully
completed the lab book on 8051 Microcontroller Programming CA- 154 - P
Lab course on CA- 153 - T course work and has scored _______marks out
of 15.

Instructor H.O.D./Coordinator

Internal examiner External examiner

2
List of Assignments

1. Study of 8051 microcontroller chip, keil µvision-5.


2. Study of proteus simulator for 8051 simulation.
3. Program to find Largest/smallest from a series.
4. Program to perform Addition / subtraction / multiplication/division of 8/16
bit data.
5. Program to perform Arithmetic, logical & code conversion problems
6. Program to perform data transfer/exchange between specified memories
locations.
7. Interfacing of LED/LEDs to 8051 microcontroller.
8. Interfacing of switch & LED to 8051 microcontroller.
9. Waveform generation using DAC Interface to 8051 Microcontroller.
10. Traffic light controller using 8051 microcontroller.
11. Interfacing LCD to 8051Microcontroller.
12. Interfacing with IR sensor to 8051 microcontroller and LCD.
13. ADC interfacing to 8051 Microcontroller.
14. Stepper motor interfacing to 8051 microcontroller.
15. DC motor interfacing to 8051 microcontroller.

3
Assignment Completion Sheet

Sr. No. Assignment Name Sign Grade

1 Study of 8051 microcontroller chip, keil µvision-5.


(Demonstration)
2 Study of proteus simulator for 8051 simulation
(Demonstration)

3 Program to perform data transfer/exchange between


specified memories locations
4 Program to perform Arithmetic, logical & code
conversion problems
5 Program to perform Addition / subtraction /
multiplication/division of 8/16 bit data.
6 Program to find Largest/smallest from a series

7 Interfacing of LED/LED s to 8051 microcontroller.


8 Interfacing of switch & LED to 8051 microcontroller.
9 Traffic light controller using 8051 microcontroller.
10 Interfacing LCD to 8051Microcontroller.
11 Interfacing with IR sensor to 8051 microcontroller and
LCD.
12 ADC interfacing to 8051 Microcontroller.
13 Waveform generation using DAC Interface to 8051
Microcontroller.
14 DC motor interfacing to 8051 microcontroller.
15 Stepper motor interfacing to 8051 microcontroller.

4
Assignment No. 1
Study of 8051 Microcontroller Chip and Keil μVision-5

Aim:
To study the architecture, features, and applications of the 8051 microcontroller and familiarize with the
Keil μVision-5 IDE for developing and simulating embedded system programs.

Objectives :
1. Understand the architecture, features, and pin configuration of the 8051 microcontroller.
2. Learn to use Keil μVision-5 IDE for writing, compiling, and debugging programs.
3. Write and simulate simple programs in embedded C or assembly for 8051.
4. Familiarize with the process of generating a .HEX file for hardware interfacing.
5. Build a foundation for interfacing peripherals and embedded system applications.

Part 1: 8051 Microcontroller

Introduction
The 8051 microcontroller, introduced by Intel, is an 8-bit microcontroller widely used in embedded
systems. It is based on Harvard architecture and supports a range of peripherals, making it ideal for small-
scale to medium-scale applications.
Features
1. 8-bit Data Bus: Processes 8 bits of data at a time.
2. 16-bit Address Bus: Accesses up to 64 KB of memory.
3. On-chip Memory:
o 4 KB of ROM for program storage.
o 128 bytes of RAM for data storage.
4. I/O Ports:
o Four 8-bit parallel ports (P0, P1, P2, P3).
5. Timers:
o Two 16-bit timers (Timer 0 and Timer 1) for time-related operations.
6. Serial Communication:
o Full-duplex UART for communication.
7. Interrupt System:
o 5 interrupt sources for handling real-time events.
8. Oscillator Frequency:
o Typically operates at 12 MHz.

5
Pin Diagram
The pin configuration of the 8051 microcontroller:

Pin out Description


Pins 1-8: Port 1 of these pins can be configured as an input or an output.
each
Pin 9: RS A logic one on this pin disables the microcontroller and clears the contents
of most registers. In other words, the positive voltage on this pin resets the
microcontroller. By applying logic zero to this pin, the program starts execution
from the beginning.
Pins10-17: Port 3 Similar to port 1, each of these pins can serve as general input or output.
Besides, all of them have alternative functions:
Pin 10: RXD Serial asynchronous communication input or Serial
synchronous communication output.
Pin 11: TXD Serial asynchronous communication output or Serial
synchronous communication clock output.
Pin 12: INT0 Interrupt 0 inputs.
Pin 13: INT1 Interrupt 1 input.
Pin 14: T0 Counter 0 clock input.
Pin 15: T1 Counter 1 clock input.
Pin 16: WR Write to external (additional) RAM.
Pin 17: RD Read from external RAM.
Pin 18, 19: X2, X1 Internal oscillator input and output. A quartz crystal which
specifies operating frequency is usually connected to these pins. Instead of it,
miniature ceramics resonators can also be used for frequency stability. Later
versions of microcontrollers operate at a frequency of 0 Hz up to over 50 Hz.
Pin 20: GND Ground.

6
Pin 21-28: Port 2 If there is no intention to use external memory then these port pins
are configured as general inputs/outputs. In case external memory is used, the
higher address byte, i.e. addresses A8-A15 will appear on this port. Even though
memory with capacity of 64Kb is not used, which means that not all eight port bits
are used for its addressing, the rest of them are not available as inputs/outputs.
Pin 29: PSEN If external ROM is used for storing program then a logic zero (0)
appears on it every time the microcontroller reads a byte from memory.
Pin 30: ALE Prior to reading from external memory, the microcontroller puts the
lower address byte (A0-A7) on P0 and activates the ALE output. After receiving
signal from the ALE pin, the external register (usually 74HCT373 or 74HCT375
add-on chip) memorizes the state of P0 and uses it as a memory chip address.
Immediately after that, the ALU pin is returned its previous logic state and P0 is now
used as a Data Bus. As seen, port data multiplexing is performed by means of only
one additional (and cheap) integrated circuit. In other words, this port is used for both
data and address transmission.
Pin 31: EA By applying logic zero to this pin, P2 and P3 are used for data and
address transmission with no regard to whether there is internal memory or not. It
means that even there is a program written to the microcontroller, it will not be
executed. Instead, the program written to external ROM will be executed. By
applying logic one to the EA pin, the microcontroller will use both memories, first
internal then external (if exists).
Pin 32-39: Port 0 Similar to P2, if external memory is not used, these pins can be
used as general inputs/outputs. Otherwise, P0 is configured as address output (A0-
A7) when the ALE pin is driven high (1) or as data output (Data Bus) when the ALE
pin is driven low (0).
Pin 40: VCC +5V power supply.

7
Block Diagram:

The internal structure of the 8051 microcontroller includes:


1. CPU: Processes instructions.
2. RAM/ROM: Stores data and program code.
3. Timers/Counters: For generating delays and counting events.
4. I/O Ports: Interfaces with external devices.
5. Interrupts: Handles external/internal events.

Types of instructions:
Depending on operation they perform, all instructions are divided in several groups:
 Arithmetic Instructions
 Branch Instructions
 Data Transfer Instructions
 Logic Instructions
 Bit-oriented Instructions

Arithmetic instructions:
Arithmetic instructions perform several basic operations such as addition, subtraction, division,
multiplication etc. After execution, the result is stored in the first operand. For example:
ADD A, R1 - The result of addition (A+R1) will be stored in the accumulator

. Mnemonic Description
ADD A,Rn Adds the register to the accumulator
ADD A,direct Adds the direct byte to the accumulator
ADD A,@Ri Adds the indirect RAM to the
accumulator
ADD A,#data Adds the immediate data to the
accumulator
ADDC A,Rn Adds the register to the accumulator with
a carry flag
ADDC A,direct Adds the direct byte to the accumulator
with a carry flag
ADDC A,@Ri Adds the indirect RAM to the
accumulator with a carry flag
8
ADDC A,#data Adds the immediate data to the
accumulator with a carry flag
SUBB A,Rn Subtracts the register from the
accumulator with a borrow
SUBB A,direct Subtracts the direct byte from the
accumulator with a borrow
SUBB A,@Ri Subtracts the indirect RAM from the
accumulator with a borrow
SUBB A,#data Subtracts the immediate data from the
accumulator with a borrow
INC A Increments the accumulator by 1
INC Rn Increments the register by 1
INC Rx Increments the direct byte by 1
INC @Ri Increments the indirect RAM by 1
DEC A Decrements the accumulator by 1
DEC Rn Decrements the register by 1
DEC Rx Decrements the direct byte by 1
DEC @Ri Decrements the indirect RAM by 1
INC DPTR Increments the Data Pointer by 1
MUL AB Multiplies A and B
DIV AB Divides A by B
DA A Decimal adjustment of the accumulator
according to BCD code
Branch Instructions:
There are two kinds of branch instructions:
Unconditional jump instructions: upon their execution a jump to a new location from
where the program continues execution is executed.
Conditional jump instructions: a jump to a new program location is executed only if a
specified condition is met. Otherwise, the program normally proceeds with the next
instruction.
Mnemonic Description
ACALL addr11 Absolute subroutine call
LCALL addr16 Long subroutine call
RET Returns from subroutine
RETI Returns from interrupt subroutine
AJMP addr11 Absolute jump
LJMP addr16 Long jump
SJMP rel Short jump (from –128 to +127 locations relative to the
following instruction)
JC rel Jump if carry flag is set. Short jump.
JNC rel Jump if carry flag is not set. Short jump.
JB bit,rel Jump if direct bit is set. Short jump.
JBC bit,rel Jump if direct bit is set and clears bit. Short jump.
JMP @A+DPTR Jump indirect relative to the DPTR
JZ rel Jump if the accumulator is zero. Short jump.
JNZ rel Jump if the accumulator is not zero. Short jump.
CJNE A,direct,rel Compares direct byte to the accumulator and jumps if not
equal. Short jump.
CJNE A,#data,rel Compares immediate data to the accumulator and jumps
if not equal. Short jump.
CJNE Rn,#data,rel Compares immediate data to the register and jumps if not
9
equal. Short jump.
CJNE @Ri,#data,rel Compares immediate data to indirect register and jumps
if not equal. Short jump.
DJNZ Rn,rel Decrements register and jumps if not 0. Short jump.
DJNZ Rx,rel Decrements direct byte and jump if not 0. Short jump.
NOP No operation

Data Transfer Instructions:

Data transfer instructions move the content of one register to another. The register the content of
which is moved remains unchanged. If they have the suffix “X” (MOVX), the data is exchanged
with external memory.

Mnemonic Description

MOV A,Rn Moves the register to the accumulator

MOV A,direct Moves the direct byte to the accumulator

MOV A,@Ri Moves the indirect RAM to the accumulator

MOV A,#data Moves the immediate data to the accumulator

MOV Rn,A Moves the accumulator to the register

MOV Rn,direct Moves the direct byte to the register

MOV Rn,#data Moves the immediate data to the register

MOV direct,A Moves the accumulator to the direct byte

MOV direct,Rn Moves the register to the direct byte

MOV direct,direct Moves the direct byte to the direct byte

MOV direct,@Ri Moves the indirect RAM to the direct byte

MOV direct,#data Moves the immediate data to the direct byte

MOV @Ri,A Moves the accumulator to the indirect RAM

MOV @Ri,direct Moves the direct byte to the indirect RAM

MOV @Ri,#data Moves the immediate data to the indirect RAM

MOV DPTR,#data Moves a 16-bit data to the data pointer

MOVC Moves the code byte relative to the DPTR to the


A,@A+DPTR accumulator (address=A+DPTR)

10
MOVC A,@A+PC Moves the code byte relative to the PC to the accumulator
(address=A+PC)

MOVX A,@Ri Moves the external RAM (8-bit address) to the accumulator

MOVX A,@DPTR Moves the external RAM (16-bit address) to the


accumulator
MOVX @Ri,A Moves the accumulator to the external RAM (8-bit address)

MOVX @DPTR,A Moves the accumulator to the external RAM (16-bit address)

PUSH direct Pushes the direct byte onto the stack

POP direct Pops the direct byte from the stack/td>

XCH A,Rn Exchanges the register with the accumulator

XCH A,direct Exchanges the direct byte with the accumulator

XCH A,@Ri Exchanges the indirect RAM with the accumulator

XCHD A,@Ri Exchanges the low-order nibble indirect RAM with the
accumulator

Logic Instructions:

Logic instructions perform logic operations upon corresponding bits of two registers. After execution,
the result is stored in the first operand.

Mnemonic Description

ANL A,Rn AND register to accumulator

ANL A,direct AND direct byte to accumulator

ANL A,@Ri AND indirect RAM to accumulator

ANL A,#data AND immediate data to accumulator

ANL direct,A AND accumulator to direct byte

ANL direct,#data AND immediate data to direct register

ORL A,Rn OR register to accumulator

ORL A,direct OR direct byte to accumulator

ORL A,@Ri OR indirect RAM to accumulator

ORL direct,A OR accumulator to direct byte

11
ORL direct,#data OR immediate data to direct byte

XRL A,Rn Exclusive OR register to accumulator

XRL A,direct Exclusive OR direct byte to accumulator

XRL A,@Ri Exclusive OR indirect RAM to accumulator

XRL A,#data Exclusive OR immediate data to


accumulator
XRL direct,A Exclusive OR accumulator to direct byte
XORL direct,#data Exclusive OR immediate data to direct byte

CLR A Clears the accumulator

CPL A Complements the accumulator (1=0, 0=1)

SWAP A Swaps nibbles within the accumulator

RL A Rotates bits in the accumulator left

RLC A Rotates bits in the accumulator left


through carry
RR A Rotates bits in the accumulator right

RRC A Rotates bits in the accumulator right


through carry

Bit-oriented Instructions

Similar to logic instructions, bit-oriented instructions perform logic operations. The difference is that
these are performed upon single bits.

Mnemonic Description

CLR C Clears the carry flag

CLR bit Clears the direct bit

SETB C Sets the carry flag

SETB bit Sets the direct bit

CPL C Complements the carry flag

CPL bit Complements the direct bit

ANL C,bit AND direct bit to the carry flag

ANL C,/bit AND complements of direct bit to the carry


flag
12
ORL C,bit OR direct bit to the carry flag

ORL C,/bit OR complements of direct bit to the carry flag

MOV C,bit Moves the direct bit to the carry flag

MOV bit,C Moves the carry flag to the direct bit

Description of all 8051 instructions:

Here is a list of the operands and their meanings:

 A - accumulator; Rn - is one of working registers (R0-R7) in the currently active RAM


memory bank;

 Direct - is any 8-bit address register of RAM. It can be any general-purpose register or a
SFR (I/O port, control register etc.);
 @Ri - is indirect internal or external RAM location addressed by register R0 or R1;
 #data - is an 8-bit constant included in instruction (0-255);
 #data16 - is a 16-bit constant included as bytes 2 and 3 in instruction (0-65535);
 addr16 - is a 16-bit address. May be anywhere within 64KB of program memory;
 addr11 - is an 11-bit address. May be within the same 2KB page of program memory as the
first byte of the following instruction;
 Rel - is the address of a close memory location (from -128 to +127 relative to the first byte of
the following instruction). On the basis of it, assembler computes the value to add or subtract
from the number currently stored in the program counter;
 bit - is any bit-addressable I/O pin, control or status bit; and
 C - is carry flag of the status register (register PSW).
8051 Addressing modes:

The way of specifying the address of the operand is called as addressing mode. The 8051
microcontroller is having four addressing modes for accessing data.

1. Immediate Addressing mode


2. Register Addressing mode
3. Direct Addressing mode
4. Indirect Addressing mode
5. Indexed Addressing mode

1. Immediate addressing mode:


The operand comes immediately after the op-code. The immediate data must be preceded by the hash
sign, "#".
MOV A, #25H ;load 25H into A
MOV R4, #62 ;load the decimal value 62 into R4
MOV B, #40H ;load 40H into B
MOV DPTR, #4512H ; DPTR=4512H

13
2. Register Addressing mode:
Register addressing mode involves the use of registers to hold the data to be manipulated. In this
addressing mode register which is having the data is part of the instruction.
MOV A, R0 ;copy the contents of RO into A
MOV R2,A ; copy the contents of A into R2
ADD A, R5 ; add the contents of R5 to contents of A
ADD A, R7 ; add the contents of R7 to contents of A
MOV R6, A ; save accumulator in R6

3. Direct Addressing mode:


In the direct addressing mode, the data is in a RAM memory location whose address is known, and
this address is given as a part of the instruction.

MOV R0,40H ; save content of RAM location 40H in RO


MOV 56H, A ; save content of A in RAM location 56H
MOV R4,7FH ; move contents of RAM location 7FH to R4

4. Indirect Addressing mode:


A register is used as a pointer to the data. If the data is inside the CPU, only registers R0 and R 1 are
used for this purpose. R2 - R7 cannot be used to hold the address of an operand located in RAM
when using indirect addressing mode. When RO and R1 are used as pointers they must be
preceded by the @ sign.

MOV A, @R0 ; move contents of RAM location whose ;address is held by RO into A
MOV @R1, B ; move contents of B into RAM location ; whose address is held by R1

5. Indexed Addressing mode


Indexed addressing mode is widely used in accessing data elements of look-up table entries
located in the program ROM space of the 8051.
The instruction used for this purpose is :
MOVC A, @ A+DPTR
The 16-bit register DPTR and register A are used to form the address of the data element
stored in on-chip ROM.
Because the data elements are stored in the program (code) space ROM of the 8051, the
instruction MOVC is used instead of MOV. The "C" means code.
In this instruction the contents of A are added to the 16-bit register DPTR to form the 16bit
address of the needed data.

Applications
 Home appliances (e.g., washing machines).
 Robotics and automation.
 Automotive systems.
 Industrial control systems.

14
Part 2: Keil μVision-5
Introduction
Keil μVision-5 is a professional IDE for embedded systems development. It supports programming and
simulation for a variety of microcontrollers, including the 8051 family.

Features
1. Code Editor: Provides syntax highlighting and error detection.
2. Compiler: Converts high-level language (C) to machine code (HEX files).
3. Simulator: Allows debugging and testing without hardware.
4. Peripheral Support: Simulates ports, timers, serial interfaces, etc.
5. Integration: Works with real hardware using programmers/debuggers.

Step 1: Give a double click on μvision4 icon on the desktop; it will generate a window as shown below:

Step 2: To create new project, go to project, select new μvision project.

15
Step 3: Select a drive where you would like to create your project.
Step 4: Create a new folder and name it with your project name.
Step 5: Open that project folder and give a name of your project executable file and save it.
Step 6: After saving, it will show some window there select your microcontroller company i.e. Atmel.

Step 7: Select your chip as AT89S52.

Step 8: After selecting chip click on OK then it will display some window asking to add STARTUP file.
Select YES.
Step 9: A target is created and start up file is added to your project window and is shown below.

16
Step 10: To write your project code select a new file from FILE menu bar.
Step 11: It will display some text editor, to save that file select SAVE option from FILE menu bar.
Step 12: Save file name with .c/ .asm extension depending on the language using to write the programs.
Step 13: Write the code of your project and save it.
Step 14: To add c/asm file to target, give a right click on Source Group, choose “ADD files to Group” option.

17
Step 15: It will displays some window there select the file you have to add and click on ADD option.

Step 16: The file will be added to target and it is shown in the project window.
Step 17: Now give a right click on target in the project window and select “Options for Target”.

18
Step 18: It will show some window like below, in that go to target option and type crystal oscillator frequency
Xtal (MHz) as 11.0592

Step 19: It will come back to the previous window and click OK in that window.
Step 20: Now go to project and click on Translate as shown in below figure it shows the errors and warnings in
Build output.

Step 21: Clear all the syntax errors and make sure 0 errors and 0 warnings.
Step 22: Now go to project and click on Build as shown in below figure it shows the errors and warnings in Build
output and shows target file is created.

19
Step 23: Go to debug tab and click on start/stop debug it opens the below window and click OK.

20
Step 24: It opens the following window and click run in the debug tab and the observe the output in
interfacing board

Key Steps to Use Keil μVision-5 for 8051


Step 1: Create a New Project
1. Open Keil μVision-5.
2. Go to Project > New μVision Project.
3. Select the target microcontroller (e.g., Atmel 89S52).
Step 2: Add Source Files
1. Create a .c file by right-clicking on the project folder.
2. Write the desired code in the editor.
Step 3: Configure Compiler
1. Set up the compiler to generate HEX files.
2. Enable options for simulation and debugging.
Step 4: Compile the Program
1. Click the "Build" button to compile the program.
2. Check for errors in the output window.
Step 5: Simulate the Program
1. Click Debug to enter simulation mode.
2. Test the functionality of the program using virtual peripherals.
Step 6: Load to Hardware
Use a ProgISP programmer device to upload the HEX file to the 8051 microcontroller.

Assignment Evaluation
0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]
3: Needs Improvement [ ] 4: Complete [ ] 5: Well Done [ ]
Lab Incharge Signature

21
Assignment No. 2
Study of Proteus Simulator for 8051 Simulation
Aim
To study and understand the use of the Proteus Simulator for designing, simulating, and testing
8051 microcontroller-based circuits in a virtual environment.

Objectives
1. Learn the interface and features of the Proteus simulator.
2. Understand how to add and configure components like 8051 microcontroller, LEDs,
switches, sensors, motors, and displays.
3. Simulate 8051 programs using .HEX files generated from Keil μVision-5.
4. Verify and debug microcontroller-based circuits virtually without physical hardware.
5. Develop skills to design and test embedded systems projects efficiently.
.
Apparatus Required
1. Proteus Design Suite software.(Use Student version or License Version only)
2. A PC with Windows OS.
3. Knowledge of 8051 programming (HEX files).

Theory
Proteus is an electronic circuit design and simulation software widely used to test and validate
embedded system designs, including microcontroller-based projects. It provides a virtual
platform to:

 Simulate microcontroller operations.


 Interface peripherals such as LEDs, switches, LCDs, motors, etc.
 Debug and analyze embedded systems.

Key Features of Proteus

1. Schematic Capture: Draw circuits using an extensive library of components.


2. Microcontroller Simulation: Supports various microcontrollers, including the 8051.
3. Peripheral Integration: Simulate sensors, displays, and other components.
4. Logic Analyzer: Analyze data flow and logic in the circuit.
5. HEX File Loading: Run programs written for microcontrollers by loading compiled
HEX files.

22
PROTEUS Environment

PROTEUS

Basically PROTEUS is also a simulating software but it helps you attach many components with
the 8051. Like resistors, capacitors, LEDs, LCDs, keypads, ICs etc. and these are just few that I
have named in general. It has a complete library and you will find everything that you will ever
need. You can design your complete circuit and then simulate it to view the final output. This
means that after perfecting your project on the programming side in KEIL, you'll need to
simulate it on PROTEUS to determine the output of the hardware components and change it if
need be. This will completely ensure your project's success.

DOWNLOAD PROTEUS
It is a paid application but you can download the free demo version of PROTEUS from their
official website here. It is fully functional except that it won't allow you to save your designs.

USING PROTEUS
PROTEUS is designed to be user-friendly and you will get the hold of it instantly. There is no
need to worry about some complex configuration / settings prior to simulation. Here are the basic
steps.

1. Place your components from the library


2. Connect them accordingly
3. Load HEX file (if 8051 is involved)
4. Simulate the circuit
Let me explain each step.

PLACING COMPONENTS
1. Click the "Pick from library (P)" button as shown in the figure
2. Select any category
3. Select item from the list
4. Click OK
23
 After selecting component, click anywhere in the design area to select it and then click
again to place it

CONNECTING COMPONENTS
1. Place all the required components
2. Connect the desired nodes by clicking at starting and ending points

24
LOAD HEX FILE
1. Double click the 8051 component to open its properties
2. Browse for the HEX file as shown and select it

And don't worry, in PROTEUS, there is no need to provide the RESET circuit or crystal
oscillator to the microcontroller. It will work just fine even without it. The frequency can be
adjusted in the properties window as well.

SIMULATING THE CIRCUIT


 The controls at the left-bottom corner will help you simulate the circuit in real time

25
The above picture is the complete circuitry for testing an LED on P2.0 like toggling (ON / OFF)
through programming but we will get to that part later on. At this point, you will just see the
LED glow if you have programmed it to be always ON.

Key Steps to Use Proteus for 8051 Simulation:


1. Open Proteus Design Suite:
o Launch the Proteus software and start a new project.
2. Create a Circuit:
o Place the 8051 microcontroller (AT89C51 or equivalent) from the component
library.
o Add peripherals (e.g., LEDs, switches, resistors).
3. Connect Components:
o Connect LEDs to Port 1 (P1.0 - P1.7).
o Add a clock oscillator (XTAL) and reset circuit for the 8051.
4. Load the Program:
o Write a program for the 8051 using Keil μVision.
o Compile the code to generate a .HEX file.
o Load the .HEX file into the 8051 by double-clicking on the microcontroller in
Proteus and browsing to the file.
5. Simulate the Circuit:
o Click the Run button to start the simulation.
o Observe the behavior of the circuit (e.g., blinking LEDs).
6. Debug the Circuit:
o Use virtual instruments like logic analyzers and oscilloscopes to debug the circuit.

Assignment Evaluation
0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]
3: Needs Improvement [ ] 4: Complete [ ] 5: Well Done [ ]
Lab Incharge Signature
26
Assignment No. 3
Program to perform data transfer/exchange between specified memories
locations.
Aim
To implement data transfer and exchange between specified memory locations using the 8051
microcontroller in Assembly language and simulate the program in Keil μVision.

Objectives
1. To learn data transfer techniques between different memory locations in the 8051.
2. To write Assembly programs for memory data exchange.
3. To simulate and debug the program using Keil μVision.

Theory
 Data Transfer: Involves copying data from a source memory location to a destination
memory location.
 Data Exchange: Swaps the data between two memory locations without losing any
information.

Programs
1. Data Transfer from Source to Destination
This program transfers data from memory location 30H to 40H.
ORG 00H ; Program starts at address 0
MOV R0, #30H ; Load source address into R0
MOV R1, #40H ; Load destination address into R1
MOV A, @R0 ; Move data from source address to accumulator
MOV @R1, A ; Move data from accumulator to destination address
SJMP $ ; Stop execution

2. Data Exchange Between Two Memory Locations


This program exchanges data between memory locations 30H and 40H.
ORG 00H ; Program starts at address 0
MOV R0, #30H ; Load address of first memory location into R0
MOV R1, #40H ; Load address of second memory location into R1
MOV A, @R0 ; Load data from first location into accumulator
MOV B, @R1 ; Load data from second location into B
MOV @R0, B ; Move data from B to first location
MOV @R1, A ; Move data from accumulator to second location
SJMP $ ; Stop execution

Steps to Simulate in Keil μVision


1. Create a New Project:
o Open Keil μVision and create a new project for the 8051 microcontroller.
2. Write the Program:
o Copy the program into a .asm file.
3. Assemble the Code:
o Assemble the code to generate a .HEX file.
4. Debug and Simulate:
27
o Load the program in the debugger.
o Use the memory and register view to verify data transfer or exchange.
(Open Memory1 type D:30H)

Observations
1. For Data Transfer:

Obs Before Execution After Execution


No.
1 30H=55 40H=00 30H=55 40H=
2 30H=66 40H= 30H=66 40H=

2. For Data Exchange:

Obs Before Execution After Execution


No.
1 30H=13 40H=87 30H= 40H=
2 30H=66 40H=33 30H= 40H=

Result

28
Conclusion

Assignment Evaluation

0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]

3: Needs Improvement [ ] 4: Complete [ ] 5: Well Done [ ]

Lab Incharge Signature

29
Assignment No. 4
Program to perform Arithmetic, logical & code conversion problems

Aim
To perform arithmetic, logical, and code conversion operations using the 8051 microcontroller in
Assembly language and simulate the program in Keil μVision.

Objectives
1. To implement basic arithmetic and logical operations.
2. To perform code conversions (binary, BCD, hexadecimal).
3. To write and simulate programs in Keil μVision.
Theory
1. Arithmetic Operations:
o Basic operations like addition, subtraction, multiplication, and division.
o Handled using the 8051 instruction set.
2. Logical Operations:
o Perform AND, OR, XOR, and NOT operations on 8-bit data.
o Useful for bit manipulation and decision-making.
3. Code Conversion:
o Conversion between different data formats (e.g., Binary to BCD, ASCII to Hex).

Assembly Programs
1. Arithmetic Operations
Addition of Two Numbers
ORG 00H ; Program starts at address 0
MOV A, #25H ; Load first number into accumulator
ADD A, #15H ; Add second number to accumulator
MOV 30H, A ; Store result at memory location 30H
SJMP $ ; Stop execution

Subtraction of Two Numbers


ORG 00H ; Program starts at address 0
MOV A, #25H ; Load first number into accumulator
SUBB A, #15H ; Subtract second number from accumulator
MOV 30H, A ; Store result at memory location 30H
SJMP $ ; Stop execution

Multiplication
ORG 00H
MOV A, #25H ; Load multiplicand into A
MOV B, #15H ; Load multiplier into B
MUL AB ; Perform multiplication (result in A and B)
MOV 30H, A ; Store lower byte at 30H
MOV 31H, B ; Store higher byte at 31H
SJMP $ ; Stop execution

30
2. Logical Operations
AND Operation
ORG 00H
MOV A, #0F0H ; Load first operand into A
ANL A, #0A0H ; Perform AND with second operand
MOV 30H, A ; Store result at memory location 30H
SJMP $ ; Stop execution

OR Operation
ORG 00H
MOV A, #0F0H ; Load first operand into A
ORL A, #0A0H ; Perform OR with second operand
MOV 30H, A ; Store result at memory location 30H
SJMP $ ; Stop execution

XOR Operation
ORG 00H
MOV A, #0F0H ; Load first operand into A
XRL A, #0A0H ; Perform XOR with second operand
MOV 30H, A ; Store result at memory location 30H
SJMP $ ; Stop execution

NOT Operation
ORG 00H
MOV A, #0F0H ; Load operand into A
CPL A ; Complement (NOT) the accumulator
MOV 30H, A ; Store result at memory location 30H
SJMP $ ; Stop execution

3. Code Conversion
Binary to BCD Conversion
ORG 00H
MOV A, #27H ; Load binary number into A (e.g., 39 decimal)
DA A ; Decimal adjust to BCD format
MOV 30H, A ; Store BCD result at memory location 30H
SJMP $ ; Stop execution

Hexadecimal to ASCII Conversion


ORG 00H
MOV A, #39H ; Load hexadecimal number into A
ADD A, #30H ; Add offset to convert to ASCII
MOV 30H, A ; Store ASCII result at memory location 30H
SJMP $ ; Stop execution

31
ASCII to Hexadecimal Conversion

ORG 00H
MOV A, #39H ; Load ASCII character '9' into A
SUBB A, #30H ; Subtract offset to convert to Hexadecimal
MOV 30H, A ; Store hexadecimal result at memory location 30H
SJMP $ ; Stop execution

Steps to Simulate in Keil μVision


1. Create a New Project:
o Open Keil μVision and create a new project for the 8051 microcontroller.
2. Write the Program:
o Copy the desired program into a .asm file.
3. Assemble and Debug:
o Assemble the code to generate the .HEX file.
o Correct errors if any.
4. Load and Simulate:
o Load the program in the debugger.
o Step through the code and observe the changes in memory and registers.

Observations

32
Result
Addition of Two Numbers

AND Operation:

33
Binary to BCD:

Conclusion

Assignment Evaluation

0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]

3: Needs Improvement [ ] 4: Complete [ ] 5: Well Done [ ]

Lab Incharge Signature

34
Assignment No. 5
Program to Perform Addition, Subtraction, Multiplication, and Division of
8/16-Bit Data

Aim
To perform arithmetic operations (addition, subtraction, multiplication, and division) on 8-bit
and 16-bit data using 8051 microcontroller and simulate the program in Keil μVision.

Objective
To write and simulate an assembly language program for the 8051 microcontroller using Keil
μVision for arithmetic operations on 8-bit and 16-bit data.

Theory
 Addition: Adds two numbers, may result in a carry.
 Subtraction: Subtracts one number from another using 2's complement.
 Multiplication: Multiplies two numbers, result is stored in the A and B registers.
 Division: Divides two numbers, quotient is stored in A and remainder in B.

Program Structure
The program is divided into segments to perform each operation, with separate routines for 8-bit
and 16-bit arithmetic.

Assembly Programs:
1. Addition of 8-Bit Numbers

ORG 00H ; Program starts at address 0


MOV A, #25H ; Load the first number into A
ADD A, #15H ; Add the second number
MOV 30H, A ; Store the result at memory location 30H
SJMP $ ; Stop execution

2. Subtraction of 8-Bit Numbers


ORG 00H ; Program starts at address 0
MOV A, #25H ; Load the first number into A
SUBB A, #15H ; Subtract the second number
MOV 30H, A ; Store the result at memory location 30H
SJMP $ ; Stop execution

3. Multiplication of 8-Bit Numbers


ORG 00H ; Program starts at address 0
MOV A, #25H ; Load the first number into A
MOV B, #15H ; Load the second number into B
MUL AB ; Multiply A and B (Result in A and B)
MOV 30H, A ; Store the lower byte of the result at 30H
MOV 31H, B ; Store the higher byte of the result at 31H
SJMP $ ; Stop execution

35
4. Division of 8-Bit Numbers

ORG 00H ; Program starts at address 0


MOV A, #50H ; Load the dividend into A
MOV B, #15H ; Load the divisor into B
DIV AB ; Divide A by B (Quotient in A, Remainder in B)
MOV 30H, A ; Store the quotient at 30H
MOV 31H, B ; Store the remainder at 31H
SJMP$ ; Stop execution

5. Addition of 16-Bit Numbers

ORG 00H ; Program starts at address 0

; Load the first 16-bit number


MOV DPTR, #3000H ; Load address of the first number
MOVX A, @DPTR ; Load lower byte of the first number
MOV R0, A ; Store in R0
INC DPTR ; Point to the higher byte
MOVX A, @DPTR ; Load higher byte of the first number
MOV R1, A ; Store in R1

; Load the second 16-bit number


MOV DPTR, #3002H ; Load address of the second number
MOVX A, @DPTR ; Load lower byte of the second number
ADD A, R0 ; Add lower bytes
MOV DPTR, #3004H ; Store lower byte of result at address 3004H
MOVX @DPTR, A ; Store result's lower byte
JC CARRY ; If carry is generated, handle it

; Add the higher bytes


MOV DPTR, #3003H ; Load address of the higher byte of the second number
MOVX A, @DPTR ; Load higher byte of the second number
ADD A, R1 ; Add higher bytes and carry (if any)
SJMP STORE_HIGH ; Jump to store higher byte

CARRY:
INC A ; Increment higher byte to handle carry

STORE_HIGH:
MOV DPTR, #3005H ; Store higher byte of result at address 3005H
MOVX @DPTR, A ; Store result's higher byte

SJMP $ ; End of program

36
6. Multiplication of 16-Bit Numbers
 For 16-bit multiplication, use repeated addition or advanced algorithms. 8051 does not
directly support 16-bit multiplication.

Steps to Simulate in Keil μVision:


1. Create a New Project:
o Open Keil μVision and create a project for the 8051 microcontroller.
2. Write the Program:
o Copy the desired program into a new .asm file.
3. Assemble and Debug:
o Assemble the program to generate a .HEX file.
o Debug and step through the program.
4. Simulate the Results:
o Load the program into the Keil debugger.
o Verify results in the memory and registers.

Observations

37
Result
1. 8-BIT ADDITION

2. 8-BIT MULTIPLICATION

38
Conclusion

Assignment Evaluation

0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]

3: Needs Improvement [ ] 4: Complete [ ] 5: Well Done [ ]

Lab Incharge Signature

39
Assignment No. 6
Program to find Largest/smallest from a series.
Aim:
To write an assembly language program for the 8051 microcontroller to find the largest and
smallest numbers from a given series of data.

Objectives:
1. Learn to handle arrays in assembly language.
2. Implement comparison logic to find the largest or smallest number.
3. Use 8051 registers (Accumulator and general-purpose registers).
4. Practice 8051 assembly syntax and instructions.
5. Test and verify the program through simulation.

Apparatus Required:
1. Keil μVision IDE.
2. 8051 microcontroller (AT89S51/52 or similar) for simulation.
3. Basic understanding of assembly programming.

Theory:
The program uses a loop to compare elements in an array stored in memory locations. Depending
on the requirement (largest or smallest), the accumulator holds the current result as comparisons
proceed.

Program Algorithm:
1. Load the first number of the series into the accumulator.
2. Point to the memory address of the next number using a pointer register (e.g., R0).
3. Compare the current number with the accumulator value:
o If the current number is larger (or smaller), update the accumulator.
o Otherwise, continue with the next number.
4. Repeat the comparison for all numbers in the series.
5. Store the result (largest or smallest number) in memory.

Assembly Program:
Finding the Largest Number

ORG 00H ; Program starts at address 0


MOV R0, #30H ; R0 points to the first number in memory
MOV R1, #05H ; R1 is the counter for the number of elements (5 in this case)
MOV A, @R0 ; Load the first number into the accumulator
INC R0 ; Point to the next number

NEXT: MOV B, @R0 ; Load the next number into register B


CJNE A, B, COMP ; Compare A with B
INC R0 ; Move to the next memory location
DJNZ R1, NEXT ; Decrement the counter and repeat for the next number
SJMP J1 ; Skip to the end

COMP: JNC SKIP ; If A > B, skip updating A


MOV A, B ; Otherwise, update A with B
40
SKIP: INC R0 ; Move to the next memory location
DJNZ R1, NEXT ; Repeat until all numbers are compared

J1: MOV 40H, A ; Store the largest number at memory location 40H
SJMP $ ; Stop the program

Finding the Smallest Number


For the smallest number, replace the COMP section with:
COMP: JC SKIP ; If A < B, skip updating A
MOV A, B ; Otherwise, update A with B
SKIP: INC R0
DJNZ R1, NEXT

Steps to Simulate in Keil μVision

1. Open Keil μVision:


o Create a new project and select the target device (e.g., AT89S52).
2. Write the Program:
o Copy the program into a new .asm file.
3. Assemble and Compile:
o Assemble the program using the Keil assembler.
o Correct any syntax errors if present.
4. Simulate the Program:
o Load the compiled .HEX file into the debugger.
o Initialize memory (e.g., 30H with test numbers).
5. Run the Simulation:
o Use step-by-step execution to observe register and memory changes.
o Verify that the largest or smallest number is stored at 40H.

Example Test Data

Address Value
30H 34
31H 78
32H 12
33H 56
34H 89

Observations

41
Result

Conclusion

Assignment Evaluation

0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]

3: Needs Improvement [ ] 4: Complete [ ] 5: Well Done [ ]

Lab Incharge Signature

42
Assignment No. 7
Interfacing of LED/LEDs to 8051 microcontroller
Aim
To interface LEDs with the 8051 microcontroller and control on-off action of an using
Embedded C programming .

Objectives
1. To write a simple program in Embedded C to turn an LED on and off using the 8051
microcontroller.
2. To control the LED through a microcontroller's I/O port.
3. To demonstrate basic digital output control with the 8051.
4. To test the functionality using simulation software (Keil μVision) and physical hardware
(circuit board).

Theory
1. LED Basics:
o LEDs emit light when current flows through them.
o They are connected in either active-high or active-low configuration.
2. Interfacing LEDs with 8051:
o LEDs are connected to the microcontroller’s I/O port through current-limiting
resistors.
o An I/O pin configured as output can control the LED's state.
3. Circuit Design:
o Connect LEDs to Port 1 of the 8051 microcontroller.
o Use 330Ω resistors in series with each LED to limit the current.

Circuit Diagram
 Port 1 pins (P1.0 to P1.7) are connected to LEDs.
 Each LED has a series resistor connected to ground (active-high configuration).

43
Program in Embedded C
1. Blinking a Single LED

#include <reg51.h> // Header file for 8051 microcontroller

sbit LED = P1^0; // Define LED at pin P1.0

void delay_ms(unsigned int ms) {


unsigned int i, j;
for (i = 0; i < ms; i++) {
for (j = 0; j < 1275; j++); // Approximate delay for 1 ms
}
}

void main() {
while (1) {
LED = 1; // Turn ON LED
delay_ms(500); // Delay of 500 ms
LED = 0; // Turn OFF LED
delay_ms(500); // Delay of 500 ms
}
}

2. Blinking Multiple LEDs

#include <reg51.h> // Header file for 8051 microcontroller

void delay_ms(unsigned int ms) {


unsigned int i, j;
for (i = 0; i < ms; i++) {
for (j = 0; j < 1275; j++); // Approximate delay for 1 ms
}
}

void main() {
unsigned char LED_pattern = 0x01; // Initial LED pattern
while (1) {
P1 = ~LED_pattern; // Send pattern to Port 1 (active-low)
delay_ms(500); // Delay of 500 ms
LED_pattern = LED_pattern << 1; // Shift the LED pattern to the left
if (LED_pattern == 0x00) { // Reset the pattern after 8 shifts
LED_pattern = 0x01;
}
}
}

44
Steps to Simulate in Keil μVision
1. Create a New Project:
o Open Keil μVision and create a new project for the 8051 microcontroller.
2. Write the Program:
o Copy the code into a .c file.
3. Configure the Project:
o Add the file to the project.
o Set the target device and include the reg51.h header.
4. Compile the Code:
o Build the project to generate the .HEX file.
5. Simulate the Program:
o Use the Keil debugger or Proteus simulator to verify the LED behavior.

Observations

Result

Conclusion

Assignment Evaluation

0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]

3: Needs Improvement [ ] 4: Complete [ ] 5: Well Done [ ]

Lab Incharge Signature

45
Assignment No. 8
Interfacing of Switch & LED to 8051 Microcontroller
Objective
To interface a switch and an LED with the 8051 microcontroller and control the LED based on
the switch's state using Embedded C.

Theory
1. Switch Basics:
o A switch can be used as an input device to the microcontroller.
o It is connected to a microcontroller pin, usually through a pull-up or pull-down
resistor, to ensure a stable logic level.
2. LED Basics:
o An LED is connected to the microcontroller as an output device.
o It can be turned ON or OFF based on the logic level sent by the microcontroller.
3. Working:
o When the switch is pressed, it changes the input logic at the microcontroller pin.
o The microcontroller reads the switch's state and turns the LED ON or OFF
accordingly.

Circuit Diagram
1. Switch: Connected to pin P2.0 with a pull-up resistor.
2. LED: Connected to pin P1.1 through a 330Ω resistor (active-high configuration).

46
Program in Embedded C

#include <reg51.h> // Header file for 8051 microcontroller

sbit SWITCH = P2^0; // Define switch at pin P2.0


sbit LED = P1^1; // Define LED at pin P1.1

void main() {
SWITCH = 1; // Configure P1.0 as input (high by default due to pull-up)
LED = 0; // Turn OFF LED initially

while (1) {
if (SWITCH == 0) { // Check if switch is pressed (active-low)
LED = 1; // Turn ON LED
} else {
LED = 0; // Turn OFF LED
}
}
}

Explanation
1. Switch:
 The switch is active-low; when pressed, it connects the input pin to ground (logic 0).
 The if condition checks for this state.
2. LED:
 The LED is controlled by writing logic 1 (ON) or 0 (OFF) to its pin.

Steps to Simulate in Keil μVision:


1. Create a New Project:
o Open Keil μVision and create a new project for the 8051 microcontroller.
2. Write the Program:
o Copy the code into a .c file.
3. Configure the Project:
o Add the file to the project.
o Set the target device and include the reg51.h header.
4. Compile the Code:
o Build the project to generate a .HEX file.
5. Simulate the Program:
o Load the .HEX file in the Proteus simulator.
o Connect a switch and an LED to the specified pins and observe the behavior.

Observations

47
Result

Conclusion

Assignment Evaluation

0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]

3: Needs Improvement [ ] 4: Complete [ ] 5: Well Done [ ]

Lab Incharge Signature

48
Assignment No. 9
Traffic Light Controller Using 8051 Microcontroller
Objective
To design and simulate a traffic light controller system using the 8051 microcontroller for:
1. Simple one-way traffic control.
2. Two-way or four-way traffic control.

Theory
Traffic light controllers manage traffic flow at intersections by using Red, Yellow, and Green
lights. A microcontroller like the 8051 is used to automate this process efficiently.

Part 1: Simple One-Way Traffic Light Controller


Circuit Design
1. Connect three LEDs (Red, Yellow, Green) to pins P1.0, P1.1, and P1.2 respectively.
2. Use 330Ω resistors for each LED in series.

Program

#include <reg51.h>

sbit RED = P1^0; // Red LED


sbit YELLOW = P1^1; // Yellow LED
sbit GREEN = P1^2; // Green LED
49
void delay(unsigned int ms) {
unsigned int i, j;
for (i = 0; i < ms; i++) {
for (j = 0; j < 1275; j++); // Approximate delay
}
}

void main() {
while (1) {
RED = 1; // Turn ON Red LED
YELLOW = 0; // Turn OFF Yellow LED
GREEN = 0; // Turn OFF Green LED
delay(5000); // 5-second delay

RED = 0; // Turn OFF Red LED


YELLOW = 1; // Turn ON Yellow LED
GREEN = 0; // Turn OFF Green LED
delay(2000); // 2-second delay

RED = 0; // Turn OFF Red LED


YELLOW = 0; // Turn OFF Yellow LED
GREEN = 1; // Turn ON Green LED
delay(5000); // 5-second delay
}
}

Part 2: Two-Way Traffic Light Controller


Circuit Design
1. Two sets of traffic lights:
o Set 1 (Main Road): LEDs connected to P1.0, P1.1, P1.2 (Red, Yellow, Green).
o Set 2 (Side Road): LEDs connected to P1.3, P1.4, P1.5 (Red, Yellow, Green).
Program

#include <reg51.h>

sbit RED_MAIN = P1^0; // Red LED for Main Road


sbit YELLOW_MAIN = P1^1; // Yellow LED for Main Road
sbit GREEN_MAIN = P1^2; // Green LED for Main Road

sbit RED_SIDE = P1^3; // Red LED for Side Road


sbit YELLOW_SIDE = P1^4; // Yellow LED for Side Road
sbit GREEN_SIDE = P1^5; // Green LED for Side Road

void delay(unsigned int ms) {


unsigned int i, j;
for (i = 0; i < ms; i++) {
for (j = 0; j < 1275; j++);
}
}
50
void main() {
while (1) {
// Main Road Green, Side Road Red
GREEN_MAIN = 1; RED_SIDE = 1;
YELLOW_MAIN = 0; RED_MAIN = 0;
GREEN_SIDE = 0; YELLOW_SIDE = 0;
delay(5000); // 5 seconds

// Main Road Yellow, Side Road Red


YELLOW_MAIN = 1; GREEN_MAIN = 0;
delay(2000); // 2 seconds

// Main Road Red, Side Road Green


RED_MAIN = 1; GREEN_SIDE = 1;
YELLOW_MAIN = 0; RED_SIDE = 0;
delay(5000); // 5 seconds

// Main Road Red, Side Road Yellow


YELLOW_SIDE = 1; GREEN_SIDE = 0;
delay(2000); // 2 seconds
}
}

Part 3: Four-Way Traffic Light Controller


Circuit Design
1. Four sets of traffic lights: North, South, East, and West.
2. LEDs connected to separate ports or pins for each direction.
Program Outline
 Each road has Red, Yellow, and Green LEDs.
 The program cycles through each road, ensuring only one has Green light at a time, while
others follow the standard Red-Yellow-Green sequence.

Steps to Simulate in Keil μVision:


1. Create a New Project:
a. Open Keil μVision and create a new project for the 8051 microcontroller.
2. Write the Program:
a. Copy the code into a .c file.
3. Configure the Project:
a. Add the file to the project.
b. Set the target device and include the reg51.h header.
4. Compile the Code:
a. Build the project to generate a .HEX file.
5. Load HEX File:
a. Compile the code in Keil μVision to generate a .HEX file.
b. Load the .HEX file into the 8051.
6. Run Simulation:
a. Observe the behavior of the LEDs representing traffic lights.

51
Observations

Result

Conclusion

Assignment Evaluation

0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]

3: Needs Improvement [ ] 4: Complete [ ] 5: Well Done [ ]

Lab Incharge Signature

52
Assignment No. 11
Interfacing LCD to 8051 Microcontroller
Objective
To interface a 16x2 LCD with the 8051 microcontroller in 8-bit mode and display a message.

Theory
In 8-bit mode, all 8 data pins (D0-D7) of the LCD are used for sending data and commands. This
mode provides faster communication compared to 4-bit mode as the full byte is sent at once.

Pin Configuration
1. Control Pins:
o RS: Register Select (0 for Command, 1 for Data).
o RW: Read/Write (0 for Write, 1 for Read).
o E: Enable (High to Low transition triggers data).
2. Data Pins:
o D0-D7: Data lines connected to the microcontroller's port for 8-bit
communication.

Circuit Design
1. Connections:
o Control Lines:
 RS -> P2.0
 RW -> P2.1
 E -> P2.2
o Data Lines:
 D0-D7 -> P1.0 to P1.7
o Adjust LCD contrast using a 10kΩ potentiometer connected to the VEE pin.
o Power pins (VCC and GND) connected to the power supply.

53
Program (8-Bit Mode)

#include <reg51.h>

sbit RS = P2^0; // Register Select


sbit RW = P2^1; // Read/Write
sbit EN = P2^2; // Enable

void delay_ms(unsigned int ms) {


unsigned int i, j;
for (i = 0; i < ms; i++) {
for (j = 0; j < 1275; j++); // Approximate delay
}
}

// Send a command to the LCD


void LCD_Command(unsigned char cmd) {
RS = 0; // Command mode
RW = 0; // Write mode
P1 = cmd; // Send command byte
EN = 1; // Enable pulse
delay_ms(2);
EN = 0;
}

// Send data to the LCD


void LCD_Data(unsigned char data) {
RS = 1; // Data mode
RW = 0; // Write mode
P1 = data; // Send data byte
EN = 1; // Enable pulse
delay_ms(2);
EN = 0;
}

// Initialize the LCD


void LCD_Init() {
LCD_Command(0x38); // 8-bit mode, 2 lines, 5x7 matrix
LCD_Command(0x0C); // Display ON, Cursor OFF
LCD_Command(0x06); // Auto-increment cursor
LCD_Command(0x01); // Clear display
delay_ms(2);
}

// Display a string on the LCD


void LCD_String(char *str) {
while (*str) {
LCD_Data(*str);
str++;
54
}
}

void main() {
LCD_Init(); // Initialize LCD
LCD_String("Hello, World!"); // Display message
LCD_Command(0xC0); // Move to second line
LCD_String("8051 Micro!"); // Display message
while (1);
}

Steps to Simulate in Proteus


Steps to Simulate in Keil μVision:
1. Create a New Project:
o Open Keil μVision and create a new project for the 8051 microcontroller.
2. Write the Program:
o Copy the code into a .c file.
3. Configure the Project:
o Add the file to the project.
o Set the target device and include the reg51.h header.
4. Compile the Code:
o Build the project to generate a .HEX file.
5. Load HEX File:
o Compile the code in Keil μVision to generate a .HEX file.
o Load the .HEX file into the 8051.
6. Run Simulation:
o Observe the LCD displaying "Hello, World!" on the first line and "8051 Micro!"
on the second line.

Observations

Result

Conclusion

Assignment Evaluation

0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]

3: Needs Improvement [ ] 4: Complete [ ] 5: Well Done [ ]

Lab Incharge Signature


55
Assignment No. 12
Interfacing with IR Sensor and LCD to 8051 Microcontroller
Objective
To interface an IR sensor and a 16x2 LCD with the 8051 microcontroller to detect objects and
display the sensor status on the LCD.
Theory
1. IR Sensor Basics:
o An IR sensor emits infrared light and detects reflected light to sense objects.
o It has three main pins:
 VCC: Power supply (typically 5V).
 GND: Ground.
 OUT: Digital output (High = Object detected, Low = No object).
2. LCD Basics:
o Used to display the status of the IR sensor.
o Operated in 8-bit mode for simplicity.
Pin Connections
1. IR Sensor:
o OUT -> P3.0 (digital input pin of 8051).
2. LCD:
o Control Pins:
 RS -> P2.0
 RW -> P2.1
 E -> P2.2
o Data Pins:
 D0-D7 -> P1.0-P1.7.
Circuit Design
1. Connect the IR sensor's output to P3.0 of the microcontroller.
2. Connect the LCD as described in the LCD interfacing circuit for 8-bit mode.
3. Use a 10kΩ potentiometer to adjust the LCD contrast.
4. Connect the VCC and GND of both IR sensor and LCD to the power supply.

56
Program

#include <reg51.h>

sbit RS = P2^0; // Register Select


sbit RW = P2^1; // Read/Write
sbit EN = P2^2; // Enable
sbit IR_SENSOR = P3^0; // IR Sensor output connected to P3.0

void delay_ms(unsigned int ms) {


unsigned int i, j;
for (i = 0; i < ms; i++) {
for (j = 0; j < 1275; j++);
}
}

// Send a command to the LCD


void LCD_Command(unsigned char cmd) {
RS = 0; // Command mode
RW = 0; // Write mode
P1 = cmd; // Send command byte
EN = 1; // Enable pulse
delay_ms(2);
EN = 0;
}

// Send data to the LCD


void LCD_Data(unsigned char data) {
RS = 1; // Data mode
RW = 0; // Write mode
P1 = data; // Send data byte
EN = 1; // Enable pulse
delay_ms(2);
EN = 0;
}

// Initialize the LCD


void LCD_Init() {
LCD_Command(0x38); // 8-bit mode, 2 lines, 5x7 matrix
LCD_Command(0x0C); // Display ON, Cursor OFF
LCD_Command(0x06); // Auto-increment cursor
LCD_Command(0x01); // Clear display
delay_ms(2);
}

// Display a string on the LCD


void LCD_String(char *str) {
while (*str) {
LCD_Data(*str);
57
str++;
}
}

void main() {
LCD_Init(); // Initialize LCD

while (1) {
if (IR_SENSOR == 1) { // Object detected
LCD_Command(0x80); // Move to the first line
LCD_String("Object Detected");
} else { // No object detected
LCD_Command(0x80); // Move to the first line
LCD_String("No Object "); // Clear remaining characters
}
delay_ms(500);
}
}

Steps to Simulate in Proteus


1. Create a New Project:
o Open Keil μVision and create a new project for the 8051 microcontroller.
2. Write the Program:
o Copy the code into a .c file.
3. Configure the Project:
o Add the file to the project.
o Set the target device and include the reg51.h header.
4. Compile the Code:
o Build the project to generate a .HEX file.
5. Circuit Design:
o 8051 microcontroller, IR sensor, and 16x2 LCD.
o Connect the components as described.
6. Load HEX File:
o Compile the code in Keil μVision to generate a .HEX file.
o Load the .HEX file into the 8051 microcontroller
7. Run Simulation:
o Move an object in front of the IR sensor.
o Observe the status update on the LCD:
 "Object Detected" when an object is detected.
 "No Object" when no object is present.
Observations

58
Result

Conclusion

Assignment Evaluation

0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]

3: Needs Improvement [ ] 4: Complete [ ] 5: Well Done [ ]

Lab Incharge Signature

59
Assignment No. 13
ADC Interfacing to 8051 Microcontroller
Objective
To interface an Analog-to-Digital Converter (ADC) with the 8051 microcontroller and display
the converted digital value on a 16x2 LCD.

Theory
1. Analog-to-Digital Converter (ADC):
o Converts an analog input signal into a corresponding digital value.
o Common ADC used: ADC0804.
 8-bit resolution.
 Takes analog input (0-5V) and converts it into an 8-bit digital value (0-
255).
2. Pin Configuration of ADC0804:
o VCC and GND: Power supply.
o VREF: Reference voltage (5V for full range).
o IN+ and IN-: Analog input pins.
o WR (Write): Starts the conversion process.
o RD (Read): Enables the digital output.
o INTR: Interrupt pin, goes low when conversion is complete.
o D0-D7: Digital output pins for 8-bit data.
3. LCD Basics:
o Used to display the converted digital value.

Pin Connections
1. ADC0804:
o WR -> P0.0
o RD -> P0.1
o INTR -> P0.2
o D0-D7 -> P3.0-P3.7 (digital output to microcontroller).
o IN+ -> Analog input (e.g., potentiometer).
o VREF -> 5V.
2. LCD:
o Control Pins:
 RS -> P2.0
 RW -> P2.1
 E -> P2.2
o Data Pins:
 D0-D7 -> P1.0-P1.7.

Circuit Design
1. Connect ADC0804 pins to the microcontroller as described.
2. Connect LCD in 8-bit mode to the microcontroller.
3. Use a potentiometer to provide an adjustable analog input to the ADC.

60
Program

#include <reg51.h>

sbit WR = P0^0; // ADC Write Pin


sbit RD = P0^1; // ADC Read Pin
sbit INTR = P0^2; // ADC Interrupt Pin
sbit RS = P2^0; // LCD Register Select
sbit RW = P2^1; // LCD Read/Write
sbit EN = P2^2; // LCD Enable

void delay_ms(unsigned int ms) {


unsigned int i, j;
for (i = 0; i < ms; i++) {
for (j = 0; j < 1275; j++);
}
}

// Send a command to the LCD


void LCD_Command(unsigned char cmd) {
RS = 0; // Command mode
RW = 0; // Write mode
P1 = cmd; // Send command byte
61
EN = 1; // Enable pulse
delay_ms(2);
EN = 0;
}

// Send data to the LCD


void LCD_Data(unsigned char data) {
RS = 1; // Data mode
RW = 0; // Write mode
P1 = data; // Send data byte
EN = 1; // Enable pulse
delay_ms(2);
EN = 0;
}

// Initialize the LCD


void LCD_Init() {
LCD_Command(0x38); // 8-bit mode, 2 lines, 5x7 matrix
LCD_Command(0x0C); // Display ON, Cursor OFF
LCD_Command(0x06); // Auto-increment cursor
LCD_Command(0x01); // Clear display
delay_ms(2);
}

// Display a string on the LCD


void LCD_String(char *str) {
while (*str) {
LCD_Data(*str);
str++;
}
}

// Convert an integer to a string


void IntToStr(unsigned int num, char *str) {
str[0] = (num / 100) + '0';
str[1] = ((num / 10) % 10) + '0';
str[2] = (num % 10) + '0';
str[3] = '\0';
}

// Read data from ADC


unsigned char ADC_Read() {
unsigned char data;
WR = 0; // Start conversion
delay_ms(2);
WR = 1; // Stop conversion
while (INTR == 1); // Wait for conversion to complete
RD = 0; // Read data
data = P1; // Read data from ADC
RD = 1; // Complete read process
62
return data;
}

void main() {
unsigned char adc_value;
char str[4];

LCD_Init(); // Initialize LCD


LCD_String("ADC Value:"); // Display heading

while (1) {
adc_value = ADC_Read(); // Read ADC value
IntToStr(adc_value, str); // Convert to string
LCD_Command(0xC0); // Move to second line
LCD_String(str); // Display ADC value
delay_ms(500);
}
}

Steps to Simulate in Proteus


1. Create a New Project:
o Open Keil μVision and create a new project for the 8051 microcontroller.
2. Write the Program:
o Copy the code into a .c file.
3. Configure the Project:
o Add the file to the project.
o Set the target device and include the reg51.h header.
4. Compile the Code:
o Build the project to generate a .HEX file.
5. Circuit Design:
o 8051 microcontroller, ADC0804, and 16x2 LCD.
o Connect the potentiometer to IN+ of ADC0804.
o Connect the components as described.
6. Load HEX File:
o Compile the code in Keil μVision to generate a .HEX file.
o Load the .HEX file into the 8051 microcontroller in Proteus.
7. Run Simulation:
o Adjust the potentiometer.
o Observe the digital value displayed on the LCD.

Observations

Result

63
Conclusion

Assignment Evaluation

0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]

3: Needs Improvement [ ] 4: Complete [ ] 5: Well Done [ ]

Lab Incharge Signature

64
Assignment No. 9
Waveform Generation Using DAC Interface to 8051 Microcontroller
Objective
To generate analog waveforms (e.g., sine wave, triangular wave, square wave) using the 8051
microcontroller and a Digital-to-Analog Converter (DAC).

Theory
1. Digital-to-Analog Converter (DAC):
o Converts digital signals from the microcontroller into analog signals.
o Common DACs, like the DAC0808, accept an 8-bit digital input and provide an
equivalent analog output.
2. Waveform Generation:
o Square Wave: Alternating between high and low digital values at regular
intervals.
o Triangular Wave: Gradually increasing and decreasing digital values to form a
triangular shape.
o Sine Wave: Approximated by sending precomputed sine values from a lookup
table to the DAC.
3. 8051-DAC Interface:
o DAC data pins are connected to an 8-bit port of the microcontroller (e.g., Port 1).
o The output of the DAC is the analog waveform.

Circuit Diagram
1. Connect the DAC’s data input pins (D0-D7) to Port 1 (P1.0 to P1.7) of the 8051
microcontroller.
2. Connect the DAC output to an oscilloscope or analog device to visualize the waveform.

65
Programs
1. Square Wave Generation

#include <reg51.h>

sbit DAC_PIN = P1; // Connect DAC to Port 1

void delay(unsigned int ms) {


unsigned int i, j;
for (i = 0; i < ms; i++) {
for (j = 0; j < 1275; j++); // Approximate delay for 1 ms
}
}

void main() {
while (1) {
P1 = 0xFF; // Output maximum value (high)
delay(500); // Delay for half a period
P1 = 0x00; // Output minimum value (low)
delay(500); // Delay for half a period
}
}

2. Triangular Wave Generation

#include <reg51.h>

void delay(unsigned int ms) {


unsigned int i, j;
for (i = 0; i < ms; i++) {
for (j = 0; j < 1275; j++);
}
}

void main() {
unsigned char value;
while (1) {
// Ascending values for triangular wave
for (value = 0; value < 255; value++) {
P1 = value; // Send value to DAC
delay(2); // Delay for smooth transition
}
// Descending values for triangular wave
for (value = 255; value > 0; value--) {
P1 = value; // Send value to DAC
delay(2); // Delay for smooth transition
}
}
}
66
3. Sine Wave Generation
#include <reg51.h>

// Sine lookup table (8-bit resolution)


unsigned char sine_table[32] = {
128, 152, 176, 198, 218, 234, 247, 255,
247, 234, 218, 198, 176, 152, 128, 104,
80, 58, 38, 22, 9, 1, 9, 22,
38, 58, 80, 104, 128, 152, 176, 198
};

void delay(unsigned int ms) {


unsigned int i, j;
for (i = 0; i < ms; i++) {
for (j = 0; j < 1275; j++);
}
}

void main() {
unsigned char i;
while (1) {
for (i = 0; i < 32; i++) {
P1 = sine_table[i]; // Send sine value to DAC
delay(2); // Adjust delay for frequency
}
}
}

Steps to Simulate in Keil μVision:


1. Create a New Project:
o Open Keil μVision and create a new project for the 8051 microcontroller.
2. Write the Program:
o Copy the code into a .c file.
3. Configure the Project:
o Add the file to the project.
o Set the target device and include the reg51.h header.
4. Compile the Code:
o Build the project to generate a .HEX file.
5. Simulate the Program:
o Load the .HEX file in the Proteus simulator.
o Connect a switch and an LED to the specified pins and observe the behavior.
6. Observe the Waveform:
o Use the oscilloscope to visualize the generated waveform.

67
Observations

Result

Conclusion

Assignment Evaluation

0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]

3: Needs Improvement [ ] 4: Complete [ ] 5: Well Done [ ]

Lab Incharge Signature

68
Assignment No. 14
DC Motor Interfacing to 8051 Microcontroller
Objective
To interface a DC motor with the 8051 microcontroller using an H-Bridge motor driver
(L293D) to control its direction and speed.

Theory
1. DC Motor Basics:
o A DC motor converts electrical energy into mechanical energy.
o Requires an external driver circuit due to higher current and voltage requirements.
2. H-Bridge Motor Driver (L293D):
o Acts as an interface between the microcontroller and the DC motor.
o Controls motor direction by varying the polarity of the voltage applied to the
motor terminals.
o Features:
 Input Pins (IN1, IN2): Control motor direction.
 Enable Pin (EN): Enables or disables the motor.
 Output Pins (OUT1, OUT2): Connect to the motor terminals.
3. Control Logic:
o IN1 = 1, IN2 = 0: Clockwise rotation.
o IN1 = 0, IN2 = 1: Counterclockwise rotation.
o IN1 = IN2 = 0: Motor off.

Pin Connections
1. L293D to 8051:
o IN1 -> P1.0
o IN2 -> P1.1
o EN1 (Enable) -> P1.2
2. Motor:
o Connect the motor terminals to OUT1 and OUT2 of L293D.
3. Power Supply:
o VCC1 (Logic): 5V.
o VCC2 (Motor): 12V (depending on motor rating).
o GND: Common ground.

Circuit Design
1. Connect the L293D motor driver IC as described.
2. Use a suitable DC motor with the driver outputs.
3. Use external power supplies for the motor and microcontroller.

69
Program
#include <reg51.h>

sbit IN1 = P1^0; // Input 1 for motor driver


sbit IN2 = P1^1; // Input 2 for motor driver
sbit EN = P1^2; // Enable pin for motor driver

void delay_ms(unsigned int ms) {


unsigned int i, j;
for (i = 0; i < ms; i++) {
for (j = 0; j < 1275; j++);
}
}

void Motor_Clockwise() {
EN = 1; // Enable motor
IN1 = 1; // Set direction to clockwise
IN2 = 0;
}

void Motor_Counterclockwise() {
EN = 1; // Enable motor
IN1 = 0; // Set direction to counterclockwise
IN2 = 1;
}

70
void Motor_Stop() {
EN = 0; // Disable motor
IN1 = 0; // Stop motor
IN2 = 0;
}

void main() {
while (1) {
Motor_Clockwise(); // Rotate motor clockwise
delay_ms(5000); // Run for 5 seconds
Motor_Stop(); // Stop motor
delay_ms(2000); // Wait for 2 seconds
Motor_Counterclockwise(); // Rotate motor counterclockwise
delay_ms(5000); // Run for 5 seconds
Motor_Stop(); // Stop motor
delay_ms(2000); // Wait for 2 seconds
}
}

Steps to Simulate in Proteus


1. Design Circuit:
o Add the 8051 microcontroller, L293D, and a DC motor.
o Connect the components as described.
2. Load HEX File:
o Compile the code in Keil μVision to generate a .HEX file.
o Load the .HEX file into the 8051 microcontroller in Proteus.
3. Run Simulation:
o Observe the motor rotating clockwise and counterclockwise alternately.

Observations

Result

Conclusion

71
Assignment Evaluation

0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]

3: Needs Improvement [ ] 4: Complete [ ] 5: Well Done [ ]

Lab Incharge Signature

72
Assignment No. 15
Stepper Motor Interfacing to 8051 Microcontroller
Objective
To interface a Stepper Motor with the 8051 microcontroller and control its rotation direction
(clockwise and counterclockwise) and steps.

Theory
1. Stepper Motor Basics:
o A stepper motor rotates in discrete steps, providing precise control over position.
o Types:
 Unipolar (easier control, multiple windings with a common center tap).
 Bipolar (requires an H-bridge, no center tap, stronger torque).
o Each step corresponds to energizing a specific sequence of coils.
2. Control Logic:
o Full-Step Mode:
 Two coils are energized simultaneously for each step.
o Half-Step Mode:
 Coils are energized alternately in single and double configurations.
o Wave Drive Mode:
 Only one coil is energized at a time.
3. ULN2003 Driver IC:
o Used to drive the stepper motor.
o Acts as an interface between the microcontroller and motor by amplifying current.
o Input pins control corresponding output pins to the motor.

Pin Connections
1. ULN2003 to 8051:
o IN1 -> P1.0
o IN2 -> P1.1
o IN3 -> P1.2
o IN4 -> P1.3
2. Stepper Motor:
o Connect stepper motor windings to the corresponding outputs of the ULN2003.
3. Power Supply:
o Provide sufficient power to the stepper motor (12V or as per motor
specifications).

Circuit Design
1. Connect the ULN2003 driver to the microcontroller and stepper motor.
2. Ensure proper grounding and power supply connections.

73
Program
#include <reg51.h>

sbit IN1 = P1^0; // Stepper Motor Input 1


sbit IN2 = P1^1; // Stepper Motor Input 2
sbit IN3 = P1^2; // Stepper Motor Input 3
sbit IN4 = P1^3; // Stepper Motor Input 4

void delay_ms(unsigned int ms) {


unsigned int i, j;
for (i = 0; i < ms; i++) {
for (j = 0; j < 1275; j++);
}
}

void Step_CW() { // Rotate clockwise


IN1 = 1; IN2 = 0; IN3 = 0; IN4 = 0;
delay_ms(2);
IN1 = 0; IN2 = 1; IN3 = 0; IN4 = 0;
delay_ms(2);
IN1 = 0; IN2 = 0; IN3 = 1; IN4 = 0;
delay_ms(2);
IN1 = 0; IN2 = 0; IN3 = 0; IN4 = 1;
delay_ms(2);
}

void Step_CCW() { // Rotate counterclockwise


IN1 = 0; IN2 = 0; IN3 = 0; IN4 = 1;
delay_ms(2);
IN1 = 0; IN2 = 0; IN3 = 1; IN4 = 0;
delay_ms(2);
74
IN1 = 0; IN2 = 1; IN3 = 0; IN4 = 0;
delay_ms(2);
IN1 = 1; IN2 = 0; IN3 = 0; IN4 = 0;
delay_ms(2);
}

void main() {
unsigned int steps;

while (1) {
// Rotate clockwise for 100 steps
for (steps = 0; steps < 100; steps++) {
Step_CW();
}
delay_ms(1000); // Wait for 1 second

// Rotate counterclockwise for 100 steps


for (steps = 0; steps < 100; steps++) {
Step_CCW();
}
delay_ms(1000); // Wait for 1 second
}
}

Steps to Simulate in Proteus


1. Design Circuit:
o Add the 8051 microcontroller, ULN2003, and stepper motor.
o Connect components as described.
2. Load HEX File:
o Compile the code in Keil μVision to generate a .HEX file.
o Load the .HEX file into the 8051 microcontroller in Proteus.
3. Run Simulation:
o Observe the motor rotating in the specified direction and steps.

Observations

75
Result

Conclusion

Assignment Evaluation

0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]

3: Needs Improvement [ ] 4: Complete [ ] 5: Well Done [ ]

Lab Incharge Signature

76
Programming the 89S52 Microcontroller Using ProISP 1.72

Software Requirement:

 ProISP 1.72 software (freely available for download from trusted sources).

Hardware Requirements:

 Target board with AT89S52 microcontroller.


 USBASP programmer or equivalent programmer compatible with AT89S52.
 USB cable for connecting the programmer to the PC.
 Power supply for the target board.
 HEX file of the program to be loaded into the microcontroller.

Procedure

Step 1: Install and Configure ProISP

1. Download ProISP 1.72:


o Download the tool from a trusted source or the programmer manufacturer's
website.
o Install the tool on a Windows-compatible computer.
2. Launch ProISP. The main interface will display options for selecting the device, loading
HEX files, and configuring programming settings.

Step 2: Connect the Hardware

1. Connect the Programmer to the Target Board:


o Connect the USBASP programmer to the ISP header on the target board.
o Ensure the pinout matches the target board's ISP connector (MOSI, MISO, SCK,
RESET, VCC, and GND).
2. Connect the Programmer to the PC:
o Use a USB cable to connect the programmer to the computer.
3. Power on the target board.

Step 3: Program the Microcontroller

1. Select the Microcontroller:


o In ProISP, choose the AT89S52 microcontroller from the list of supported
devices.
2. Load the HEX File:
o Click the Load Flash button to browse for and select the HEX file to be
programmed.
3. Configure Programming Options:
o Set the desired options for erasing flash, writing the program, and verifying after
programming.
o Recommended for beginners: Enable Verify After Programming.
4. Start the Programming Process:
o Click the Auto button to begin the programming process. This will:

77
 Erase the flash memory.
 Write the HEX file to the microcontroller.
 Verify the written data.

Step 4: Verify and Test

1. Observe the status messages in ProISP to ensure programming is successful.


2. Disconnect the programmer and power off the target board.
3. Power on the target board and verify that the programmed code functions as intended.

78
[Sample Practical Slip]

Savitribai Phule Pune University

F.Y.B.C.A. /F.Y.B.Sc.(CA) Practical Examination (NEP Pattern)

Lab Course: CA- 154 - P Lab course on CA- 153 - T

Duration: 3 Hours Maximum Marks: 35

Q1 . Write an 8051 assembly Program (10 Marks)

A. To find the largest and smallest number from a given series __,__,__,__,__,__,__
OR
B. To perform addition, subtraction, multiplication, or division of ___-bit data.

____ _____

Q2. Draw the block diagram of given interface and write 8051 C Program (20 Marks)

A. To interface an LCD to display "WELCOME 8051".


OR
B. To control the speed and direction of a DC motor using the 8051 microcontroller.

Q3. Viva (5 Marks)

79

You might also like