Você está na página 1de 47

CONTENTS

1. Abstract
2. Introduction
2.2 Block Diagram
2.3 Block Description
3. Circuit Details
3.2 Circuit Diagram
3.3 Circuit Description
4. Power supply
5. Microcontroller
6. I/O Ports
7. ADC
8. IR Sensors
9. Motor Driver-L293D
10. Program Code
11. Application
12. Conclusion
13. References

ABSTRACT
The objective of this project is to design an automated railway gate
controller using IR Sensor. The project comprises of two pairs of analog IR
Sensor which is placed in an order, so as to automatically control the
opening & closing of the gate in accordance to the arrival & departure of
the train crossing the public roads.
As the system is completely automated, it avoids manual errors and
thus provides ultimate safety to road users. By this mechanism, presence
of a gatekeeper is not necessary and automatic operation of the gate
through the motor action is achieved. Microcontroller Atmega16 performs
the complete operation i.e., sensing, gate closing and opening operation is
done by software coding written for the controller. The mechanism works
on a simple principle and there are no hardware complexities.

INTRODUCTION
Today’s world is the world of automation. Now a day we can find each
and every part is getting automated. If we talk of the Railway crossing, we
can find that it is manually operated. By the presently existing system
once the train leaves the station, the stationmaster informs the
gatekeeper about the arrival of the train through the telephone. Once the
gatekeeper receives the information, he closes the gate depending on the
timing at which the train arrives. Hence, if the train is late due to certain
reasons then gate remain closed for a long time causing traffic near the
gates. Our project which is “Automatic railway gate controller” can solve
this problem by automating the whole gate system.

In this project we are using a common power supply which regulates


the 12v supply from the adapter to give a constant 5 volt supply which can
be fed to all the components of the circuit. In this project we are using a
microcontroller which controls all the functions to be performed. IR
sensors along with the motor driver to drive motors are used in this
project.
BLOCK DIAGRAM:

MICRO MOTOR
IR SENSORs CONTROLLE DRIVER MOTOR
R

BLOCK DESCRIPTION:
CIRCUIT DETAILS

CIRCUIT DIAGRAM:
POWER SUPPLY
DESCRIPTION:

Power supply is the circuit from which we get a desired dc voltage to


run the other circuits. The voltage we get from the main line is 230V AC
but the other components of our circuit require 5V DC. Hence a step-down
transformer is used to get 12V AC which is later converted to 12V DC using
a rectifier. The output of rectifier still contains some ripples even though it
is a DC signal due to which it is called as Pulsating DC. To remove the
ripples and obtain smoothed DC power filter circuits are used. Here a
capacitor is used. The 12V DC is rated down to 5V using a positive voltage
regulator chip 7805. Thus a fixed DC voltage of 5V is obtained.

A 5V regulated supply is taken as followed:

Each of the blocks is described in more detail below:

 Transformer - steps down high voltage AC mains to low voltage


AC.

 Rectifier - converts AC to DC, but the DC output is varying.

 Smoothing - smoothes the DC from varying greatly to a small


ripple.

 Regulator - eliminates ripple by setting DC output to a fixed


voltage.
TRANSFORMER

Transformer is the electrical device that converts one voltage to


another with little loss of power. Transformers work only with AC. There
are two types of transformers as Step-up and Step-down transformer.
Step-up transformers increase voltage, step-down transformers reduce
voltage. Most power supplies use a step-down transformer to reduce the
dangerously high mains voltage to a safer low voltage. Here a step down
transformer is used to get 12V AC from the supply i.e. 230V AC.

RECTIFIERS

A rectifier is a circuit that converts AC signals to DC. A rectifier circuit


is made using diodes. There are two types of rectifier circuits as Half-
wave rectifier and Full-wave rectifier depending upon the DC signal
generated.

Half-wave Rectifier: It is the rectifier circuit that rectifies only half part of
the AC signal. It uses only a single diode. It only uses only positive part of
the AC signal to produce half-wave varying DC and produce gaps when the
AC is negative.
Full-wave Rectifier: It is also called as Bridge Rectifier. A bridge rectifier can
be made using four individual diodes, but it is also available in special
packages containing the four diodes required. It is called a full-wave
rectifier because it uses the total AC wave (both positive and negative
sections).
SMOOTHING

Smoothing is performed by a large value electrolytic capacitor


connected across the DC supply to act as a reservoir, supplying current to
the output when the varying DC voltage from the rectifier is falling. The
diagram shows the unsmoothed varying DC (dotted line) and the
smoothed DC (solid line). The capacitor charges quickly near the peak of
the varying DC, and then discharges as it supplies current to the
output. Here a capacitor of 330uF is used as a smoothing circuit.
VOLTAGE REGULATION

Voltage regulators produce fixed DC output voltage from variable DC


(a small amount of AC on it). Normally we get fixed output by connecting
the voltage regulator at the output of the filtered DC. It can also used in
circuits to get a low DC voltage from a high DC voltage (for example we use
7805 to get 5V from 12V). There are two types of voltage regulators

1. Fixed voltage regulators (78xx, 79xx)

2. Variable voltage regulators (LM317)

In fixed voltage regulators there is another classification

1. Positive voltage regulators

2. Negative voltage regulators

POSITIVE VOLTAGE REGULATORS:

This includes 78xx voltage regulators. The most commonly used ones
are 7805 and 7812. 7805 gives fixed 5V DC voltage if input voltage is in
(7.5V-20). You may sometimes have questions like, what happens if input
voltage is <7.5 V or some 3V, the answer is that regulation won't be
proper. Suppose if input is 6V then output may be 5V or 4.8V, but there
are some parameters for the voltage regulators like maximum output
current capability, line regulation etc. won't be proper. Remember that
electronics components should be used in the proper voltage and current
ratings as specified in datasheet. You can work without following it, but
you won't be able to get some parameters of the component.

NEGATIVE VOLTAGE REGULATORS:

Mostly available negative voltage regulators are of 79xx family. The mainly
available 79xx IC's are 7905,7912 1.5A output current ,short circuit
protection, ripple rejection are the other features of 79xx IC's.

Many of the fixed voltage regulators have 3 leads and look like power
transistors, such as the 7805 (+5V 1A) regulator shown on the above. If
adequate heat sinking is provided then it can deliver up to maximum 1A
current. For an output voltage of 5v-18v the maximum input voltage is 35v
and for an output voltage of 24V the maximum input voltage is 40V.For
7805 IC, for an input of 10v the minimum output voltage is 4.8V and the
maximum output voltage is 5.2V. The typical dropout voltage is 2V.

TOTAL CIRCUIT DIAGRAM OF POWER SUPPLY


MICROCONTROLLER
Microcontroller can be termed as a system on a chip computer which includes
number of peripherals like RAM, EEPROM, Timers etc., required to perform some
predefined task.
Does this mean that the microcontroller is another name for a computer…? The
answer is NO!

The computer on one hand is designed to perform all the general purpose tasks on a
single machine like you can use a computer to run a software to perform calculations
or you can use a computer to store some multimedia file or to access internet
through the browser, whereas the microcontrollers are meant to perform only the
specific tasks, for e.g., switching the AC off automatically when room temperature
drops to a certain defined limit and again turning it ON when temperature rises
above the defined limit.

There are number of popular families of microcontrollers which are used in different
applications as per their capability and feasibility to perform the desired task, most
common of these are 8051, AVR and PIC microcontrollers. In this article we will
introduce you with AVR family of microcontrollers.
History of AVR
AVR was developed in the year 1996 by Atmel Corporation. The architecture of
AVR was developed by Alf-EgilBogen and VegardWollan. AVR derives its name from
its developers and stands for Alf-EgilBogen VegardWollan RISC microcontroller, also
known as Advanced Virtual RISC. The AT90S8515 was the first microcontroller which
was based on AVR architecture however the first microcontroller to hit the
commercial market was AT90S1200 in the year 1997.

AVR microcontrollers are available in three categories:

1. Tiny AVR – Less memory, small size, suitable only for simpler applications

2. Mega AVR – These are the most popular ones having good amount of memory (up
to 256 KB), higher number of inbuilt peripherals and suitable for moderate to
complex applications.

3. Xmega AVR – Used commercially for complex applications, which require large
program memory and high speed.

The following table compares the above mentioned AVR series of microcontrollers:

Series Name Pins Flash Special


Memory Feature
TinyAVR 6-32 0.5-8 KB Small in size
MegaAVR 28-100 4-256KB Extended peripherals

XmegaAVR 44-100 16-384KB DMA ,


Event System included
What’s special about AVR?

They are fast: AVR microcontroller executes most of the instructions in


single execution cycle. AVRs are about 4 times faster than PICs; they
consume less power and can be operated in different power saving
modes. Let’s do the comparison between the three most commonly used
families of microcontrollers.

8051 PIC AVR


SPEED Slow Moderate Fast
MEMORY Small Large Large
ARCHITECTURE CISC RISC RISC
ADC Not Present Inbuilt Inbuilt
Timers Inbuilt Inbuilt Inbuilt
PWM Channels Not Present Inbuilt Inbuilt

AVR is an 8-bit microcontroller belonging to the family of Reduced


Instruction Set Computer (RISC). In RISC architecture the instruction set of
the computer are not only fewer in number but also simpler and faster in
operation. The other type of categorization is CISC (Complex Instruction
Set Computers).

8-bit means that the microcontroller is capable of transmitting and


receiving 8-bit data. The input/output registers available are of 8-bits. The
AVR families controllers have register based architecture which means
that both the operands for an operation are stored in a register and the
result of the operation is also stored in a register. Following figure shows a
simple example performing OR operation between two input registers and
storing the value in Output Register.

The CPU takes values from two input registers INPUT-1 and INPUT-2,
performs the logical operation and stores the value into the OUTPUT
register. All this happens in 1 execution cycle.
Features of ATmega16:

In our journey with the AVR we will be working


on Atmega16 microcontroller, which is a 40-pin IC and belongs to the
mega AVR category of AVR family. Some of the features of Atmega16 are:
 16KB of Flash memory
 1KB of SRAM
 512 Bytes of EEPROM
 Available in 40-Pin DIP
 8-Channel 10-bit ADC
 Two 8-bit Timers/Counters
 One 16-bit Timer/Counter
 4 PWM Channels
 In System Programmer (ISP)
 Serial USART
 SPI Interface

Architecture of AVR

The AVR microcontrollers are based on the advanced RISC


architecture and consist of 32 x 8-bit general purpose working registers.
Within one single clock cycle, AVR can take inputs from two general
purpose registers and put them to ALU for carrying out the requested
operation, and transfer back the result to an arbitrary register. The ALU
can perform arithmetic as well as logical operations over the inputs from
the register or between the register and a constant. Single register
operations like taking a complement can also be executed in ALU. We can
see that AVR does not have any register like accumulator as in 8051 family

of microcontrollers; the operations can be performed between any of the


registers and can be stored in either of them.

AVR follows Harvard Architecture format in which the processor is


equipped with separate memories and buses for Program and the Data
information. Here while an instruction is being executed, the next
instruction is pre-fetched from the program memory.

Since AVR can perform single cycle execution, it means that AVR can
execute 1 million instructions per second if cycle frequency is 1MHz. The
higher is the operating frequency of the controller, the higher will be its
processing speed. We need to optimize the power consumption with
processing speed and hence need to select the operating frequency
accordingly.

There are two flavors for Atmega16 microcontroller:


1. Atmega16:- Operating frequency range is 0 – 16 MHz
2. Atmega16L:- Operating frequency range is 0 – 8 MHz
If we are using a crystal of 8 MHz = 8 x 10 6 Hertz = 8 Million cycles, then
AVR can execute 8 million instructions.

Naming Convention

The AT refers to Atmel the manufacturer, Mega means that the


microcontroller belong to Mega AVR category, 16 signifies the memory of
the controller, which is 16KB.

Architecture Diagram: Atmega16


Following points explain the building blocks of Atmega16 architecture:
 I/O Ports: Atmega16 has four (PORTA, PORTB, PORTC and PORTD) 8-
bit input-output ports.
 Internal Calibrated Oscillator: Atmega16 is equipped with an internal
oscillator for driving its clock. By default Atmega16 is set to operate at
internal calibrated oscillator of 1 MHz The maximum frequency of internal
oscillator is 8Mhz. Alternatively, ATmega16 can be operated using an
external crystal oscillator with a maximum frequency of 16MHz. In this
case you need to modify the fuse bits. (Fuse Bits will be explained in a
separate tutorial).

 ADC Interface: Atmega16 is equipped with an 8 channel ADC (Analog


to Digital Converter) with a resolution of 10-bits. ADC reads the analog
input for e.g., a sensor input and converts it into digital information which
is understandable by the microcontroller.

 Timers/Counters: Atmega16 consists of two 8-bit and one 16-bit


timer/counter. Timers are useful for generating precision actions for e.g.,
creating time delays between two operations.
 Watchdog Timer: Watchdog timer is present with internal oscillator.
Watchdog timer continuously monitors and resets the controller if the
code gets stuck at any execution action for more than a defined time
interval.
 Interrupts: Atmega16 consists of 21 interrupt sources out of which
four are external. The remaining are internal interrupts which support the
peripherals like USART, ADC, and Timers etc.
 USART: Universal Synchronous and Asynchronous Receiver and
Transmitter interface is available for interfacing with external device
capable of communicating serially (data transmission bit by bit).
 General Purpose Registers: Atmega16 is equipped with 32 general
purpose registers which are coupled directly with the Arithmetic Logical
Unit (ALU) of CPU.
 ISP: AVR family of controllers have In System Programmable Flash
Memory which can be programmed without removing the IC from the
circuit, ISP allows to reprogram the controller while it is in the application
circuit.

 Memory: Atmega16 consist of three different memory sections:


1. Flash EEPROM: Flash EEPROM or simple flash memory is used to store
the program dumped or burnt by the user on to the microcontroller. It can
be easily erased electrically as a single unit. Flash memory is non-volatile
i.e., it retains the program even if the power is cut-off. Atmega16 is
available with 16KB of in system programmable Flash EEPROM.
2. Byte Addressable EEPROM: This is also a nonvolatile memory used to
store data like values of certain variables. Atmega16 has 512 bytes of
EEPROM; this memory can be useful for storing the lock code if we are
designing an application like electronic door lock.
3. SRAM: Static Random Access Memory, this is the volatile memory of
microcontroller i.e., data is lost as soon as power is turned off. Atmega16
is equipped with 1KB of internal SRAM. A small portion of SRAM is set
aside for general purpose registers used by CPU and some for the
peripheral subsystems of the microcontroller.

 SPI: Serial Peripheral Interface, SPI port is used for serial


communication between two devices on a common clock source. The data
transmission rate of SPI is more than that of USART.

 TWI: Two Wire Interface (TWI) can be used to set up a network of


devices, many devices can be connected over TWI interface forming a
network, the devices can simultaneously transmit and receive and have
their own unique address.

PIN DIAGRAM :
Pin Descriptions

PIN NO. PINS DESCRIPTION


10 VCC Digital supply voltage.
11,31 GND Ground
33-40 PortA Port A serves as the analog inputs to the A/D Converter.
Port A also serves as an 8-bit bi-directional I/O port, if the A/D Converter is
(PA7..PA0) not used.
Port pins can provide internal pull-up resistors (selected for each bit).
The Port A output buffers have symmetrical drive characteristics with both
high sink and source capability. When pins PA0 to PA7 are used as inputs and
are externally pulled low, they will source current if the internal pull-up
resistors are activated. The Port A pins are tri-stated when a reset condition
becomes active, even if the clock is not running.
1-7 Port B Port B is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected for each
(PB7..PB0) bit). The Port B output buffers have symmetrical drive characteristics with
both high sink and source capability. As inputs, Port B pins that are externally
pulled low will source current if the pull-up resistors are activated. The Port B
pins are tri-stated when a reset condition becomes active, even if the clock is
not running.
22-29 PortC Port C is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The Port C output buffers have symmetrical drive
(PC7..PC0) characteristics with both high sink and source capability. As inputs, Port C pins
that are externally pulled low will source current if the pull-up resistors are
activated. The Port C pins are tri-stated when a reset condition becomes
active, even if the clock is not running. If the JTAG interface is enabled, the
pull-up resistors on pins PC5(TDI), PC3(TMS) and PC2(TCK) will be activated
even if a reset occurs.
Port C also serves the functions of the JTAG interface

14-21 PortD Port D is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The Port D output buffers have symmetrical drive
(PD7..PD0) characteristics with both high sink and source capability. As inputs, Port D pins
that are externally pulled low will source current if the pull-up resistors are
activated. The Port D pins are tri-stated when a reset condition becomes
active, even if the clock is not running.
9 RESET Reset Input. A low level on this pin for longer than the minimum pulse length
will generate a reset, even if the clock is not running. Shorter pulses are not
guaranteed to generate a reset.

12 XTAL1 Input to the inverting Oscillator amplifier and input to the internal clock
operating circuit.
13 XTAL2 Output from the inverting Oscillator amplifier

30 AVCC AVCC is the supply voltage pin for Port A and the A/D Converter. It should
be externally connected to VCC, even if the ADC is not used. If the ADC is
used,
it should be connected to VCC through a low-pass filter.
32 AREF AREF is the analog reference pin for the A/D Converter.
I/O PORTS
Atmega16 have 32 general purpose digital I/O pins. Corresponding to
every pin, there are 3 bits in 3 different registers which control its
function. Let’s say we are talking about the pin PA0. The three registers
involved with this pin are DDRA, PORTA and PINA and the corresponding
bits are DDRA0, PORTA0 and PINA0.

PORT REGISTERS

Reads the input status


of the pins

DDRx (Data Direction Register)

DDR - is the Data Direction Register - writing 1 to DDRA0 makes the pin
PA0 act like an output pin and writing 0 makes it an input pin.
 Initializes the direction of the port i.e., as input or output.

 1 – represents output

 0 – represents input

CONTROLLING
i/o STATUS OF D
D
PORT B R
B

PORTX(for output control)

 It controls the output status of the ports.

 Logic 1 – 5 V (high)

 Logic 0 – 0V (low)

PORTX = 0B111111111;
PORTX = 0B00000000;

PORTX = 0B10001110;
PINX(for input data)

 Used to get the input data.

 Logic 1 – 5V (high)

 Logic 0 – 0V (low)

A = PINX;

Then .,A = 0B01110101;

Code example:
DDRC=130;
or,
DDRC= 0b 10000010;
or,
DDRC= 0x 82;

Either of the above statements will make the PC1 and PC7 as output and
rest as input.
Detailed Explanation:

It is to be noted that writing some value onto a register simply means that
the bits of the register will attain values such that the binary number
represented by all the 8 bits of the register together equals the number
assigned to them. e.g. writing 0b10110101 means that the bits in the
register will become like this:

PORT register - If DDRA0 is set as 1,

 writing 1 to PORTA0 gives a high output on pin PA0

 writing 0 to PORTA0 gives a low output on pin PA0

If DDRA0 is set to 0 (input),

 writing 1 to PORTA0 simply pulls up the pin to Vcc via 100k


resistance

 Writing 0 to PORTA0 makes the pin tri-stated (very high input


resistance, practically floating.) This means that in absence of
any input from outside the pin will just read some arbitrary
value.

PIN register - This register is used for reading the digital value of the pin. It
can be thought of as actually connected to MCU physical pins. If voltage of
the pin (either in case of input or output) at any instant is low it will read
as 0 otherwise 1.
Code example:
int read;
read = PINB; // stores the value of 8 bit PINB register in the variable read
or,
read =PINB & 4; // this statement stores the value of PB2 bit in read

ADC
Features:

• 10-bit Resolution
• 0.5 LSB Integral Non-
linearity
• ±2 LSB Absolute
Accuracy
• 13 - 260 µs Conversion
Time
• Up to 15 KSPS at Maximum
Resolution
• 8 Multiplexed Single Ended Input
Channels
• Optional Left adjustment for ADC
Result Readout
• 0 - VCC ADC Input Voltage
Range
• Selectable 2.56V ADC Reference
Voltage
• Free Running or Single Conversion
Mode
• ADC Start Conversion by Auto Triggering on
Interrupt Sources
• Interrupt on ADC Conversion
Complete

The ATmega16 features a 10-bit successive approximation ADC.


The ADC is connected to an 8-channel Analog Multiplexer which
allows 8 single-ended voltage inputs constructed from the pins of
Port A. The single-ended voltage inputs refer to 0V (GND).

The ADC contains a Sample and Hold circuit which ensures that the
input voltage to the ADC is held at a constant level during
conversion. The ADC has a separate analog supply voltage pin,
AVCC. AVCC must not differ more than ±0.3 V from VCC.
Internal reference voltages of nominally 2.56V or AVCC are
provided On-chip. The volt- age reference may be externally
decoupled at the AREF pin by a capacitor for better noise
performance.

CODING:

#include<avr/adc.h>

void main()
{
unsigned char x;
adc_init(); //for initialization of ADC port
x=read_adc_channel(channel number); //to read a
particular ADC channel and
//storing in a variable
}

IR SENSORS

DEFINITION

IR stands for “Infra Red”. Infrared detectors/sensors are transducers of


radiant energy.IR Sensor is a sensor that sends and detects IR
Radiation/Signals. Infrared radiation is the portion of electromagnetic
spectrum having wavelengths longer than visible light wavelengths, but
smaller than microwaves, i.e., the region roughly from 0.75µm to 1000 µm
is the infrared region. Infrared waves are invisible to human eyes. The
wavelength region of 0.75µm to 3 µm is called near infrared, the region
from 3 µm to 6 µm is called mid infrared and the region higher than 6 µm
is called far infrared. (The demarcations are not rigid; regions are defined
differently by many).

 “Visible”: 0.3 – 1.0 μm;


 Near-IR: 1.0 – 5.2 μm;
 Mid-IR : 8 – 25 μm;
 Far-IR: 25 – 1000 μm; airborne, space

TYPES OF IR SENSORS:

1. Active IR Sensors:
Active IR Sensors are the type of IR Sensors that employs an IR source
& IR detectors (emitter & receiver). They operate by transmitting energy
from either a light emitting diode (LED) or a laser diode. A phototransistor
is used as an active IR detector. In these types of IR sensors, the LED or
laser diode illuminates the target, and the reflected energy is focused onto
a detector. Photoelectric cells, Photodiode or phototransistors are
generally used as detectors. The measured data is then processed using
various signal-processing algorithms to extract the desired information.
Active IR detectors provide count, presence, speed, and occupancy
data in both night and day operation.
2. Passive IR Sensors:

These are basically IR detectors; they don’t use any IR source. These
form the major class of IR sensors/detectors.
A passive infrared system detects energy emitted by objects in the
field of view and may use signal-processing algorithms to extract the
desired information. It does not emit any energy of its own for the
purposes of detection. Passive infrared systems can detect presence,
occupancy, and count.

Type of IR Sensor required in the project


Active IR Sensors- Reflectance Sensors
This type of sensors house both an IR source and an IR detector in a
single housing in such a way that light from emitter LED bounces off an
external object and is reflected into a detector. Amount of light reflected
into the detector depends upon the reflectivity of the surface.
This principle is used in intrusion detection, object detection (measure
the presence of an object in the sensor’s FOV), barcode decoding, and
surface feature detection (detecting features painted, taped, or otherwise
marked onto the floor), wall tracking (detecting distance from the wall),
etc.
It can also be used to scan a defined area; the transmitter emits a
beam of light into the scan zone, the reflected light is used to detect a
change in the reflected light thereby scanning the desired zone.
It consist of a pair of IR sensors –
-Transmitter
- Receiver
The transmitter transmits the IR signals & the receiver receives the ir
signal.

IR RECEIVER
Transmitter:
 Transmitter = LED (Light Emitting Diode)

 It is similar to normal LEDs but emit infra-red light its glow can be seen
with a digital camera or mobile phone camera.
Receiver:
 Receiver = Photodiode/IR Transistor.
 A photodiode is a diode that conducts only when light falls on it

WORKING PRINCIPLE
CONNECTIONS
APPLICATIONS:

 Robotics – Line follower, Obstacle detector, Edge detector


 Vehicle crash detection
 Speed measurement of motors
 Space expeditions applications
 Military Applications
 General uses as in Shop Door sensor, Anti-theft alarm, Appliance
control system

MOTOR DRIVER
Whenever we are talking about driving a motor through the outputs
of our microcontroller, it is not easy to do that work. This is so because our
motors specification tells to drive it on 12v dc but our microcontroller can
give a max of 5v. So to drive a motor we need some drivers which can
amplify the 5v voltage to 12v. . These days many IC manufacturers have H-
bridge motor driver available in the market like L293D is most used H-
Bridge driver IC. H-bridge can also be made with the help of transistors
and MOSFETs etc. rather of being cheap, they only increase the size of
the design board, which is sometimes not required so using a small 16 pin
IC is preferred for this purpose. The driver which we are using here to
drive the motor is an IC L293D.

WORKING 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. It is also
known as "Full Bridge". Basically there are four switching elements in the
H-Bridge as shown in the figure below.
As you can see in the figure above there are four switching elements
named as "High side left", "High side right", "Low side right", "Low side
left". When these switches are turned on in pairs motor changes its
direction accordingly. Like, if we switch on High side left and Low side right
then motor rotate in forward direction, as current flows from P\power
supply through the motor coil goes to ground via switch low side right.
This is shown in the figure below.
Similarly, when you switch on low side left and high side right, the current
flows in opposite direction and motor rotates in backward direction. This
is the basic working of H-Bridge. We can also make a small truth table
according to the switching of H-Bridge explained above.

Truth Table
High Left High Right Low Left Low Right Description
On Off Off On Motor runs clockwise
Off On On Off Motor runs anti-clockwise
On On Off Off Motor stops or decelerates
Off Off On On Motor stops or decelerates

As already said, H-bridge can be made with the help of transistors as well
as MOSFETs; the only thing is the power handling capacity of the circuit.
If motors are needed to run with high current then lot of dissipation is
there. So head sinks are needed to cool the circuit.

Now you might be thinking why I did not discuss the cases like High side
left on and Low side left on or high side right on and low side right on.
Clearly seen in the diagram, you don't want to burn your power supply by
shorting them. So that is why those combinations are not discussed in the
truth table.

So we have seen that using simple switching elements we can make our
own H-Bridge, or other option we have is using an IC based H-bridge
driver.

►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 and if you have motor with
fix direction of motion. You can make use of all the four I/Os to connect
up to four DC motors. L293D has output currentof 600mA and peak output
current of 1.2A per channel. Moreover for protection o f c i r c u i t f r o m
b a c k E M F, 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.

As you can see in the circuit, three pins are needed for interfacing a DC
motor (A, B, Enable). If you want the o/p to be enabled completely then
you can connect Enable to VCC and only 2 pins needed from controller to
make the motor work.

As per the truth mentioned in the image above it’s fairly simple to
program the microcontroller. It’s also clear from the truth table of BJT
circuit and L293D the programming will be same for both of them, just
keeping in mind the allowed combinations of A and B.

PROGRAM CODE
APPLICATION:
CONCLUSION

REFERENCES

Você também pode gostar