Hardware Interfacing

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 65

Power supply

The microcontroller operating voltage is +5V DC.

The following components are used to construct the power supply circuit.
Description:

 230V AC supply is given to the step down transformer .

 The output of the step down transformer is given to bridge rectifier.

 The bridge rectifier is formed with diodes. The bridge rectifier converts the AC
voltage into DC voltage.

 But the output DC Voltage contains some AC component (ripples).


So we use capacitors as a filter for removing ripples.

 The output DC Voltage is given to the positive voltage regulator LM7805 .


So the output of the regulator will be the regulated +5V DC.

 To indicate the condition of the circuit we place LED at the end of the circuit.
Introduction
The most commonly used Character based LCDs are based on Hitachi's
HD44780 controller .

Pin Description

The most commonly used LCDs available in the market today are single
Line, double Line or four Line LCDs and support at most of 80 characters.

Most LCDs with one controller has 14 Pins and LCDs with two controller
has 16 Pins (two pins are extra in both for back-light LED connections).
LCD Pin Diagram
Pin description of 16*2 LCD is shown in the table below.
4-bit Mode

8-bit Mode
LCD Connection
The LCD requires three control lines (RS, R/W & EN) & 8 (or 4) data lines.

 The number of data lines depends on the mode of operation.

 If operated in 8-bit mode then 8 data lines plus 3 control lines .


i.e. total 11 port pins are required.

 In case of 4-bit mode only 4 data lines are required & the 8-bit data is
sent by first sending the higher nibble followed by the lower nibble.

The three control lines are RS, RW & Enable.

RS: Register Select


When RS = 0 The command register is selected.
When RS=1 The data register is selected.

RW: Read or Write


When RW=0 Write to LCD.
When RW=1 Read from LCD.

Enable:
Used to Latch data into the LCD.
A H-L pulse latches the data into the LCD.
Display Data RAM (DDRAM) stores the display data.

So when we have to display a character on LCD we basically write it


into DDRAM.

For a 2x16 LCD the DDRAM address for first line is from 0x80H to
0x8FH & for second line is 0xC0H to 0xCFH.

For example, if we want to display ‘A' on the 7th position of the first
line then we will write it at location 86h.
LED

• Above fig. shows how to interface the LED to microcontroller.

• As you can see the Anode is connected through a resistor to Vcc & the
Cathode is connected to the Microcontroller pin.

• So we need to provide active low signal from microcontroller in order to


glow the LED.

• So when the Port Pin is HIGH the LED is OFF & when the Port Pin is LOW
the LED is turned ON.
Seven Segment Display
Multiple Seven Segment Displays

In order to interface multiple seven segments we use Scanning Principle


where One seven segment is displayed after another but this process is
very fast hence the flickering cannot be seen by human eyes.

Figure shows the circuit for interfacing two seven segment displays.
RELAY

Relay is basically electro-magnetic switch with a wire coil, surrounded by an iron


core. It makes proper switching based on the coil supply provided to it . It is
useful to control high power loads.
Relay

Figure shows the basic relay driver circuit.

As you can see an NPN transistor BC547 is being used to control the relay.

The transistor is turned ON when a LOGIC high is written on the PORT PIN
thus turning ON the relay.
Likewise, the relay gets turned OFF by writing LOGIC Low on the port
pin.

A diode is connected across the relay coil; this is done so as to protect


the transistor from damage due to the BACK EMF generated in the
relay's inductive coil when the transistor is turned OFF.

This diode is also called as free-wheeling diode.


Current Driver ULN2803

If you want to connect more relays to microcontroller


then you can use ULN 2003 for connecting seven
relays or ULN 2803 for connecting eight relays.

Figure shows how to connect a relay to


microcontroller using ULN 2003/ULN 2803.

These IC’s are high voltage, high current Darlington


transistor arrays with free-wheeling diodes .

We can use the same IC for interfacing stepper


motor .
ULN2003 CURRENT DRIVER

ULN2003 is a high voltage and high current


Darlington array IC. It contains seven open
collector darlington pairs with common
emitters. A darlington pair is an arrangement
of two bipolar transistors.

Each channel or darlington pair in ULN2003 is


rated at 500mA and can withstand peak
current of 600mA
OptoCoupler ICs
Opto coupler IC’s are used in automation to provide
optical isolation .

Because microcontroller works on 5V and other


devices(Stepper Motor , DC Motor,Relay) works on
greater voltage.

Any spikes of greater than 5V can burn


microcontroller.
TRIAC
Switch

In above figure when the switch is not pressed , controller gets LOGIC High
through pull up resistor.

 When we press switch ,controller pin gets LOGIC Low pulse.


Keypad
In interfacing switches to microcontroller, one end of switch is connected
to the port pin whereas the other end is connected to the Ground.

So normally the port pin is high but when a switch is pressed the
controller pin gets a Low signal and we come to know that a switch has
been pressed

 In case of matrix Keypad both the ends of switches are connected to


the port Pins.

 Over here we have considered a 4x3 matrix keypad i.e. four rows and
three columns.

 So in all twelve switches have been interfaced using just seven lines.
In keypad interfacing, every number is assigned two unique parameters, i.e.,
row and column number . Hence when a key is pressed the number is identified
by detecting the row and column number of the key pressed.

Initially all the rows are set to zero by the controller and the columns are
scanned to check if any key is pressed. In case no key is pressed the output
of all the columns will be high.
Whenever a key is pressed the row and column corresponding to the key will get
shorted, resulting in the output of the corresponding column goes low. This gives
the column number of the pressed key.
Once the column number is detected, the controller set’s all the rows to high. Now
one by one each row is set to zero by controller. The row corresponding to which
the column gets zero is the row number of the digit.
The above process is very fast and even if the switch is pressed for a very small
duration of time the controller can detect the key which is pressed.
DC Motor

In this part of tutorial we will learn to interface a DC motor


with a microcontroller.

Usually H-bridge is preferred way of interfacing a DC


motor.

These days many IC manufacturers have H-bridge motor


drivers available in the market like L293D is mostly used H-
Bridge driver IC.
DC Motor

In this part of tutorial we will learn to interface a DC motor


with a microcontroller.

Usually H-bridge is preferred way of interfacing a DC


motor.

These days many IC manufacturers have H-bridge motor


drivers available in the market like L293D is mostly used H-
Bridge driver IC.
Theory of H-Bridge
The name "H-Bridge" is derived from the actual shape of the switching circuit
which controls the motion of the motor.

Basically there are four switching elements in the H-Bridge as shown in the
figure below.

These are constructed with transistors or MOSFETs.


L293D Dual H-Bridge Motor Driver
• L293D is a dual H-Bridge motor driver, So with one IC we can interface two DC
motors which can be controlled in both clockwise and counter clockwise direction

• L293D has output current of 600mA and peak output current of 1.2A per
channel.

• Moreover for protection of circuit from back EMF output diodes are included
within the IC.

• The output supply (VCC2) has a wide range from 4.5V to 36V, which has made
L293D a best choice for DC motor driver.
A simple schematic for interfacing a DC motor using L293D is shown below.
Basic Principle of PWM
Pulse-width Modulation is achieved with the help of a square wave whose duty
cycle is changed to get a varying voltage output as a result of average value of
waveform.
A mathematical explanation of this is given below.
Waveform
INTERNAL STRUCTURE OF STEPPER MOTOR

Stepper motor converts electrical pulses into specific rotational


movements.

Hence ,Torque is generated by alternately magnetizing the stator


teeth electrically, and permanent magnet rotor teeth try to align up
with stator teeth.

ROTOR
(permanent magnet)

STATOR
(carry coil for current Flow)
Servo Motor is lightweight with high output torque. Servo can rotate
approximately 180 degrees. It works by applying pulse to it’s data pin.
ADC
 In lot of embedded systems microcontrollers needs to take
digital input.

 Most of the sensors & transducers such as temperature,


humidity, pressure, light, are analog.

 For interfacing these sensors to microcontrollers we require to


convert the analog output of these sensors to digital so that the
controller can read it.

 Some microcontrollers have built in Analog to Digital Convertor


(ADC) so there is no need of external ADC.

 For microcontrollers that don’t have internal ADC external ADC


is used.

One of the most commonly used ADC is ADC0808.

ADC 0808 is a Successive approximation type with 8 channels


i.e. it can directly access 8 single ended analog signals.
Getting Data from Analog World
Sensors
Sensors are the devices capable of converting the
physical data such as temperature, light Intensity and
pressure into the corresponding voltage.
TEMPERATURE SENSORS:

Temperature Sensors are the devices whose output


voltage is proportional to input temperature. In such
sensors for each degree change the output voltage
changes by 10mv.

Fig shows LM35 temperature Sensor.


LIGHT SENSOR
Light Dependent Resistor (LDR) also known as photoconductor or
photocell,

It is a device which has a resistance which varies according to the amount of


light falling on its surface. Since LDR is extremely sensitive in visible light
range, it is well suited for the proposed application.

When light falls on LDR surface , its resistance becomes low


whereas when there is no light on it, its resistance is high.
.
Humidity Sensor
Humidity measurement determines the amount of water
content present in air. It basically senses the moisture
level in an environment.

Resistive type humidity sensors pick up changes in the


resistance value of the sensor element in response to the
change in the humidity.
Soil Moisture Sensor
This soil moisture sensor can be used to detect the
moisture of soil ie. water content around the sensor, by
measuring the analog voltage from sensor. We need to
insert copper sensor probes in soil.
This sensor has a high sensitivity and fast response time. The
sensor's output is an analog voltage. The analog gas sensor -
MQ2 is used in gas leakage detecting equipments in
consumer and industry markets, this sensor is suitable for
detecting LPG, i-butane, propane, methane ,alcohol,
Hydrogen, smoke
The ultrasonic sensor is used to monitor distance of an obstalce
from it. It can detect distance upto 4 meters. It has four pins VCC,
GND, Trig and Echo
Real Time Clock (RTC)
DS1307 is a Real Time Clock IC which uses I2C protocol to communicate with
microcontroller.

This module has 3V CMOS battery for bakup so that it retains time and date even in
case of power failure.
LM358 Based Voltage Comparator
Micro controller AT89S52

 8K Bytes of In-System Programmable (ISP) Flash

Memory.

 4.0V to 5.5V Operating Range.

Crystal Frequency 11.0592MHZ.

256 x 8-bit Internal RAM.

 32 Programmable I/O Lines.

 Three 16-bit Timer/Counters.

AT89S52
Block Diagram of Microcontroller
External interrupts
On-chip Timer/Counter

Interrupt ROM for


program On-chip Timer 1 Counter
Control RAM Inputs
code Timer 0

CPU

Bus Serial
4 I/O
OSC Control Port
Ports

P0 P1 P2 P3 TxD RxD
Address/Data
Pin Diagram of AT89S52 Micontroller
IR SENSOR MODULE
Bluetooth is a wireless technology standard
for exchanging data over short distances
(using short-wavelength UHF radio waves in
the ISM band from 2.4 to 2.485 GHz)
HC-05 Module has GND, VCC, TXD, RXD.
We can use WI-FI Module for more range and faster data
transfer rate. Generally ESP-01 wi-fi module is popular.
Xbee Module

• Upto 250 kbps data rate


• Range 100 ft (30m) in door / 300 ft
(100 m) outdoor line-of-sight
• Supply voltage 2.8-3.4V;
• 2.4 GHz frequency band
RF Transmitter & Receiver

Applications

Remote Controls
Automation System
Wireless Security System

Frequency Range : 433.92 MHz


ENCODER DECODER
Radio-frequency identification (RFID) is
the wireless use of electromagnetic fields to
transfer data, for the purposes of
automatically identifying and tracking tags
attached to objects. The tags contain
electronically stored information.
GSM MODEM

We are using SIM900 GSM Module –

This means the module supports


communication in 900MHz band. In
India most of the mobile network
providers operate in the 900Mhz band.
GPS MODULE

GPS module communicates with


satellite to give information
about latitude and longitude
paramters for location tracking.
The applications of the Global
Positioning System fall into five
categories: location, navigation,
timing, mapping, and tracking. Each
category contains uses for the
military, industry, transportation,
recreation and science.
R305 Fingerprint Module

We are storing fingerprints in it’s memory using SFGDEMO PC


software. We are connecting RX , TX pins of modules to
microcontroller’s serial communication pins. We are giving regulated
5V supply for module.

You might also like