Microprocessor Theory and Interfacing LAB MANUAL Goup
Microprocessor Theory and Interfacing LAB MANUAL Goup
Verified by:
Engr. Dr. Muhammad Farhan
(Assistant Professor)
Approved by:
The laboratory of each and every subject taught in the degree of bachelor’s in
electrical engineering & Technology is of very much importance in every University.
Fully equipped laboratory meeting the industrial demands under the supervision of
qualified, talented, and practically motivated lab assistants and lab engineers is also a basic
criterion of the National Technology Council. This Manual has been formulated
considering all these above mentioned points.
With Regards
Mubashar Ahmad
Lab Engineer
OBJECTIVE
To have the idea of the 8086 architecture.
To have detailed information about the MDA-8086 Microprocessor Trainer
EQUIPMENT
PC having Intel microprocessor, MDA-8086 kit.
MDA-Win8086
Power Cords
Communication Cables
Data Sheet
THEORY
A microprocessor is a controlling unit of a micro-computer, fabricated on a small chip capable of
performing Arithmetic Logical Unit (ALU) operations and communicating with the other
devices connected to it. Microprocessor consists of an ALU, register array, and a control unit.
ALU performs arithmetical and logical operations on the data received from the memory or an
input device. Register array consists of registers identified by letters like B, C, D, E, H, L and
accumulator. The control unit controls the flow of data and instructions within the computer.
The general microcontroller consists of the processor, the memory (RAM, ROM, EPROM),
Serial ports, peripherals (timers, counters), etc. A typical microcontroller includes a processor,
memory, and input/output (I/O) peripherals on a single chip.
Pin Diagram:
The introduction to the pins of the 8086 are as follows:
8086 was the first 16-bit microprocessor available in 40-pin DIP (Dual Inline Package) chip. It
consists of different input, output, control, clock and communication pins.
The detail of all the pins is present in the data sheet of the 8086.
̅𝑺̅𝟎̅, ̅𝑺̅𝟏̅, ̅𝑺̅𝟐̅ Status signals; used by the 8086 bus controller to generate bus timing and
control signals. These are decoded as shown
̅𝑸̅̅𝑺̅̅𝟎̅, ̅𝑸̅̅𝑺̅̅𝟏̅ (Queue Status) the processor provides the status of queue in these lines. The
queue status can be used by external device to track the internal status of the queue in 8086. The
output on QS0 and QS1 can be interpreted as shown in the table.
̅𝐑̅̅𝐐̅/̅𝐆̅̅𝐓̅𝟎̅, ̅𝐑̅̅𝐐̅/𝐆̅̅̅𝐓̅𝟏̅ (Bus Request/ Bus Grant)) these requests are used by other
local bus masters to force the processor to release the local bus at the end of the processor’s
current bus cycle.
These pins are bidirectional. The request on(GT_0 ) ̅ will have higher priority than(GT_1 ) ̅.
̅𝐋̅𝐎̅̅̅𝐂̅̅𝐊̅ An output signal activated by the LOCK prefix instruction. Remains active until the
completion of the instruction prefixed by LOCK. The 8086 output low on the (LOCK) ̅ pin while
executing an instruction prefixed by LOCK to prevent other bus masters from gaining control of
the system bus.
Features of 8086:
The most prominent features of 8086 microprocessor are as follows:
1. It has an instruction queue, which is capable of storing six instruction bytes
from the memory resulting in faster processing.
2. It was the first 16-bit processor having 16-bit ALU, 16-bit registers, internal data
bus, and 16-bit external data bus resulting in faster processing.
3. It is available in 3 versions based on the frequency of operation −
Flag Purpose
Carry (CF) Holds the carry after addition or the borrow after subtraction.
Also indicates some error conditions, as dictated by some
programs and procedures .
Parity (PF) PF=0;odd parity, PF=1;even parity.
Auxiliary (AF) Holds the carry (half – carry) after addition or borrow after
subtraction between bit positions 3 and 4 of the result
(for example, in BCD addition or subtraction.)
Zero (ZF) Shows the result of the arithmetic or logic operation.
Z=1; result is zero. Z=0; The result is 0
Sign (SF) Holds the sign of the result after an arithmetic/logic instruction
execution. S=1; negative, S=0
Trap (TF) A control flag. Enables the trapping through an on-chip debugging
feature
Interrupt (IF) A control flag. Controls the operation of the INTR (interrupt
request) I=0; INTR pin disabled. I=1; INTR pin enabled.
Direction (DF) A control flag. It selects either the increment or decrement mode for
DI and /or SI registers during the string instructions.
Overflow (OF) Overflow occurs when signed numbers are added or subtracted. An
overflow indicates the result has exceeded
the capacity of the Machine
STC Set CF 1
CLC Clear CF 0
CMC Complement carry CF CF/
STD Set direction flag DF 1
CLD Clear direction flag DF 0
STI Set interrupt enable flag IF 1
CLI Clear interrupt enable flag IF 0
NOP No operation
HLT Halt after interrupt is set
WAIT Wait for TEST pin active
ESC opcode mem/ reg Used to pass instruction to a coprocessor which
shares the address and data bus with the 8086
LOCK Lock bus during next instruction
Control Transfer Instructions
JC disp8 Jump if CF = 1
JP disp8 Jump if PF = 1
JO disp8 Jump if OF = 1
JS disp8 Jump if SF = 1
Mnemonics Explanation
CALL reg/ mem/ disp16 Call subroutine
RET Return from subroutine
JMP reg/ mem/ disp8/ disp16 Unconditional jump
MDA-8086 Features.
In this experiment, we understand the idea of mda-8086 and learned about all
components which are embedded on board,
And also acknowledge the working of hardware like keypad, LEDs, etc.
Total
OBJECTIVE
To get familiar with the serial communication between mda-8086 trainer and pc.
EQUIPMENT
PC having Intel microprocessor, MDA-8086 kit.
THEORY:-
Serial Monitor:-
Serial monitor is the basic monitor program to do data communicate between MDA-Win8086
and your computer.
How to setup the serial monitor
Adjust the P1 switch as following figure.
Menu bar
Terminal window
Terminal window is that you can use to connect the MDA-Win8086 kit.
Troubleshooting
The output window lists tool information during the code generation. You may check on error
messages to correct syntax errors in your program.
Select the serial port to connected to your PC. (ie. COM1, COM2, COM3 or COM4 ) BPS :
9600, Parity : None, Stop bits : 1
Press MDA-Win8086 RESET KEY again then "8086>" prompt will be displayed.
Click button or select "Trace" from the Run menu. You can also type 'T' and "Enter" key
on Terminal window. The Trace command in the work menu executes one instruction.
CONCLUSION:-
In this experiment, we managed to create a communication between pc and mda-
8086 trainer.
And learned about program setup on pc, work tabs, port setting, compiling and
execution of Instruction.
Activity Name
Serial communication interface between mda-8086 trainer
and pc.
Group No. 07
Student Roll No. 8034 8035 8036 8037
C PL Domain +
No. O Taxonomy Criteria Awarded Score (out of 4 for each cell)
L
O
Conduct experiments in
laboratory in order to interpret
1 A2 experimental data and displays
its conformance with analyzed
results of circuits.
-
- - - - -
Total
THEORY
Peripheral Interfacing is considered to be a main part of Microprocessor, as it is the only way to
interact with the external world. The interfacing happens with the ports of the Microprocessor.
The INTEL 8255 is a device used to parallel data transfer between processor and
slow peripheral devices like ADC, DAC, keyboard, 7-segment display, LCD, etc.
The 8255 has three ports: Port-A, Port-B and Port-C.
/*****************************************
* MDE-Win8086 EXPERIMENT PROGRAM *
* FILENAME : LED.C
* PROCESSOR : I8086
* 8255 test
*****************************************/
#include "mde8086.h"
void wait( long del )
{
while( del-- );
}
void main( void )
{
unsigned char led;
outportb( PPI1_CR, 0x80 );
outportb( PPI1_B, 0xff );
outportb( PPI1_A, 0xff );
outportb( PPI1_C, 0X20 );
led = 0xf1;
do {
outportb( PPI1_B, led );
led = led << 1;
if( led & 0x10 ) led = 0xf1;
wait( 10000 );
} while( 1);
}
CONCLUSION:-
In this experiment we have interfaced led’s using 8255a with mda-8086 trainer. And on
the trainer there are 4 led’s which operate by given input in the controlling program.
Activity Name
Interfacing of led’s using 8255a interface with mda-8086
trainer
Group No. 07
Student Roll No. 8034 8035 8036 8037
C PL Domain +
No. L O Taxonomy Criteria Awarded Score (out of 4 for each cell)
O
Conduct experiments in
laboratory in order to interpret
1 A2 experimental data and displays
its conformance with analyzed
results of circuits.
-
- - - - -
2. ON the MDA 8085 Microprocessor Trainor and Select Serial Monitor Mode with mode
selection switch P1 to PC
void main(void)
{
int *data1;
do {
data1 = data;
CONCLUSION:-
In this experiment we perform the 7-segment interfacing on mda-8086 trainer and conduct
different alphabet and digits on trainer.
Activity Name
Interfacing of 7-segment using 8255a interface with mda-
8086 trainer.
Group No. 07
Student Roll No. 8034 8035 8036 8037
C PL Domain +
No. O Taxonomy Criteria Awarded Score (out of 4 for each cell)
L
O
Conduct experiments in
laboratory in order to interpret
1 A2 experimental data and displays
its conformance with analyzed
results of circuits.
-
- - - - -
Total
Arduino programming jack known as B typer usb port because it looks like B and using A type usb port we can
connect arduino with computer and android phone (using OTG) using A to B data cable for upload code.
The use of a reverse polarity protection diode in Arduino in series to a circuit impresses by its simplicity
and the fact that no current flows if a reverse voltage is applied. If a revers voltage is applied by mistake
so there will be no issues in Arduino board.
There are some drawbacks regarding this solution, however. The voltage drop over the diode is around
0.7 V for a normal silicon diode. This is especially an issue with low supply voltage.
Op-Amp IC (Comparator)
This IC is used for when data cable and external power supply are connected at the same time, so this IC compare
voltage and allows one voltage to pass.
In Arduino ATMega16U2 is used for USB to TTL converter because microcontroller cannot understand USB
language directly, we can upload program in ATMega328P without using ATMega16U2 IC by using external USB
to TTL device (ch340).
ICSP header
ICSP stands for In-Circuit Serial Programming. The name originated from In-System Programming
headers (ISP). Manufacturers like Atmel who work with Arduino have developed their own in-circuit
serial programming headers. These pins enable the user to program the Arduino boards’ firmware. There
Reset button
When reset button press program will run from beginning with initial values.
Microcontroller IC
The ATmega328 is a single-chip microcontroller created by Atmel in the megaAVR family (later
Microchip Technology acquired Atmel in 2016) and use in Arduino board as a microcontroller.
Pin configuration with respect to Arduino
Here input voltage value is with respect to the Arduino because actually that microcontroller is worked
on 5Vdc, but Arduino board have a 5V regulator.
UNO’sheart.
It operates ranging from 3.3V to 5.5V but normally we use 5V as a standard.
Its excellent features include cost-efficiency, low power dissipation, programming lock for security
purposes, real timer counter with separate oscillator.
It’s normally used in Embedded System applications. You should have a look at these Real Life
Examples of Embedded Systems, we can design all of them using this Microcontroller.
ATmega328 Pins
ATmega-328 is an AVR Microcontroller having twenty-eight (28) pins in total.
All of the pins in chronological order, are listed in the table shown in the figure given below.
RESET pin
IOREF pin
Analog pins
Arduino boards contain a multichannel, 10-bit analog to digital converter. This means that it will map
input voltages between 0 and the operating voltage (5V or 3.3V) into integer values between 0 and
1023.Arduino Uno board have 6 analog pins (A0-A5). And these pins are also used as digital input
output purpose.
TWI pins
The Two-Wire Interface (TWI) is similar to the I2C interface with a few differences. The TWI
peripheral provides an interface to components on a unique two-wire bus, consisting of one clock
line and one data line.
Digital pins
Arduino Uno is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins
(of which 6 can be used as PWM outputs)
PWM pins
Pulse Width Modulation, or PWM, is a technique for
getting analog results with digital means. Digital
control is used to create a square wave, a signal
switched between on and off. ... The duration of "on
time" is called the pulse width. To get varying analog
values, you change, or modulate, that pulse width.
Problem 01
Open the IDE that is working area for coding and happy coding
Double click on Arduino and open a new window go to program file and paste here hex file path
2nd method to upload code in Arduino which is little bit easy for you
Copy all code from IDE
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
Go to Proteus file and right click on Arduino > Edit source code & paste code here
Run simulation
2. Connect the Arduino board to your computer using the USB cable.
5. Verify / compile code and upload / run the code button to send sketch to the Arduino.
Circuit Diagram:
Introduction of Arduino.
Interface between Arduino and PC
Activity Name
Integration of Arduino in Proteus
Interfacing of LEDs with Arduino.
Group No. 07
Student Roll No. 8034 8035 8036 8037
C PL Domain +
No. O Taxonomy Criteria Awarded Score (out of 4 for each cell)
L
O
Conduct experiments in
laboratory in order to interpret
1 A2 experimental data and displays
its conformance with analyzed
results of circuits.
-
- - - - -
Total
OBJECTIVE
To expose student and gain more knowledge about 7-Segment Technology
EQUIPMENT
Arduino IDE
Proteus
7-Segment
Resistor
THEORY
What is 7-Segment display?
A seven-segment display (SSD), or seven-segment indicator, is a form of electronic display device for
displaying decimal numerals. Seven-segment displays are widely used in digital clocks, electronic
meters, and other electronic devices for displaying numerical information. Composed of seven elements.
Individually on or off, they can be combined to produce simplified representations of the numerals.
Seven segment is a display which may be either common anode or common cathode. Which is ON
either on 1 or zero but here we use the format ‘ON’ on zero.
Seven segment LED displays are often found in clock radios, VCRs, microwave ovens, toys and many
other household items. They are primarily used to display decimal numbers, but they can also display a
few alphabets and other characters. The difference between the two displays is the common cathode has
all the cathodes of the 7-segments connected directly together and the common anode has all the anodes
of the 7-segments connected together. Seven-segment LED is a digital display module specialized to
display numerical information. Light-emitting diodes (LEDs) arranged in the shape of numbers offer an
easily visible display. They are sometimes called "seven-segment displays" or "seven-segment
indicators."
A seven-segment LED display shows a single digit or character using LED segments. Each
segment is an individual LED, and by controlling which segments are lit at any time, we can display
numeric values. We’re using a single-digit display in this project, shown in Figure, but there are also
two-, three-, four-, and eight-digit variations available.
NOTE
The cathode of a device is the negative connection, usually indicated with a minus sign (–) and
sometimes referred to as ground (abbreviated GND). It is connected to negative power. The anode of a
device is the positive connection, usually indicated with a plus sign (+) and connected to positive power.
(sevseg)
Project On Proteus
Code :
#define a 3
#define b 4
#define c 5
#define d 6
#define e 7
#define f 8
#define g 9
#define h 10
void setup() {
Serial.begin(9600);
pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
pinMode(h, OUTPUT);
}
void loop()
{ digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
digitalWrite(h,LOW);
delay(1000);
}
EQUIPMENT
Arduino IDE
LCD 16x2
Connecting Leads
Variable Resistor
THEORY
What is LCD 16X2?
An electronic device that is used to display data and the message is known as LCD 16×2. As the
name suggests, it includes 16 Columns & 2 Rows so it can display 32 characters (16×2=32) in total
& every character will be made with 5×8 (40) Pixel Dots. So the total pixels within this LCD can
be calculated as 32 x 40 otherwise 1280 pixels.
LCD 16 X2
16 X2 displays mostly depend on multi-segment LEDs. There are different types of displays
available in the market with different combinations such as 8×2, 8×1, 16×1, and 10×2, however,
The pin configuration of LCD 16 X 2 is discussed below so that LCD 16×2 connection can be done
easily with external devices.
Sr. Pin
Pin Name Pin Type Pin Description Pin Connection
No No.
6 Pin Enable Control Pin Must be held high to Connected to MCU and
Working Principle
The basic working principle of LCD is passing the light from layer to layer through modules. These
modules will vibrate & line up their position on 90 o that permits the polarized sheet to allow the
light to pass through it.
These molecules are accountable for viewing the data on every pixel. Every pixel utilizes the
method of absorbing light to illustrate the digit. To display the value, the position of molecules
must be changed to the angle of light.
So this light deflection will make the human eye notice the data that will be the ingredient
wherever the light gets absorbed. Here, this data will supply to the molecules & will be there till
they get changed
At present, LCDs are used frequently in CD/DVD players, digital watches, computers, etc. In
screen industries, LCDs have replaced the CRTs (Cathode Ray Tubes) because these displays use
more power as compared to LCD, heavier & larger.
The displays of LCDs are thinner as compared to CRTs. As compared to LED screens, LCD has
less power consumption because it functions on the fundamental principle of blocking light instead
of dissipating.
The registers used in LCD are two types like data register & command register. The register can
be changed by using the RS pinout. If we set ‘0’ then it is command register and if it is ‘1’ then it
is data register.
Command Register
The main function of the command register is to save instructions illustrated on LCD. That assists
in data clearing & changes the cursor location & controls the display.
Data Register
The data register is used to save the date to exhibit on the LCD. Once we transmit data to LCD,
then it shifts to the data register to process the data. If we fix the register value at one that the data
register will start working.
It is okay if you do not understand the function of all the pins, I will be explaining in detail below. Now,
let us turn back our LCD:
Okay, what is this two black circle like things on the back of our LCD?
These black circles consist of an interface IC and its associated components to help us use this LCD with
the MCU. Because our LCD is a 16*2 Dot matrix LCD and so it will have (16*2=32) 32 characters in
total and each character will be made of 5*8 Pixel Dots. A Single character with all its Pixels enabled is
shown in the below picture.
Interfacing of a 16X2 LCD with Arduino is discussed to display “Hello World!” on the screen. A
library like LiquidCrystal permits you to manage the displays that are well-matched through the
driver like Hitachi HD44780 driver. Here, the following example circuit displays “Hello World!”
on the LCD & displays the time in sec once the Arduino board was reset.
The 16×2 display includes a parallel interface which means that the microcontroller used in this
has to control different interface pins immediately to control the LCD. The interface includes
mainly these pins like RS (Register Select) pin, Read/Write pin, Enable Pin, Data pins from D0 to
D7, display contrast pin, LED backlight pins, power supply pins.
The display controlling process mainly involves placing the data to form the picture of what you
desire to show into the data registers, after that placing instructions within the instruction
The controlling of LCDs compatible with Hitachi can be done using two modes like 4-bit/8-bit.
Here, the 4-bit mode needs 7 I/O pins using the Arduino board, whereas the 8-bit mode needs 11
pins. To display the text on the LCD, the 4-bit mode is used. The following example will explain
how to control an LCD using 4-bit mode.
Text Direction: Control which way text flows from the cursor.
LiquidCrystal()
Description
Creates a variable of type LiquidCrystal. The display can be controlled using 4 or 8
data lines. If the former, omit the pin numbers for d0 to d3 and leave those lines
Syntax
LiquidCrystal (rs, enable, d4, d5, d6, d7)
LiquidCrystal (rs, rw, enable, d4, d5, d6, d7)
LiquidCrystal (rs, enable, d0, d1, d2, d3, d4, d5, d6, d7)
LiquidCrystal (rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7)
Parameters
rs: the number of the Arduino pin that is connected to the RS pin on the LCD
rw: the number of the Arduino pin that is connected to the RW pin on the LCD
(optional)
enable: the number of the Arduino pin that is connected to the enable pin on the LCD
d0, d1, d2, d3, d4, d5, d6, d7: the numbers of the Arduino pins that are connected to the
corresponding data pins on the LCD. d0, d1, d2, and d3 are optional; if omitted, the
LCD will be controlled using only the four data lines (d4, d5, d6, d7).
void setup()
{
lcd.begin(16,1);
lcd.print("hello, world!");
}
void loop() {}
begin()
Description
Initializes the interface to the LCD screen, and specifies the dimensions (width and
height) of the display. begin() needs to be called before any other LCD library
commands.
Syntax
lcd.begin(cols, rows)
Parameters
lcd: a variable of type LiquidCrystal
------------------------------------------------------------------------------------------------------
clear()
Description
Clears the LCD screen and positions the cursor in the upper-left corner.
Syntax
lcd.clear()
Parameters
lcd: a variable of type LiquidCrystal
-------------------------------------------------------------------------------------------------------
home()
Description
Positions the cursor in the upper-left of the LCD. That is, use that location in
outputting subsequent text to the display. To also clear the display, use
the clear() function instead.
Syntax
lcd.home()
Parameters
lcd: a variable of type LiquidCrystal
-------------------------------------------------------------------------------------------------------
setCursor()
Description
Position the LCD cursor; that is, set the location at which subsequent text written to the
LCD will be displayed.
Syntax
lcd.setCursor(col, row)
Parameters
lcd: a variable of type LiquidCrystal
col: the column at which to position the cursor (with 0 being the first column)
row: the row at which to position the cursor (with 0 being the first row)
-------------------------------------------------------------------------------------------------------
write()
Description
Write a character to the LCD.
Syntax
lcd.write(data)
void setup()
{
Serial.begin(9600);
}
void loop()
{
if (Serial.available())
{ lcd.write(Serial.read()
);
}
-------------------------------------------------------------------------------------------------------
print()
Description
Prints text to the LCD.
Syntax
lcd.print(data)
lcd.print(data, BASE)
Parameters
lcd: a variable of type LiquidCrystal
data: the data to print (char, byte, int, long, or string)
BASE (optional): the base in which to print numbers: BIN for binary (base 2), DEC for
decimal (base 10), OCT for octal (base 8), HEX for hexadecimal (base 16).
Returns
byte
print() will return the number of bytes written, though reading that number is optional
Example
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
void setup()
{
lcd.print("hello, world!");
}
Procedure:
6. Construct /assemble circuit of required task.
7. Connect the Arduino board to your computer using the USB cable.
10.Verify / compile code and upload / run the code button to send sketch to the
Arduino.
OBJECTIVE
Implementation of DC motor interface with Arduino.
Implementation of Servo motor interface with Arduino.
Implementation of Stepper motor interface with Arduino.
EQUIPMENT
Arduino
DC motor
Servo motor
Stepper motor
DC MOTOR
THEORY
DC motor has part of many equipment and machinery. We are using 5v DC motor, It is device that can
use in industrial equipment as small device and it also chipper and used in robotics, Quadcopter, and
internet of the things project. DC motor work on the current and voltage needed for the capabilities of
microcontroller but DC moto necessary to use some external device of electronic to drive the and control
the motor and it required individual power supply. There are many ways to drive the DC motor from
their output of device. however, transistor also use full to drive the DC motor and the other way to
control the direction of the motor is L298 drive it is integrated circuit.
How DC motor work
Warning − Do not drive the motor directly from Arduino board pins. This may damage the
board. Use a driver Circuit or an IC.
We will divide this chapter into three parts −
the averages voltage is proportional to the width of the pulses known as Duty Cycle. The higher the duty
cycle, the greater the average voltage being applied to the dc motor (High Speed) and the lower the duty
cycle, the less the average voltage being applied to the dc motor (Low Speed). Below image illustrates
PWM technique with various duty cycles and average voltages.
IN1 & IN2 Motor A input pins. Used to control the spinning direction of
Motor A
IN3 & IN4 Motor B input pins. Used to control the spinning direction of
Motor B
VCC pin supplies power for the motor. It can be anywhere between 5 to
35V. Remember, if the 5V-EN jumper is in place, you need to supply 2 extra
volts than motor’s actual voltage requirement, in order to get maximum
speed out of your motor.
GND is a common ground pin.
5V pin supplies power for the switching logic circuitry inside L298N IC. If
the 5V-EN jumper is in place, this pin acts as an output and can be used to
power up your Arduino. If the 5V-EN jumper is removed, you need to
connect it to the 5V pin on Arduino.
ENA pins are used to control speed of Motor A. Pulling this pin HIGH(Keeping the
jumper in place) will make the Motor A spin, pulling it LOW will make the
Cod
e
The potentiometer provides position feedback to the servo control unit where the
current position of the motor is compared to the target position. According to the
error, the control unit corrects the actual position of the motor so that it matches
the target position.
How Servo Motors Work?
You can control the servo motor by sending a series of pulses to the signal
line. A conventional analog servo motor expects to receive a pulse roughly
every 20 milliseconds (i.e. signal should be 50Hz). The length of the pulse
determines the position of the servo motor.
If the pulse is high for 1ms, then the servo angle will be zero.
The duration of the pulses may sometimes vary with different brands and they
can be 0.5ms for 0 degrees and 2.5ms for 180 degrees.
The color of the wires varies between servo motors, but the red wire is always 5V
and GND will either be black or brown. The control wire is usually orange or
yellow.
Stepper motor
THEORY
A Stepper Motor or a step motor is a brushless, synchronous motor, which divides a full rotation
into a number of steps. Unlike a brushless DC motor, which rotates continuously when a fixed
DC voltage is applied to it, a step motor rotates in discrete step angles.
The Stepper Motors therefore are manufactured with steps per revolution of 12, 24, 72, 144, 180,
and 200, resulting in stepping angles of 30, 15, 5, 2.5, 2, and 1.8 degrees per step. The stepper
motor can be controlled with or without feedback.
imagine a printer. There are lots of moving parts inside a printer, including motors. One such
motor acts as the paper feed, spinning rollers that move the piece of paper as ink is being printed
on it. This motor needs to be able to move the paper an exact distance to be able to print the next
line of text or the next line of an image.
Stepper motor rotates in steps. To understand its principle, consider the logical diagram of its
construction given below. Two winding, A and B are the stator of motor. Permanent magnet
having North and South poles is rotor of the motor. The basic arrangement of stator and rotor in
stepper motor is shown in figure below.
Now, similarly for winding A, if we energise winding A, then the unlike poles will be
attracted and make step as shown in figure below.
Step Angle
Step angle is the minimum angle that stepper motor will cover within one move/step.
Number of steps required to complete one rotation depends upon step angle. E.g. If
step angle is of 45° then 8 steps are required to complete one rotation as shown in
figure below.
Depending upon stepper motor configuration, step angle varies e.g. 0.72°, 1.8°, 3.75°,
7.5°, 15° etc.
Stepper motors are classified depending upon construction and winding arrangement.
Unipolar Stepper Motor has centre tapped winding with 5 (If both centres are
connected
internally) or 6 wires as shown in below figure.
Generally, these centre tapped connections are connected to the power supply.
By providing ground path to the winding leads we can allow the flow of current
through each half of coil which create magnetic poles. By altering poles
sequentially, we can rotate rotor accordingly.
The current is unidirectional in unipolar motor.
Due to centre tap, each winding is divided i.e. current flows through half of
winding.
Due to its centre tap arrangement, we do not need to change current direction to
change magnetic pole on winding. Here we just need to alter ground connection
at winding ends.
A servo motor is a general term used for a specific kind of linear or rotary actuators.
Basically, the name servo motor is related to the term servomechanism, which means that the
motor is constantly monitored to control its motion.
Stepper motors are so named because each pulse of electricity turns the motor one step.
Stepper motors are controlled by a driver, which sends the pulses into the motor causing it to
turn.
1 Coil 1 Orange This Motor has a total of four coils. One end of all the coils are
connect to +5V (red) wire and the other end of each coil is
pulled out as wire colors Orange, Pink, Yellow and Blue
respectively
2 Coil 2 Pink
3 Coil 3 Yellow
4 Coil 4 Blue
5 +5V Red We should supply +5V to this wire, this voltage will appear
across the coil that is grounded.
The board has a connector that mates the motor wires perfectly which makes it
very easy to connect the motor to the board. There are also connections for
four control inputs as well as power supply connections.
The board has four LEDs that show activity on the four control input lines (to
indicate stepping state). They provide a nice visual when stepping.
The board also comes with an ON/OFF jumper to isolate power to the stepper
Motor.
Procedure:
PIN Connection
Table: Fill table according
to your Sr. No LM298 N Module Arduino PIN connection
diagram 1 VCC VCC
2 GND GND
3 5v 9
4 ENA 8
5 IN1 7
6 IN2 6
7 IN3 5
8 IN4 4
9 ENB 3
10 OUT1 VCC MOTOR 1 VCC
11 OUT 1 GND MOTOR 1 GND
12 OUT 2 VCC MOTOR 2 VCC
13 OUT GND 2 MOTOR 2 GND
PIN Connection
Table: Fill table Sr. Servo Motor Arduino PIN according to your
connection No diagram
1 VCC VCC
2 GND GND
3 Data 4
CONCLUSION:
In this experiment we learn about motor speed control with the help of some modules interfacing with
OBJECTIVE:
Implementation of Temperature sensor / module interface with Arduino display result on serial monitor.
Implementation of Temperature sensor / module interface with Arduino display result on LCD.
EQUIPMENT:
Arduino
Temperature Sensor Module
Connecting Leads
THEORY:
In this Arduino Experiment we will learn how to use the DHT11 or the DHT22 sensor for measuring temperature
and humidity with the Arduino board. Ok now let’s see how these sensors actually work. They consist of a
humidity sensing component, a NTC temperature sensor (or thermistor) and an IC on the back side of the
sensor.
DHT11 is a low-cost, small-sized & easy-to-operate embedded sensor, consists of 4 pins, used
to measure Temperature(0°C to 50°C with ±2°C accuracy) & Relative Humidity(20% to 80% with
±5% accuracy) and provides calibrated digital output.
DHT11 has a Capacitive Sensor for measuring humidity & NTC Thermistor for
temperature sensing. (We will cover them in detail below)
2. 8-Bit Humidity(Decimal)
3. 8-Bit Temperature(Integral)
4. 8-Bit Temperature(Decimal)
5. 8-Bit Checksum
If DHT11 is sending the correct data, then it must send an 8-Bit Checksum data at the
end.
Applications
Because of its small size, low cost and ability to sense two values, DHT11 has a wide range of
applications:
DHT11 is used in Home Automation Projects to maintain constant atmospheric values by
controlling the appliances(i.e. AC, Fan etc.) based on the sensor’s readings.
It is also used at weather stations for temperature & humidity sensing.
It is also used in automatic climate control appliances.
Environment monitoring devices also utilize this sensor.
Garden Monitoring Systems also use DHT11 sensors.
Pin layout:
DHT11
DHT22
Sensor DHT11 LM35 DS18B20
(AM2302)
Temperature Temperature
Measures Temperature Temperature
Humidity Humidity
Supply
3 to 5.5V DC 3 to 6V DC 4 to 30 V DC 3 to 5.5V DC
voltage
Temperature
0 to 50ºC -40 to 80ºC -55 to 150ºC -55 to 125ºC
range
+/- 2ºC (at 0 to +/- 0.5ºC (at -40 +/-0.5ºC (at +/-0.5ºC (at -10 to
Accuracy
50ºC) to 80ºC) 25ºC) 85ºC)
Coding:
#include "DHT.h"
#define DHTPIN 2 // Digital pin connected to the DHT sensor
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
DHT dht(DHTPIN, DHTTYPE);
void setup()
{ Serial.begin(9600
); dht.begin();}
void loop() { delay(200);
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
float hif = dht.computeHeatIndex(f, h);
float hic = dht.computeHeatIndex(t, h, false);
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.println(t);
}DHT Library:
In this experiment we learn that add library of DHT11, DHT22 temperature sensor in Arduino and proteus. Coding
in Arduino and create circuit in proteus. Add HEX file in proteus and check the value.
Group No. 07
Student Roll No. 8034 8035 8036 8037
C P Domain +
No. L Taxonomy Criteria Awarded Score (out of 4 for each cell)
L O
O
Conduct experiments in
laboratory in order to
interpret experimental data
1 A2 and displays its conformance
with analyzed results of
circuits.
-
- - - - -
Total
Operating Voltage DC 5V
Max Range 4m
Dimension 45 x 20 x 15mm
If those pulses are reflected back the Echo pin goes low as soon as the signal is received. This
produces a pulse whose width varies between 150 µS to 25 mS, depending upon the time it took for
the signal to be received.
Transmission
Reception
Group No. 07
Student Roll No. 8034 8035 8036 8037
C P Domain +
No. L Taxonomy Criteria Awarded Score (out of 4 for each cell)
L O
O
Conduct experiments in
laboratory in order to
interpret experimental data
1 A2 and displays its conformance
with analyzed results of
circuits.
-
- - - - -
Total
OBJECTIVE:
To get familiar with Interfacing Infrared Sensor with Arduino
EQUIPMENT:
Arduino
Infrared Sensor
LED
LCD
Connection Wires.
PINOUT:
1. VCC: 3.3V-5V power input pin
2. GND: 0V power pin
3. OUT: Digital Output Pin
TECHNICAL SPECIFICATION/RATING
Operating Voltage: 3.0V – 6.0V
Current: at 3.3V : ~23 mA & at 5.0V: ~43 mA
CONNECTION DIAGRAM
void setup()
pinMode (IRSensor, INPUT); //initialize the infrared sensor sensor pin as an input:
void loop()
int sensorState = digitalRead (IRSensor); //read the state of the infrared sensor sensor value:
if (sensorState == HIGH) //If the infrared sensor does not detect any object or obstacle, then
sensorState is HIGH:
else //If the infrared sensor detects any object or obstacle, then sensorState state is HIGH:
PROCEDURE:
The connections for the IR sensor with the Arduino are as follows: Connect the Ground wire on
the IR sensor to GND. Connect the middle of the IR sensor which is the VCC to 5V on the
Arduino. Connect the signal pin on the IR sensor to pin 2 on the Arduino.
CONCLUSION:
In this experiment we learn about inferred sensor its Arduino coding and circuit in proteus. First we copy Hex file, paste in
proteus and run the circuit. When we trigger test pin 1 the led will on
.
Interfacing infrared sensor with Arduino (open
Activity Name
ended lab)
Group No. 7
Student Roll No. 8034 8035 8036 8037
C P Domain +
No. L Taxonomy Criteria Awarded Score (out of 4 for each cell)
L O
O
Able to follow the
procedure
according to
the given
1 4 5 P2 task
and
reproduce
the results
with some
parametric
changes in
the
provided task.
Total
OBJECTIVE:
To get familiar with Interfacing of DC & AC Voltage sensor / module with Arduino.
To get familiar with Interfacing of DC & AC Current sensor / module with Arduino.
EQUIPMENT:
Arduino
DC Voltage Sensor, DC Current Sensor
AC Voltage Sensor, AC Current Sensor
Connection Wires.
THEORY:
DC Voltage Sensor
Measuring DC Voltage with a microcontroller (or any digital data device) requires the use of an Analog to Digital
Converter (ADC). Many modern microcontrollers, including the Arduino Uno, have a built-in ADC, making DC
voltage measurement the simplest of our four tasks.
Analog to Digital Converters
It’s a component that accepts an analog input and produces a digital output, the output being a digital
representation of the level of the input.
Voltage Dividers
The maximum input voltage that you can feed into an Arduino Uno ADC is 5-volts, with microcontrollers using
3.3-volt logic it is even less. Obviously, this is a bit impractical, as you’ll probably want to measure input
voltages exceeding that.
Circuit Diagram
First, connect the “S” and “–” pins of the Voltage Sensor to A0 (Analog Input) and GND of Arduino respectively.
Then connect the external voltage pins (voltage to be measured) to the screw terminal (check for polarity).
Working
Since the Voltage Sensor module is basically a voltage divider circuit, you can calculate input voltage using the
formula
Vin = Vout * (R2/(R1+R2))
Here R1 = 30000, R2 = 7500 and Vout can be calculated from Analog Input of Arduino by using
Vout = (analogvalue * 5 / 1024).
IC OF ACS712
There are three variants of ACS712 Sensor based on the range of its current sensing. The optimized ranges are
+/-5A, +/-20A and +/-30A. depending on the variant, the output sensitivity also varies as follows:
ACS712 Model Optimized Current Range Output Sensitivity
ACS712 ELC-05 +/- 5A 185 mV/A
ACS712 ELC-20 +/- 20A 100 mV/A
ACS712 ELC-30 +/- 30A 66 mV/A
WORKING:
As mentioned earlier, the ASC712 is based on Hall Effect. There is a copper strip connecting the IP+ and IP- pins
internally. When some current flows through this copper conductor, a magnetic field is generated which is
sensed by the Hall Effect sensor.
Circuit diagram
Circuit Diagram of ASC712 Current Sensor with Arduino
In this experiment we learn about the current and voltage measurement with current and voltage sensor
interfacing with Arduino.
Total
OBJECTIVE:
Implementation of interfacing of Bluetooth module with Arduino.
EQUIPMENT:
Arduino
Bluetooth module (HC-05)
Connection Wires.
Android Application
THEORY:
HC-05 Bluetooth Module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for
transparent wireless serial connection setup. Its communication is via serial communication which makes an
easy way to interface with controller or PC , Mobile.
HC-05 is a Bluetooth module which can communicate in two way. Which means, It is full-duplex. We can
use it with most micro controllers. Because it operates Serial Port Protocol (SSP). The module communicate with
the help of USART (Universal Synchronous/Asynchronous Receiver/Transmitter ) at the baud rate of 9600. and it
also support other baud rate. So we can interface this module with any microcontroller which supports USART.
The HC-05 can operate in two modes. One is Data mode and other is AT command mode. When the enable pin
is "LOW" the HC-05 is in Data Mode. If that pin set as "HIGH" the module is in AT command mode. Here we
operate this module in Data Mode.
Bluetooth protocol; an affordable communication method in PAN network, with a maximum data rate of 1Mb/S,
working in a nominal range of 100 meters using 2.4 G frequency is a common way of wireless communicating.
HC05 module is a Bluetooth module using serial communication, mostly used in electronics projects.
HC05 module has an internal 3.3v regulator and that is why you can connect it to 5v voltage. But we strongly
recommend 3.3V voltage, since the logic of HC05 serial communication pins is 3.3V. Supplying 5V to the module
can cause damage to the module. In order to prevent the module from damages and make it work properly, you
should use a resistance division circuit (5v to 3.3v ) between arduino TX pin and module RX pin. When master
and slave are connected, blue and red
LEDs on the board blink every 2seconds. If they aren’t connected, only blue one blinks every 2 seconds.
Specification:
Model: HC-05,
Architecture of these modules is based on the Cambridge Silicon Radio BC417,
2.4 GHz Bluetooth Radio chip,
+4dBm RF Transmit Power,
48-bit unique device address (BD_ADDR),
Chip uses an external 8 MB flash memory
2Mb speed
Communication Method: Serial Communication
Operating Voltage: 4V to 6V (Typically +5V)
Operating Current: 30mA
PINOUT
1. VCC: The operating voltage range is 3.3 volts. But I/O pins can withstand voltage of up to 5
volts. Therefore, we can connect 5 volts power source to this pin, and also other pins can also
operate on 5 volts signals such as Tx and Rx signals.
2. GND: Ground reference of both ESP8266 and HC-05 should be at the same level. Therefore,
we should connect a power supply, HC05, and ESP8266 ground pins to each other.
3. Tx: As discussed earlier, the HC-05 Bluetooth module uses UART communication to
transmit data. This is a transmitter pin. The TX pin will be the data transfer pin of
the module in UART.
Code
#define
: ledPin 13
int state = 0;
void setup()
{
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
Serial.begin(9600);}
Android App:
After upload code in Arduino Download this mobile application from play store.
Using The Kodular App To Control Arduino Once you have successfully paired your Android
device to the bluetooth module it’s now time to open the app. Click the bluetooth icon and
select your bluetooth module which should be displayed in the list.
So the RX pin of the Arduino needs to be connected to the RX pin of the Bluetooth module, through the voltage
divider, and the TX pin of the Arduino to the TX pin of the Bluetooth module. Now while holding the small
button over the “EN” pin we need to power the module and that’s how we will enter the command mode. If the
Slave Configuration
So for example, if we type just “AT” which is a test
command we should get back the message “OK”.
Then if we type “AT+UART?” we should get back the
massage that shows the default baud rate which is 38400.
Then if we
type “AT+ROLE?” we will get back a massage
“+ROLE=0” which means that the Bluetooth device is in
slave mode. If we type “AT+ADDR?” we will get back
the address of the Bluetooth module and it should look
something like
this: 98d3:34:905d3f.
Now we need to write down this address as we will need it when configuring the master device.
Actually that’s all we need when configuring the slave device, to get its address, although we can change
many different parameters like its name, baud rate, pairing password and so on, but we won’t do that
for this example.
Master Configuration
Ok now let’s move on and configure the other Bluetooth module as a master device. First we will check
the baud rate to make sure it’s the same 38400 as the slave device. Then by typing “AT+ROLE=1” we will set
the Bluetooth module as a master device. After this using the “AT+CMODE=0” we will set the connect mode
to “fixed address” and using the “AT+BIND=” command we will set the address of the slave device that we
previously wrote down.
void setup()
{
Serial.begin(9600);
Serial.println("Enter AT commands:");
BTSerial.begin(38400);// HC-05 default speed in AT command more
}
void loop()
{
if (BTSerial.available()) // read from HC-05 and send to Arduino Serial Monitor
Serial.write(BTSerial.read());
if (Serial.available()) // Keep reading from Arduino Serial Monitor and send to HC-05
BTSerial.write(Serial.read());
}
Changing Codes:
Open the serial monitor. Be sure that the baud rate are set to 9600 and Both NL & CR are selected.
If you send AT from serial monitor, OK will appear on the screen. Now you can change the name or password of
the module, check address, version
PROCEDURE:
1. Construct /assemble circuit of required task.
2. Connect the Arduino board to your computer using the USB cable.
3. Select the board and serial port as outlined in earlier section.
4. Write code of required task.
5. Verify / compile code and upload / run the code button to send sketch to the
Arduino.
6. Check the result of the required Task.
7. Save the result and attached with Report.
2 RX TX PIN(1)
3 GROUND
4 5V(SUPPLY)
5 EN
6 STATE
Group No. 7
Student Roll No. 8034 8035 8036 8037
C P Domain +
No. L Taxonomy Criteria Awarded Score (out of 4 for each cell)
L O
O
Able to follow the
procedure
according to
the given
1 4 5 P2 task
and
reproduce
the results
with some
parametric
changes in
the
provided task.
Total