New - Lab Manual Microprocessor and Microcontroller Manual 2019
New - Lab Manual Microprocessor and Microcontroller Manual 2019
Laboratory
B.Tech. IV Semester
Name :
Roll Number :
Department : Electronics and Communication Engineering
1. Write a program using 8086 microprocessor to perform arithmetic operations on 8 bit and
16 bit numbers using EMU 8086 software (addition, subtraction, multiplication and
division)
2. Write a program using 8086 microprocessor to perform arithmetic operations on 8 bit and
16 bit numbers using kit(addition, subtraction, multiplication and division)
3. Write a program for code conversion-Binary to Gray & Gray to Binary using 8086
microprocessor
4. Write a program for sorting a list of numbers in ascending & descending order using 8086
microprocessor
5. Write a program using 8051 microcontroller to perform arithmetic operations on 8 bit and
16 bit numbers using software (addition, subtraction, multiplication and division)
6. Write a program using 8051 microcontroller to perform arithmetic operations on 8 bit and
16 bit numbers using kit (addition, subtraction, multiplication and division)
7. Write programs for Code conversions using 8051 microcontroller (decimal to hexadecimal
and vice versa)
8. Write 8051 microcontroller programming using Timer0 to create a 10KHz square wave
9. Implement LED blinking and fading using Arduino board
10. Interface LCD with Arduino board to display message
11. Interface IR and ultrasonic sensor with Arduino board
12. Design a stepper motor and servo motor controller
Index Sheet
Name: Semester /Year:
Registration No: Staff In-charge:
Course: Microprocessors and Microcontrollers Laboratory
Experiment VIVA Total
Sl.
Name of the Experiment/Exercise Conduction
No. (10) (20)
(10)
8086 microprocessor to perform arithmetic
1 operations on 8 bit and 16 bit numbers using
EMU 8086 software
8086 microprocessor to perform arithmetic
2
operations on 8 bit and 16 bit numbers using kit
Code conversion: Binary to Gray & Gray to
3
Binary using 8086 microprocessor
Sorting a list of numbers in ascending &
4
descending order using 8086 microprocessor
8051 microcontroller to perform arithmetic
5 operations on 8 bit and 16 bit numbers using
software
8051 microcontroller to perform arithmetic
6
operations on 8 bit and 16 bit numbers using kit
Code conversions: Decimal to hexadecimal and
7
vice versa using uC
8 Create a 10KHz square wave using Timer0
Implement LED blinking and fading using
9
Arduino board
Interface LCD with Arduino board to display
10
message
Interface IR and ultrasonic sensor with Arduino
11
board
Design a stepper motor controller and traffic
12
light controller
13 Internal Test
Operand: - We can also say it as data on which operation should act. Operands may be register values
or memory values. The CPU executes the instructions using information present in this field. It may be
8-bit data or 16-bit data
Assembler: - it converts the instruction into sequence of binary bits, so that this bits can be read by
the processor
Mnemonics: - these are the symbolic codes for either instructions or commands to perform a
particular function
Microprocessor 8086 is a 16-bit processor with 20 bit address bus, which can access up to
220memory locations (1 MB). Address ranges from 00000H to FFFFFH
Memory is byte addressable - Every byte has a separate address
It can support up to 64K I/O ports and provides 14, 16 -bit registers
It is a 40 pin Dual Inline Package (DIP) Integrated Circuit (IC), that supports multiplexed address
and data bus AD0- AD15 and A16 – A19 to reduce the number of pins used in IC
8086 is designed to operate in two modes, Minimum and Maximum
It can prefetch up to 6 instruction bytes from memory and queues them in order to speed up
instruction execution (pipelining)
It requires +5V power supply
Aim
Program
a. Addition
b. Subtraction
d. Division
3. Presentation of Results
4. Conclusions
Laboratory 2
8086 Microprocessor to Perform Arithmetic Operations on 8 bit
and 16 bit Numbers Using Kit
i. AIM: Arithmetic Operations (Addition, Subtraction, Multiplication and division) of two 8-bit
numbers using immediate addressing mode.
Result:
Result:
Table 3: Multiplication Program
Offset Opcode Mnemonic comment
Address
Result:
ii. AIM: Arithmetic Operations (Addition, Subtraction, Multiplication and division) of two 16-
bit numbers using direct addressing mode.
RESULT: AX=
Input:-
Location Data
1700 88
1701 00
1702 44
1703 00
RESULT: AX=
Input:-
Location Data Output:
1700 88
1701 00
1702 44
1703 00
iii. AIM: Arithmetic Operations (Addition and Subtraction) of two 8- bit numbers using indirect
addressing mode.
RESULT :
Input:-
Location Data
1700 04
1701 04
Output: - 1800 08
RESULT:
Input:-
Location Data
1700 09
1701 04
Output:-
1800 05
Laboratory 3
Code Conversion-Binary to Gray & Gray to Binary using 8086
Microprocessor
1. Aim
To develop assembly language program in 8086 mnemonics using nested loops for code
conversion
2. Program
Binary to Gray
MOV AX, 2314H; MOVE THE BINARY DATA (11001011) INTO THE REGISTER AX
MOV BX, AX; MOVE DATA IN AX TO BX
SHR BX, 01; SHIFT THE DAT IN BX TO RIGHT BY 1 BIT
XOR AX, BX; PERFORM XOR OPERATION ON AX AND BX
Gray to Binary
MOV AL, 1110B;
MOV BL, AL;
SHR BL, 1;
XOR BL, AL;
SHR BL, 1;
XOR BL, AL;
SHR BL, 1;
XOR BL, AL;
MOV AL, BL;
3. Presentation of Results
4. Conclusions
Laboratory 4
Sorting a List of Numbers in Ascending & Descending Order Using 8086
Microprocessor
Aim
To develop assembly language program in 8086 mnemonics for sorting the numbers in
ascending & descending order
1. Program
Ascending Order
MOV SI, 4000H;
MOV BX, 03H;
MOV CX, 03H;
L1: MOV AX, [SI];
CMP AX, [SI+2];
JC GO;
XCHG AX, [SI+2];
XCHG AX, [SI];
GO: INC SI;
INC SI;
DEC CX;
JNZ L1;
MOV CX, 03H;
MOV SI, 4000H;
DEC BX;
JNZ L1;
Descending Order
2. Presentation of Results
3. Conclusions
Introduction of 8051 microcontroller kit and emulator
MCS 8051 is an 8-bit single chip microcontroller with many built-in functions and is the core for
all MCS-51 devices
P1.0 1 40 Vcc
P1.1 2 39 P0.0(AD0
P1.2 3 38 )P0.1(AD1)
P1.3 4 37 P0.2(AD2
P1.4 5 8051 36 P0.3(AD3)
)
P1.5 6 35 P0.4(AD4)
P1.6 7 34 P0.5(AD5)
P1.7 8 33 P0.6(AD6)
RST 9 32 P0.7(AD7)
(RXD)P3.0 10 31 EA/VPP
(TXD)P3.1 11 30 ALE/PROG
(INT0)P3.2 12 29 PSEN
(INT1)P3.3 13 28 P2.7(A15)
(T0)P3.4 14 27 P2.6(A14
(T1)P3.5 15 26 )P2.5(A13
(WR)P3.6 16 25 P2.4(A12
)
(RD)P3.7 17 24 )P2.3(A11
XTAL2 18 23 P2.2(A10)
)
XTAL1 19 22 P2.1(A9)
GND 20 21 P2.0(A8)
Program status word (PSW) at address DOH contains status bits as summarized in the following table
Keil Software Demostration:
2. Program
a. Addition
b. Subtraction
c. Multiplication
d. Division
3. Results
4. Conclusions
Laboratory 6
8051 Microcontroller to Perform Arithmetic Operations on 8 bit
and 16 bit Numbers Using Kit
1. Aim
Aim
2. Program
a. Addition
b. Subtraction
c. Multiplication
d. Division
3. Results
4. Conclusions
Laboratory 7
Code Conversion Programs in 8051
1. Aim
To develop assembly language program for code conversion in 8051
2. Program
Hexadecimal to Decimal
MOV A, 30H;
MOV B, #64H;
DIV AB;
MOV 41H, A;
MOV A, B;
MOV B, #0AH;
DIV AB;
SWAP A;
ADD A, B;
MOV 40H, A;
Decimal to Hexadecimal
MOV A, 30H;
ANL A, #0FH;
MOV R0, A;
MOV A, 30H;
ANL A, #0F0H;
SWAP A;
MOV B, #0AH
MUL AB;
ADD A, R0;
MOV 40H, A;
3. Results
4. Conclusions
Laboratory 8
Generation of 10 KHz Square Wave Using Timer in Microcontroller 8051
1. Aim
To generate 10 KHz Square Wave using 8051
2. Calculations
3. Program
4. Presentation of Results
5. Conclusions
Arduino Introduction
Arduino is a prototype platform (open-source) based on an easy-to-use hardware and
software. It consists of a circuit board, which can be programed (referred to as a
microcontroller) and a ready-made software called Arduino IDE (Integrated Development
Environment), which is used to write and upload the computer code to the physical board.
The key features are:
Arduino boards are able to read analog or digital input signals from different sensors
and turn it into an output such as activating a motor, turning LED on/off, connect to
the cloud and many other actions.
You can control your board functions by sending a set of instructions to the
microcontroller on the board via Arduino IDE (referred to as uploading software).
Unlike most previous programmable circuit boards, Arduino does not need an extra
piece of hardware (called a programmer) in order to load a new code onto the board.
You can simply use a USB cable.
Additionally, the Arduino IDE uses a simplified version of C++, making it easier to learn
to program.
Finally, Arduino provides a standard form factor that breaks the functions of the
micro-controller into a more accessible package.
Board Types and their specification:
BOARD DESCRIPTIONS:
USING ARDUINO IDE:
Launch Arduino IDE.
After your Arduino IDE software is downloaded, you need to unzip the folder. Inside the
folder, you can find the application icon with an infinity label (application.exe). Doubleclick
the icon to start the IDE.
Open your first project.
To open an existing project example, select File -> Example -> Basics -> Blink.
Laboratory 9
1. To blink an LED i.e. turning a LED on and off based on the defined delay.
Components required and interfacing circuit:
1x Breadboard
1x Arduino Uno R3
1x LED
1x 330Ω Resistor
2x Jumper
Arduino Code
/*
Blink Turns on an LED on for one second, then off for one second,repeatedly. */
// the setup function runs once when you press reset or power the board void setup()
{
// the loop function runs over and over again forever void loop()
{
digitalWrite(2, HIGH);
delay(1000); digitalWrite(2, // turn the LED on (HIGH is the voltage level)
LOW); delay(1000);
// wait for a second
}
Code to Note
pinMode(2, OUTPUT) - Before you can use one of Arduino’s pins, you need to tell Arduino Uno R3
whether it is an INPUT or OUTPUT. We use a built-in “function” called pinMode() to do this.
digitalWrite(2, HIGH) - When you are using a pin as an OUTPUT, you can command it to be HIGH
(output 5 volts), or LOW (output 0 volts).
Observations:
Fade
This example shows how to fade an LED on pin 9 using the analogWrite() function. The analogWrite() function
uses PWM, so to change the pin use another PWM capable pin. On most Arduino, the PWM pins are identified
with a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11.
*/
void setup()
pinMode(led, OUTPUT);
43
void loop()
analogWrite(led, brightness);
fadeAmount = -fadeAmount ;
delay(300);
Observations:
44
Laboratory 10
1. To determine the distance of object using ultrasonic sensor interfaced with
arduino.
Components required and interfacing circuit:
1x Breadboard
1x Arduino Uno R3
Arduino Code:
const int pingPin = 7; // Trigger Pin of Ultrasonic Sensor
void setup()
void loop()
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
pinMode(echoPin, INPUT);
45
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
return microseconds / 74 / 2;
return microseconds / 29 / 2;
Observation:
46
Arduino Code:
float temp;
int tempPin = 0;
void setup()
Serial.begin(9600);
void loop()
temp = analogRead(tempPin);
Serial.print("TEMPERATURE = ");
Serial.print("*C");
Serial.println();
Observation:
47
Laboratory 11
To display “Hello World” using LCD interfaced with Arduino.
Components required and interfacing circuit:
Arduino or Genuino Board
LCD Screen (compatible with Hitachi HD44780 driver)
pin headers to solder to the LCD display pins
10k ohm potentiometer
220 ohm resistor
Arduino Code:
/*
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
The circuit:
48
* LCD VSS pin to ground
* 10K resistor:
*/
#include <LiquidCrystal.h>
void setup() {
lcd.begin(16, 2);
lcd.print("hello, world!");
void loop() {
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
lcd.print(millis() / 1000);
Observation:
49
Laboratory 12
Aim of Experiment:
1. To interface the servo motor with arduino as per determined steps.
Components required and interfacing circuit:
1x Arduino UNO board
Arduino Code:
/* Stepper Motor Control */
#include <Stepper.h>
void setup() {
myStepper.setSpeed(5);
Serial.begin(9600);
void loop() {
50
// step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(500);
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
delay(500);
}}
Observation:
2. To interface servo motor with the Arduino for maintaining the angular
position of the shaft.
Components required and interfacing circuit:
1x Arduino UNO board
1x 10 KΩ Resistor
51
Arduino Code:
/* Controlling a servo position using a potentiometer (variable resistor) */
#include <Servo.h>
int val; // variable to read the value from the analog pin
void setup()
void loop()
val = analogRead(potpin);
delay(15);
Observation:
52