0% found this document useful (0 votes)
15 views

Microcontroller & Applications- Mod IV-2023

The document discusses the interfacing of various I/O devices with the 8051 microcontroller, including stepper motors, DC motors, matrix keypads, and ADCs. It outlines the operation and interfacing methods for each device, detailing the necessary connections and programming procedures. Additionally, it emphasizes the importance of interfacing in microcontroller applications for data input and output management.

Uploaded by

amal0072k5
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)
15 views

Microcontroller & Applications- Mod IV-2023

The document discusses the interfacing of various I/O devices with the 8051 microcontroller, including stepper motors, DC motors, matrix keypads, and ADCs. It outlines the operation and interfacing methods for each device, detailing the necessary connections and programming procedures. Additionally, it emphasizes the importance of interfacing in microcontroller applications for data input and output management.

Uploaded by

amal0072k5
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/ 63

Uniyt IV

INTERFACING OF VARIOUS
I/O DEVICES WITH 8051

Baiju.G.S
Lecturer in Electronics Eng
• CO4 : Illustrate the interfacing of various I/O
devices with 8051
• M4.01 : Explain the interfacing of stepper motor with
8051.
• M4.02 : Explain the interfacing of DC motor for
speed control.
• M4.03 : Illustrate the interfacing of 4x4 keyboard
and 16x2 LCD system with 8051.
• M4.04 : Illustrate ADC, DAC and LM35 temperature
sensor interfacing with 8051.

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Contents:
• Stepper motor – operation, explain the interfacing with
8051
• DC motor – operation, explain the interfacing with 8051
• 4x4 -Matrix keyboard – Structure, identifying key press,
explain the interfacing with 8051. 16x2 LCD - Pin
description, advantages of LCD, explain the interfacing with
8051.
• Explain the interfacing of 8051 - with ADC, with DAC, with
temperature control system using LM35 temperature
sensor.

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Interfacing
• Interfacing is the process of connecting devices
together so that they can exchange the
information and that proves to be easier to write
the programs. There are different type of input
and output devices such as LEDs, LCDs,
7segment, keypad, motors etc

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Interface device
• An interface device (IDF) is a hardware
component or system of components that allows
a human being to interact with a computer /
microcontroller or other electronic information
system.

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Interfacing of 8051
• Interfacing is one of the important concepts
in microcontroller 8051 because the
microcontroller is a CPU that can perform some
operation on a data and gives the output.
However to perform the operation we need an
input device to enter the data and in turn output
device displays the results of the operation. In a
microcontroller trainer kit we are using keyboard
and LCD display as input and output devices
along with the microcontroller.
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Stepper motors
• Stepper motors are type of DC motor.
• stepper motor is a brushless, synchronous
electric motor that converts digital pulses into
mechanical shaft rotation. Every revolution of
the stepper motor is divided into a discrete
number of steps, and the motor must be sent a
separate pulse for each step.

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
• Stepper motor has multiple electromagnetic coils
that are arranged in group called
phases. Motor rotates when particular phase is
energized. One step rotation occurs at a time by
energizing a particular coil.

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
STEPPER MOTOR

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
8051

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Stepper motor Interfacing
• he circuit diagram for interfacing stepper motor to
8051 is shown above. P1.0, P1.1, P1.2 and P1.3
pins are used for controlling the phases A1, A2,
A3 and A4 of the stepper motor
respectively. ULN2003 is used for driving the
individual phases of the stepper motor. ULN2003
is a darlington transistor array used for driving
high current loads such as relays and motors

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
• . ULN2003 has 8 individual channels each with
1A capacity. The channels can be paralleled to
increase the current capacity. Each channels are
fitted with individual freewheeling diodes. The
ULN2003 is operated in current sinking mode.
Each channel is activated by giving a logic LOW
at the corresponding input. For example if we
make pin 1 of ULN2003 LOW, phase A1 of the
stepper motor gets switched ON.
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
STEPPER MOTOR CONTROL

A1 A2 A3 A4
1 1 0 0
0 1 1 0
0 0 1 1
1 0 0 1
1 1 0 0
0 1 1 0
0 0 1 1
1 0 0 1
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
A1 A2 A3 A4

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
A1 A2 A3 A4

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Lab : Procedure for Stepper motor
Interfacing
• Use the P1 port of Microcontroller, in the VI Microsystem
kit for interfacing
• The pin P.0 to P.3 of the interfacing port were connected
to Stepper motor
• Write program to giving supply to the port pins connected
to four Stator motors alternatively
• Ie 0000 1001 -09H
• 0000 0101 -05H
• 0000 0110 -06 H
• 0000 1010 – 0A H
• Execute the program
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
ALP : Stepper Motor Interfacing
• ORG 4100H
• L0OP: MOV P1,#09H
• ACALL DELAY
• MOV P1,#05H
• ACALL DELAY
MOV P1,#06H
• ACALL DELAY
• MOV P1,#0AH
• ACALL DELAY
• SJMP LOOP
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
• DELAY: MOV R1,#FFH
• YY1: MOV R2,# FFH
• XX1: DJNZ R2,XXI
• DJNZ R1,YY1
• RET

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Interfacing 8051 with DC
Motor

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
DC motor
• A DC motor is any of a class of rotary electrical
machines that converts direct current electrical
energy into mechanical energy.
• In the case of the motor, the mechanical energy
produced is in the form of a rotational movement
of the motor shaft.
• The direction of rotation of the shaft of the motor
can be reversed by reversing the direction of
Direct Current through the motor.
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
• The motor can be rotated at a certain speed by
applying a fixed voltage to it. If the voltage varies, the
speed of the motor varies.
• Thus, the DC motor speed can be controlled by
applying varying DC voltage; whereas the direction of
rotation of the motor can be changed by reversing the
direction of current through it.
• For applying varying voltage, we can make use of the
PWM technique.

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
For reversing the current, we can make use of an H-Bridge circuit or
motor driver ICs that employ the H-Bridge technique or any other
mechanisms.

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
DC Motor interfacing
• Let's interface the DC motor with the 8051
microcontroller and control the DC motor speed
by using the Speed Increment Switch and Speed
Decrement Switch connected to the
Microcontroller port and direction by using
Direction Switch.
• IC L293D is used for interfacing 8051 with DC
motor as shown in the block diagram.

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
• IC L293D is designed to provide bidirectional
drive currents of up to 600mA at voltages from
4.5V to 36V. It can drive inductive loads such as
solenoids, relays, DC and bipolar stepping
motors. It contains internally protection diodes
across the motor.

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
DC Motor interfacing

8051

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Speed control
The main purpose of DC interfacing with 8051
microcontroller is for controlling the speed of the
motor
The two input buttons can be used to control the output
PWM generated by the microcontroller. This output
signal is then fed to DC Motor through motor driver.
Thus, the speed of DC motor can be controlled

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Lab : Procedure DC motor Interfacing
• Use the P1 port of Microcontroller, in the VI Microsystem
kit for interfacing
• The pin P.4 and P.5 of the interfacing port were
connected to DC motor
• Write program to giving supply to the pins of DC motor
• For clockwise rotation
0010 0000 -20H
• For Anticlockwise rotation
0001 0000 -10H
• Execute the program

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
ALP : DC Motor Interfacing
• CLOCKWISE ROTATION

• START : ORG 4100H


MOV P1, #20H
SJMP START

• ANTICLOCKWISE ROTATION

• START : ORG 4100H


MOV P1, #10H
SJMP START
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Interfacing 8051 with Key
board

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Matrix Keypad
• A Matrix keypad is the most commonly used
input device in many of the application areas like
digital circuits, telephone communications,
calculators, ATMs, and so on. A matrix
keypad consists of a set of push button or
switches which are arranged in a matrix format of
rows and columns

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
• This 4x4 matrix keypad has 16 built-in
pushbutton contacts connected to row and
column lines. A microcontroller can scan these
lines for a button-pressed state. In
the keypad library, the Propeller sets all the
column lines to input, and all the row lines to
output

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
4x4 matrix keypad

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Keyboard Interfacing
• In computing, a keyboard controller is a device
that interfaces a keyboard to a computer. Its
main function is to inform the computer when a
key is pressed or released. When data from
the keyboard arrives, the controller raises an
interrupt (akeyboard interrupt) to allow the CPU
to handle the input.

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
How to get the location of the pressed button?

1. First we have made all the Rows to Logic level 0 and all the columns
to Logic level 1.
2. Whenever we press a button, column and row corresponding to that
button gets shorted and makes the corresponding column to logic level
0. Because that column becomes connected (shorted) to the row, which
is at Logic level 0. So we get the column no.
3. Now we need to find the Row no., so we have created four functions
corresponding to each column. Like if any button of column one is
pressed, we call a function to find the row no.

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
4. In row_finder function, we reversed the logic levels, means now all
the Rows are 1 and columns are 0. Now Row of the pressed button
should be 0 because it has become connected (shorted) to the column
whose button is pressed, and all the columns are at 0 logic. So we have
scanned all rows for 0.
5. So whenever we find the Row at logic 0, means that is the row of
pressed button. So now we have column no (got in step 2) and row no
(got in step 4)., and we can print no. of that button using lcd_data
function.

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Interfacing 8051 with
ADC

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Analog to Digital Converter
• Digital computers use binary values
• In the physical world everything is Analog
• Physical quantity is converted in to Electrical
signals using a device called transducers /
Sensors
• ADC convert this electrical signal in to Digital. The
resolution of ADC may be 8/ 12 / 16 or 24
• Higher resolution smaller step size
• Both Parallel and serial ADCs
• In microcontrollers

Technology beyond the Dreams Copyright © 2006 Pantech Solutions Pvt Ltd.
• In Microcontroller interfacing frequently used Ics
are 0804 and 0808
• ADC0804 is a very commonly used 8-bit analog to
digital convertor. It is a single channel IC, i.e., it
can take only one analog signal as input.
• ADC0808 is an 8 bit analog to digital converter
with eight input analog channels, i.e., it can take
eight different analog inputs. The input which is to
be converted to digital form can be selected by
using three address lines.

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Analog to Digital convertor

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
ADC0804 Pin Configuration

Pin Pin Name Description


Number

1 Chip Select (CS) Chip select is used if more than 1 ADC module is used. By default
grounded

2 Read (RD) Read pin must be grounded to read the Analog value

3 Write (WR) Write pin should be pulsed high to start data conversion

4 CLK IN External clock can be connected here, else RC can be used for
accessing internal clock

5 Interrupt (INTR) Goes high for interrupt request.

6 Vin (+) Differential Analog input +. Connect to ADC input

7 Vin (-) Differential Analog input -. Connect to ground

8 Ground Analog Ground pin connected to ground of circuit

9 Vref/2 Reference voltage for ADC conversion.

10 Ground Digital Ground pin connected to ground of circuit

11 to 18 Data bit 0 to bit 7 Seven output Data bit pins from which output is obtained

19 CLK R RC timing resistor input pin for internal clock gen

20 Vcc Powers the ADC module, use +5V

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
ADC Interfacing

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
steps
• Make CS=0 and send a low to high pulse to WR
pin to start the conversion.
• Now keep checking the INTR pin. INTR will be 1
if conversion is not finished and INTR will be 0 if
conversion is finished.
• If conversion is not finished (INTR=1) , poll until it
is finished.
• If conversion is finished (INTR=0), go to the next
step.
• Make CS=0 and send a high to low pulse to RD pin
to read the data from the ADC.
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Interfacing 8051 with
DAC

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
DAC Interfacing

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Interfacing 8051 with
Temperature Sensor

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Sensors
• Transducers converts the physical data such as
temperature, high intensity, flow and speed to
Electrical signals
• Depending upon the transducer the output
produced may be voltage, current, resistance or
capacitance
• Eg : Thermisor – temperature sensor – resistance
– not linear

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Temperature sensors
• LM 34 and LM 35 are Precision integrated
temperature sensors
• LM 34 – Output voltage is proportional to
Fahrenheit temperature
• LM 35 – Output voltage is proportional to Celsuis
( Centigrade ) temperature

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Temperature Sensor (LM35)

• LM35 looks like a transistor it will give you


temperature in Celsius in terms of millivolt. For
example if the temperature is 25 C its output will
give you 0.25V provided that you must supply at
least 1V to it

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Signal conditioning
• Transducer output – Voltage / current / resistance
or capacitance
• ADC requires voltage as input
• Signal conditioner covert ( modify) the transducer
output for ADC

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Measuring Temperature
with LM35 using 8051

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Thank you

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.

You might also like