Project Report On Automatic Railway Gate Control

forestevanescentElectronics - Devices

Nov 2, 2013 (3 years and 11 months ago)

1,543 views

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


1




Project Report


On


Automatic Railway Gate Control

Submitted in the partial fulfillment of the requirement for the award of degree of

Bachelors of Technology


I
n


Electronics & Communication
Engineering












Submitted by








Mukesh Baberwal







10805029






























Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


2




Certificate


Certified that this project entitled “
Automatic Railway Gate Control
” submitted by
Mukesh
Baberwal

(
RE38E1B46
),

students of
Electronics &

Communication
Engineering Department,
Lovely Professional University, Phagwara Punjab

in the partial fulfillment of the requirement
for the award of Bachelors of Technology (
Electronics & Communication
Engin
eering)
Degree of LPU
, is a record of student

s
own study carried under my supervision & guidance.


This report has not been submitted to any other university or institution for the award of any
degree.












Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


3

Acknowledgement




I would like to acknowledge and extend my heartfelt gratitude to my Me
ntor Er.
Sameksha Bhaskar who supported me to make this
Capstone
Project with
proper guidance
. I would also thank my groupmates (Pallavi , Sushant and
Dhananjay) who have given their inputs equally and effectively without whom
it was impossible to make th
is Project.


I


am heart
l
y thankful to college
for facilitating various means like wifi which
helped to accomplish the task.

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


4

Abstract




OBJECTIVE:



The aim of this project is to Automate unmanned railway gate..



The objective of this project is to ma
nage the control system of railway gate using the
microcontroller
. The

control system activates and closes the gate on either side of the track.
once the train crosses the other end control system automatically lifts the gate. For
mechanical operation of
the gates
dc motors

are employed. Here we are using embedded
controller built around the 8051 family (AT89C52) for the control according to the data
pattern produced at the input port of the micro controller, the appropriate selected action will
be taken.
.

The logic is produced by the program written in
Assembly

language. The
software program is written, by using the KEIL micro vision environment. The program
written is then converted in HEX code after simulation and burned on to microcontroller.


















The basic idea behind this project is an automatic railway gate at a level crossing replacing
the gates operated by the gatekeeper. It deals with two things. Firstly, it deals with the
reduction of time for which the gate is being kept closed. And
secondly, to provide safety to
the road users by reducing the accidents. 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.


Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


5



Table of Contents



1.

Introductio
n………………………………………………………..
6
-
7

1.1

Aim……………………………………………………………

6

1.2

Function ……………………………………………………...
..7

2.

Figures……………………………………………………………
.8
-

2.1

Circuit Diagram…………………………………………………7

2.2

Block Diagram…………………………………………………..8

3.

Hardware description………………………………………………..9
-

3.1

89S52 microcon
troller…………………………………………..

3.2

L293D motor driver……………………………………………..

3.3

7805 voltage regulator…………………………………………..

3.4


IR Sensors………………………………………………………

3.5

LM358 opamp…………………………………………………...

4.

Software Description………………………………………………...

4.1

Keil Micro Vision3………………………………………………

5.

Sourc
e Code………………………………………………………….

6.

Data Sheets…………………………………………………………..

6.1

89S52 microcontroller…………………………………………...

6.2


L293D…………………………………………………………..

6.3

LM358…………………………………………………………..

6.4


7805…………………………………………………………….

7.

Conclusion ………………………………………………………….

8.

Problems occurred………………
…………………………………..

9.

Reference …………………………………………………………...


























Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


6



1.

Introduction






1.1 Aim


Early level crossings had a flagman in a nearby booth who would, on the approach of a train,
wave a red flag or lantern to stop all traffic and cle
ar the tracks. Manual or electrical closable
gates that barricaded the roadway were later introduced. The gates were intended to be a
complete barrier against intrusion of any road traffic onto the railway. In the early days of the
railways much road traff
ic was horse drawn or included livestock. It was thus necessary to
provide a real barrier. Thus, crossing gates, when closed to road traffic, crossed the entire
width of the road. When opened to allow road users to cross the line, the gates were swung
acro
ss the width of the railway, preventing any pedestrians or animals getting onto the line.

With the appearance of motor vehicles, this barrier became less effective and the need for a
barrier to livestock diminished dramatically. Many countries therefore su
bstituted the gated
crossings with weaker but more highly visible barriers and relied upon road users following
the associated warning signals to stop.


We are concerned of providing an automatic railway gate control at unmanned level
crossings replacing t
he gates operated by gate keepers and also the semi automatically
operated gates. It deals with two things. Firstly, it deals with the reduction of time for which
the gate is being kept closed. And secondly, to provide safety to the road users by reducing
the accidents that usually occur due to carelessness of road users and at times errors made by
the gatekeepers
.




















Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


7






1.2
Function




By employing the automatic railway gate control at the level crossing the arrival of train is
detected b
y the sensor placed on either side of the gate at about 5km from the level crossing.
Once the arrival is sensed, the sensed signal is sent to the microcontroller and it checks for
possible presence of vehicle between the gates, again using sensors. Subsequ
ently adequate
signals on either side are provided to the road users indicating the closure of gates. Once, no
vehicle is sensed in between the gate the motor is activated and the gates are closed. But, for
the worst case if any obstacle is sensed it is i
ndicated to the train driver by signals placed at
about 2km and 180m, so as to bring it to halt well before the level crossing. When no obstacle
is there and the train is to free to move.


The departure of the train is detected by sensors placed at the ga
te. The signal about the
departure is sent to the microcontroller, which in turn operates the motor and opens the gate.
Thus, the time for which the gate is closed is less compared to the manually operated gates
since the gate is closed depending upon the
telephone call from the previous station. Also
reliability is high as it is

not subjected to manual errors.



Our project is designed using 8052

microcontroller to avoid railway accidents happening at
unattended railway gates. This project utilizes An IR

s
ensor which is fixed at the railway
gate. Whenever a signal from the sensor is detected then the gates are closed. We will be
using DC

geared

motor

to open and close the gates. We will be using L293D

driver

IC to
control the motor i.e. open and close the g
ates.

This type of gates can be employed in an unmanned level crossing where the chances of
accidents are higher and reliable operation is required. Since, the operation is automatic; error
due to manual operation is prevented. Automatic railway gate contr
ol is highly economical
microcontroller based arrangement, designed for use in almost all the unmanned level
crossings in the country.






IR
transmitter

IR

receiver

Comparator

~

Transistor
switch

+V

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


8
















Overview of project




















Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


9







2.Figures





2.1
Circuit Diagram







Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


10














2.2

Block Diagram













Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


11












3.
Hardware Description


3.1 89S52 Microcontroller

In 1981, Intel Corporation introduced an 8
-
bit microcontroller called the 8052. This
microcontroller had 128 bytes of RAM, 4K bytes of on
-
chip ROM, two timers, one serial
port, and four ports (each 8
-
bits wide) all on a single chip. The 8052 is an 8
-
bit processor,
meaning that the CPU can work on only 8 bits of data at a time. Data larger
than 8 bits has to
broken into 8
-
bit pieces to be processed by the CPU. The 8052 has a total of four I/O ports,
each 8 bits wide. Although the 8052 can have a maximum of 64K bytes of on
-
chip ROM,
many manufacturers have put only 4K bytes on the chip. There

are different flavors of the
8052 in terms of speed and amount of on
-
chip ROM, but they are all compatible with the
original 8052 as far as the instructions are concerned. The various members of the 8052
family are 8052 microcontroller, 8052 microcontroll
er and 8031 microcontroller.




Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


12





Block diagram of microcontroller 8052



8052 Microcontroller


The 8052 is the original member of the 8052 family. Figure 2.1 shows the block diagram of
the 8052 microcontroller. The AT89C51
is a low
-
power, high
-
performance CMOS 8
-
bit
microcomputer with 4K bytes of Flash programmable and erasable read only memory
(PEROM). The device is manufactured using Atmel’s high
-
density nonvolatile memory
technology and is compatible with the industry
-
sta
ndard MCS
-
51 instruction set and pin out.
The on
-
chip Flash allows the program memory to be reprogrammed in
-
system or by a
conventional nonvolatile memory programmer. By combining a versatile 8
-
bit CPU with
Flash on a monolithic chip, the Atmel AT89C51 is
a powerful microcomputer which provides
a highly
-
flexible and cost
-
effective solution to many embedded control applications. The
AT89C51 provides the following standard features: 4Kbytes of Flash, 128 bytes of RAM, 32
I/O lines, two 16
-
bittimer/counters, f
ive vector two
-
level interrupt architecture, a full duplex
serial port, and on
-
chip oscillator and clock circuitry. In addition, the AT89C51 is designed
with static logic for operation down to zero frequency and supports two software selectable
power savin
g modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters,
serial port and interrupt system to continue functioning. The Power
-
down Mode saves the
RAM contents but freezes the oscillator disabling all other chip functions until the next
h
ardware reset.

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


13





Pin Description


VCC
-
Supply voltage.

GND
-
Ground.





Pin diagram for microcontroller 8052


Port 0


Port 0 is an 8
-
bit open
-
drain bi
-
directional I/O port. As an output port, each pin can sink eig
ht
TTL inputs. When 1s are written to port 0 pins, the pins can be used as high
-
impedance
inputs. Port 0 may also be configured to be the multiplexed low
-

order address/data bus
during accesses to external program and data memory. In this mode P0 has inter
nal pull
-
ups.
Port 0 also receives the code bytes during Flash programming, and outputs the code bytes
during program verification. External pull
-
ups are required during program verification.



Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


14

Port 1


Port 1 is an 8
-
bit bi
-
directional I/O port with intern
al pull
-
ups. The Port 1 output buffers can
sink/source four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the
internal pull
-
ups and can be used as inputs. As inputs, Port 1 pins that are externally being
pulled low will source curr
ent (IIL) because of the internal pull
-
ups. Port 1 also receives the
low
-
order address bytes during Flash programming and verification.



Port 2


Port 2 is an 8
-
bit bi
-
directional I/O port with internal pull
-
ups. The Port 2 output buffers can
sink/source
four TTL inputs. When 1s are written to Port 2 pins they are pulled high by the
internal pull
-
ups and can be used as inputs. As inputs, Port 2 pins that are externally being
pulled low will source current (IIL) because of the internal pull
-
ups. Port 2 emit
s the high
-
order address byte during fetches from external program memory and during accesses to
external data memory that uses 16
-
bit addresses (MOVX @DPTR). In this application, it uses
strong internal pull
-
ups when emitting 1s. During accesses to extern
al data memory that uses
8
-
bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register.
Port 2 also receives the high
-
order address bits and some control signals during Flash
programming and verification.


Port 3


Port 3 is an
8
-
bit bi
-
directional I/O port with internal pull
-
ups. The Port 3 output buffer scan
sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the
internal pull
-
ups and can be used as inputs. As inputs, Port 3 pins that are ext
ernally being
pulled low will source current (IIL) because of the pull
-
ups. Port 3 also serves the functions
of various special features of the AT89C51 as listed below:





Table showing function of port 3


Port 3 also receives some control signals for Fl
ash programming and verification.


RST

Reset input. A high on this pin for two machine cycles while the oscillator is running resets
the device.

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


15

ALE/PROG

Address Latch Enable output pulse for latching the low byte of the address during accesses to
extern
al memory. This pin is also the program pulse input (PROG) during Flash
programming. In normal operation ALE is emitted at a constant rate of 1/6 the oscillator
frequency, and may be used for external timing or clocking purposes. Note, however, that one
A
LE pulse is skipped during each access to external Data Memory. If desired, ALE
operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is
active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled hig
h.
Setting the ALE
-
disable bit has no effect if the microcontroller is in external execution mode.



PSEN

Program Store Enable is the read strobe to external program memory.When the AT89C51 is
executing code from external program memory, PSEN is activated
twice each machine cycle,
except that two PSEN activations are skipped during each access to external data memory.


EA/VPP

External Access Enable. EA must be strapped to GND in order to enable the device to fetch
code from external program memory location
s starting at 0000H up to FFFFH. Note,
however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should
be strapped to VCC for internal program executions. This pin also receives the 12
-
volt
programming enable voltage (VPP) duri
ng Flash programming, for parts that require 12
-
volt
VPP.

XTAL1

Input to the inverting oscillator amplifier and input to the internal clock operating circuit.



XTAL2

Output from the inverting oscillator amplifier. Oscillator Characteristics XTAL1 and XTA
L2
are the input and output, respectively, of an inverting amplifier which can be configured for
use as an on
-
chip oscillator, as shown in Figure 1. Either a quartz crystal or ceramic resonator
may be used. To drive the device from an external clock source
, XTAL2 should be left
unconnected while XTAL1 is driven as shown.


Crystal Oscillator Connections

There are no requirements on the duty cycle of the external clock signal, since the input to the
internal clocking circuitry is through a divide
-
by
-
two flip
-
flop, but minimum and maximum
voltage high and low time specifications must be observed.

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


16


How Oscillator works

When quartz crystal is subjected to mechanical pressure, they produce

a measurable electrical voltage conversely when an electric current is ap
plied to a crystal, it
will induce mechanical movement. If an ac is passed through the crystal plate the charges
oscillate back and front at the resonant frequency of crystal.




f=1

2




((1+C/C
P
)/(LC)))




Quartz crystal exhibits a property called the piezo
-
electric effect that is they produce
an electr
ic voltage. When subjected to pressure along certain direction of the crystal because
of this property quartz crystal has important application in electronics industry for controlling
the frequency of radio waves.When piezo
-
electric crystal is used in pla
ce of LC circuit for
higher frequency stability, the oscillator is called as crystal oscillator.




Crystal oscillator is used for stability frequency for a long period of time. The
resolution of 0.01 nm/s can be obtained. Crystal operates between f
p
a
nd fs frequency (a very
narrow bandwidth).


Status of External Pins during Idle and Power
-
down Modes

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


17


Program Memory Lock Bits

On the chip are three lock bits which can be left un
-
programmed (U) or can be
programmed (P) to obtain the additional features listed in

the table below. When lock bit 1 is
programmed, the logic level at the EA pin is sampled and latched during reset. If the device is
powered up without a reset, the latch initializes to a random value, and holds that value until
reset is activated. It is n
ecessary that the latched value of EA be in agreement with the current
logic level at that pin in order for the device to function properly.


Lock Bit Protection Modes


Program Lock Bits


Protection Type


LB1

LB2

LB3

1

U

U

U

No program lock features

2

P

U

U

MOVC instructions executed from external
program memory are disabled from fetching code
bytes from internal memory, EA is sampled and
latched on reset, and further programming of the
Flash is disabled

3

P

P

U

Same as mode 2, also verify is disabled

4

P

P

P

Same as mode 3, also external execution is
disabled




Mode

Program
Memory

ALE


Port 0

Port 1

Port 2

Port3

Idle

Internal

1

1

Data

Data

Data

Data

Idle

External

1

1

Float

Data

Address

Dat
a

Power
-
down

Internal

0

0

Data

Data

Data

Data

Power
-
down

External

0

0

Float

Data

Data

Data

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


18


Programming the Flash


The AT89C51 is normally shipped with the on
-
chip Flash memory array in the erased
state (that is, contents = FFH) and ready to be programmed. The programming interfac
e
accepts either a high
-
voltage (12
-
volt) or a low
-
voltage (VCC) program enable signal.

The low
-
voltage programming mode provides a convenient way to program the
AT89C51 inside the user’s system, while the high
-
voltage programming mode is compatible
with
conventional third
-
party Flash or EPROM programmers.


Reading the Signature Bytes:


The signature bytes are read by the same procedure as a normal verification of
locations 030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic low.
The

values returned are as follows.

(030H) = 1EH indicates manufactured by Atmel

(031H) = 51H indicates 89C51

(032H) = FFH indicates 12V programming

(032H) = 05H indicates 5V programming.


Programming Interface

Every code byte in the Flash array can be writte
n and the entire array can be erased by
using the appropriate combination of control signals. The write operation cycle is self timed
and once initiated, will automatically time itself to completion. All major programming
vendors offer worldwide support fo
r the Atmel microcontroller series. Please contact your
local programming vendor for the appropriate software revision.










Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


19

Flash Programming Modes

Mode

RST

PSEN

ALE/
PROG

EA

/
VPP

P2.6

P2.7

P3.6

P3.7

Write Code Data

H

L


H/12V

L

H

H

H

Read Code Data

H

L

H

H

L

L

H

H

Write
Lock

Bit
-
1

H

L


H/12V

H

H

H

H

Bit
-
2

H

L


H/12V

H

H

L

L

Bit
-
3

H

L


H/12V

H

L

H

L

Chip Erase

H

L


H/12V

H

L

L

L

Read Signature
Byte

H

L

H

H

L

L

L

L

Note: Chip Erase requires a 10 ms PROG pulse.

E
XTERNAL
P
ROGRAM
M
EMORY
R
EAD
C
YCLE










External Data Memory Read Cycle














External Data Memory Write Cycle

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


20















External Clock Drive Waveforms

















External Clock Drive







Symbol

Parameter

Min

Max

Units

1/t
CLCL

Oscillator Frequency

0

24

MHz

t
CLCL

Clock Period

41.6


ns

t
echs

High Time

15


ns

t
alc

Low Time

15


ns

t
alc

Rise Time


20

ns

t
echs

Fall Time


20

ns

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


21

3.2 Power Supply


CIRCUIT DIAGRAM:






POWER SUPPLY:

To run the electronic gadget at home it is provided by some power supply. The
microcontroller used (at89c51) requires 12v D.C supply. The DTMF receive
r used (mt8870)
requires 5v D.C. so design of these regulated power supply is also an important part in
hardware design. The A.C power supply from mains is taken and regulated using the
rectifiers.

For design of a regulated power supply components used are
:



Transformer.



Diodes.



Rectifiers.



Regulated IC chips.



Capacitive filters.

Trans former:

A transformer is required to couple the mains to the actual power supply circuit. This
is required to isolate the mains from the actual regulated power supply circuit
and the other
part of the kit. This isolation eliminates the dame of the kit to any power supply variations or
from a faulty shock.








IN4007

0


1


2

7805

LED

1

2

1000u
f

TRANSFORMER

6


8

1

IN4007

5

1k

2

1

100u
f

230 V AC

SUPPLY

50 HZ

4

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


22


For a transformer shown below:

:


Diodes:


In bride rectifier four diodes are used.

The specifications of diodes are chosen as:



PIV > input voltage.



Si diode is better.



Power dissipation is kept fixed with respect to current through the diode.

Junction capacitance need not be considered for frequencies <1 kHz.

RECTIFIERS:

Rectification i
s a process of conversion of AC to DC. Here, the AC of transformer
output is given to the rectifier input, which converts it to DC output. Basically, bridge
rectifiers or diodes arranged in bridge called Diode arrangement are used for power supply
design.

A bridge rectifier makes use of four diodes in a bridge arrangement to achieve full
-
wave rectification. This is a widely used configuration, both with individual diodes wired as
shown and with single component bridges where the diode bridge is wired intern
ally


Current Flow in the Bridge Rectifier




V1

V2

i1

i2

V1

=

i2

=
n1

V2 i1 n2

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


23

For both positive and negative swings of the transformer, there is a forward path
through the diode bridge. Both conduction paths cause current to flow in the same
direction through
the load resistor, accomplishing full
-
wave rectification.

While one set of diodes is forward biased, the other set is reverse biased and
effectively eliminated from the circuit.

Diode Bridge
:

A
diode bridge

is an arrangement of four diodes connected in a b
ridge circuit as
shownbelow, that provides the same polarity of output voltage for any polarity of the input
voltage. When used in its most common application, for conversion of alternating current
(AC) input into direct current (DC) output, it is known as

a bridge rectifier. The diagram
describes a diode
-
bridge design known as a full
-
wave rectifier or Graetz circuit.

This
design can be used to rectify single phase AC when no transformer center tap is available

Bridge Rectifier Circuit
:


The essential feature of this arrangement is that for both polarities of t
he voltage at the
bridge input, the polarity of the output is constant.




Capacitors
:


Capacitive filters are used stabilized or perfect regulation of the voltage. The capacitive
filters are opted because, they are more efficient. But they are als
o more costly.


Different types of capacitors are:

1.

Ceramic capacitors.

2.

Electrolyte capacitors.

3.

Paper/Mica capacitors.

4.

Silver capacitors.

5.

Tantalum capacitors.



Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


24



Ceramic, Paper/Mica, Silver are nonpolarized capacitors. Electrolyte and Tantalum are
polariz
ed capacitors. For high frequency, Ceramic capacitors are used. For low frequencies,
Electrolyte capacitors are used.



3.3

L293D MOTOR DRIVER


Whenever a robotics hobbyist talk about making a robot, the first thing comes to his mind is
making the robot mo
ve on the ground. And there are always two options in front of the
designer whether to use a DC motor or a stepper motor. When it comes to speed, weight, size,
cost... DC motors are always preferred over stepper motors. There are many things which you
can
do with your DC motor when interfaced with a microcontroller. For example you can
control the speed of motor, you can control the direction of rotation, you can also do
encoding of the rotation made by DC motor i.e. keeping track of how many turns are made

by
your motors etc. So you can see DC motors are no less than a stepper motor.


In this part of tutorial we will learn to interfacing a DC motor with a microcontroller. Usually
H
-
bridge is preferred way of interfacing a DC motor. These days many IC manuf
acturers
have H
-
bridge motor drivers 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 i
s sometimes not required so
using a small 16 pin IC is preferred for this purpose.



Working Theory of H
-
Bridge



The name "H
-
Bridge" is derived from the actual shape of the switching circuit which control
the motoion of the motor. It is also known as "Fu
ll Bridge". Basically there are four switching
elements in the H
-
Bridge as shown in the figure below.




Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


25

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 Power supply through
the motor coil goes to ground vi
a 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. W
e
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 trasistors as well as MOSFETs, the
only thing is the power handling capacity of the circuit. If motors are needed to run with high
curre
nt 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 diag
ram, 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. Both of them are discussed in the
next section of the tutorial.

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


26



BJT H
-
Bridge


A simple H
-
bridge can be made with the help of Power BJTs like TIP31 and TIP32. An
example and a working demo of this circuit is shown in the figure below.








►BJT H
-
Bridge Demo


Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


27




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 the you can make use of all the four I/Os to connect up to

four DC motors. L293D has output current of 600mA and peak output current of 1.2A per
channel. Moreover for protection of circuit from back EMF ouput 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.




3.4

7805 VOLTAGE REGULATOR



7805 is a voltage regulator integrated circuit. It is a member of 78xx series of fixed linear
voltage regulator ICs. The voltage source in a circuit may have fluctuations and wou
ld not
give the fixed voltage output. The voltage regulator IC maintains the output voltage at a
constant value. The xx in 78xx indicates the fixed output voltage it is designed to provide.
7805 provides +5V regulated power supply. Capacitors of suitable v
alues can be connected at
input and output pins depending upon the respective voltage levels.




Pin Diagram:



Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


28









Pin Description:



Pin No

Function

Name

1

Input voltage (5V
-
18V)

Input

2

Ground (0V)

Ground

3

Regulated output; 5V (4.8V
-
5.2V)

Outpu
t





3.5


IR SENSOR


(IR) light radiating from objects in its field of view. PIR sensors are often used in the
construction of
PIR
-
based motion detectors

(see below). Apparent motion is detected when
an infrared source with one temperature, such as a hum
an, passes in front of an infrared
source with another temperature, such as a wall.

All objects emit what is known as black body radiation. It is usually infrared radiation that is
invisible to the human eye but can be detected by electronic devices desig
ned for such a
purpose. The term
passive

in this instance means that the PIR device does not emit an
infrared beam but merely passively accepts incoming infrared radiation. “Infra” meaning
below our ability to detect it visually, and “Red” because this col
or represents the lowest
energy level that our eyes can sense before it becomes invisible. Thus, infrared means below
the energy level of the color red, and applies to many sources of invisible energy.

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


29



The IR range falls between the
visible portion of
the spectrum
and radio w
aves. IR
wavel
engths are usually expressed in
microns, with the lR spec
trum extending from 0.7 to
1000
microns. Only the 0.
7
-
14 micron band is used for IR
temperature measurement.

Using advanced optic syste
ms and detectors, nonconta
ct IR
thermometers can focus on

nearly
any portion or portions
of the0.7
-
14 micron band.

Because every object (with the
exception
of a blackbody
) emits an optimum amount of IR
energy at a specific point
along the IR band,
each process
may require unique se
nsor models with specifi
c optics and
detector types.

For example, a sensor with a narrow spectral range centered

at 3.43 microns is optimized for



measuring the surface
temperature of polyethylene and related materials. A sensor

set up for 5 microns is u
sed to measure glass surfac
es. A 1
micron sensor is used fo
r metals
and foils. The broader
spectral ranges are us
ed to measure lower temperature
surfaces, such
as paper, board, poly, and foil composites.







The intensity of an object's

emitted IR energ
y increases or
decreases in proportion to its

temperature. It is the emitted
energy, measured as the target's emissivity, that indicates

an object's temperature.

Emissivity is a term used to quantify the energy
-
emitting

characteristics of different mat
eria
ls and surfaces. IR sensors
have adjustable emissivity
set
tings, usually from 0.1 to 1.0,
which allow accurate temperature measurements of several

surface types.

The emitted energy comes

from an object and reaches the
IR sensor through its
op
tical system,
which focuses the
energy onto one or more photosensitive detectors. The

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


30

detector then converts t
he IR energy into an electrical
signal, which is in turn con
verted into a
temperature value
based on the sensor's calibr
ation equation and the target's
emissivi
ty. This
temperatur
e value can be displayed on the
sensor, or, in the case of

the smart sensor,
converted to
a digital output and displayed on a computer terminal.




3.6

LM358


The LM358 is a great, easy
-
to
-
use dual
-
channel opamp. Opamps have so many appl
ications
we figured we should probably carry at least one in a DIP package. LM358 applications
include transducer amplifiers, DC gain blocks and all the conventional opamp circuits.If
you're looking for a good, standard opamp the LM358 should fill most of
your needs. It can
handle a supply of 3
-
32VDC and source up to 20mA per channel. This opamp is great if you
need to operate two individual opamps from a single power supply. Comes in an 8
-
pin DIP
package.











Features



-
Bump micro S
MD chip sized package, (See AN
-
1112)







supplies: ±1.5V to ±16V

-
essentially independent of supply voltage


-
mode voltage range includes ground

ply voltage



Description


The LM158 series consists of two independent, high gain, internally frequency compensated
operational amplifiers which were designed specifically to operate from a single power
supply over a wide ra
nge of voltages. Operation from split power supplies is also possible
and the low power supply current drain is independent of the magnitude of the power supply
voltage.

Application areas include transducer amplifiers, dc gain blocks and all the convention
al op
amp circuits which now can be more easily implemented in single power supply systems. For
example, the LM158 series can be directly operated off of the standard +5V power supply

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


31


voltage which is used in digital systems and will easily provide the r
equired interface
electronics without requiring the additional ±15V power supplies.











4. Software Description


Software used in our project is keil. Its details are as follows:


4.1 Keil Mic
roVision3


Introduction:


Keil development tools for the 8051 Microcontroller Architecture support every level
of software developer from the professional applications engineer to the student just learning
about embedded software development.


The industry
-
standard Keil C Compilers, Macro Assemblers, Debuggers, Real
-
time Kernels,
Single
-
board Computers, and Emulators support all 8051 derivatives and help you get your
projects completed on schedule


The Keil 8051 Development Tools are designed to solve the c
omplex problems facing
embedded software developers.









When starting a new project, simply select the microcontroller you use from the
Device Database and the µVision IDE sets all compiler, assembler, linker, and
memory options for you.

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


32



Numerous exa
mple programs are included to help you get started with the most
popular embedded 8051 devices.



The Keil µVision Debugger accurately simulates on
-
chip peripherals (I²C, CAN,
UART, SPI, Interrupts, I/O Ports, A/D Converter, D/A Converter, and PWM
Modules)
of your 8051 device. Simulation helps you understand hardware
configurations and avoids time wasted on setup problems. Additionally, with
simulation, you can write and test applications before target hardware is available.



When you are ready to begin test
ing your software application with target hardware,
use the MON51, MON390, MONADI, or FlashMON51 Target Monitors, the ISD51
In
-
System Debugger, or the ULINK USB
-
JTAG Adapter to download and test
program code on your target system.

The µVision3 IDE is a Win
dows
-
based software development platform that combines a
robust editor, project manager, and make facility. µVision3 integrates all tools including the
C compiler, macro assembler, linker/locator, and HEX file generator.


µVision3 helps expedite the devel
opment process of your embedded applications by
providing the following:



Full
-
featured source code editor,



Device database for configuring the development tool setting,



Project manager for creating and maintaining your projects,



Integrated make facility

for assembling, compiling, and linking your embedded
applications,



Dialogs for all development tool settings,



True integrated source
-
level Debugger with high
-
speed CPU and peripheral simulator,



Advanced GDI interface for software debugging in the targe
t hardware and for
connection to Keil ULINK,



Flash programming utility for downloading the application program into Flash ROM,



Links to development tools manuals, device datasheets & user’s guides.




The µVision3 IDE offers numerous features and advanta
ges that help you quickly and
successfully develop embedded applications. They are easy to use and are guaranteed to help
you achieve your design goals.

The
µVision3 IDE and Debugger

is the central part of the Keil development tool chain.
µVision3 offers a

Build Mode

and a
Debug Mode
.

In the µVision3
Build Mode

you maintain the project files and generate the application.

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


33

In the µVision3
Debug Mode

you verify your program either with a powerful CPU and
peri
pheral simulator or with the
Keil ULINK USB
-
JTAG Adapter

(or other AGDI drivers)
that connect the debugger to the target system. The ULINK allows you also to download your
application into Flash ROM of

your target system.


Description


Keil Software development tools are used to create products for practically every industry:
consumer electronics, industrial control, networking, office automation, automotive, space
exploration. Micro Vision Two is a se
cond generation IDE that simplifies project
development and application testing. With Micro Vision Two, we can easily create
embedded applications in a mixture of C and assembly. Real
-
time applications benefit from
our highly optimized C libraries and re
al
-
time kernels.

MicroVision3 provides a centralized front
-
end interface for the compiler, assembler, linker,
debugger, and other development tools. The Project Window in MicroVision3 displays the
current target, groups, and source files that comprise our
project. Rather than creating a single
target for each project, MicroVision2allows multiple targets for each project file. So, with a
single project file, we can create a target for simulating, a target for our emulator, and a
production target for progra
mming into EPROM {E
-
PROM}.



Each target is composed of one or more groups which are in turn composed of one or
more source files. Groups let us divide the source files into functional blocks or assign
source files to different team members. Options may b
e configured at each level of the
project. This gives us a great deal of freedom and flexibility when organizing our
application. In addition to the on
-
line help, MicroVision3 provides on
-
line versions of the
development tool manuals as well as the device

manuals.

Keil C Compilers are based on the ANSI standard and include extensions necessary to
support the 8051, 251, and 166 microcontroller families. The optimizer in our compiler is
tuned for each specific architecture and provides the highest level o
f code density and
execution speed.

The Keil C compilers give full us control over our embedded platform. We decide which
register banks are used, when to access certain memory areas, which variables are stored in
bits, when and how to use special functio
n registers, and so on. Without ever writing any
assembly code we may even write interrupt service routines in C. Code generated by the Keil
C Compiler compares with that of a professional assembly programmer. This is due to the
level of optimizations th
at are performed. One such optimization is global register
optimization.


By analyzing which registers are used in each function, the compiler can better optimize
register usage program
-
wide and generate smaller, faster programs. This is accomplished by
iterative compilation steps during the make process.

The MicroVision3 debugger is designed to make testing your programs as efficient as
possible. While editing and debugging your programs, text and code attributes are displayed
in the source window. As y
ou step through your program, the current line is marked with a
yellow arrow. Code coverage shows you which lines of your program have been executed.
Green means the line has been run. Grey means is has not.



Breakpoints are clearly marked in the source

window. Red for enabled, white for
disabled. These attributes make following program flow easier than ever. The features of the
Micro Vision Two debugger don’t stop there. When simulating your programs, you not only
get source
-
level, symbolic simulation
. You also get on
-
chip peripheral simulation. Dialog
boxes display the condition of all peripherals and on
-
chip components.

Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


34



5. Source Code




ORG 0000H


MOV P1,#0FFH


MOV P2,
#00H

BACK: MOV A,P1


CJNE A,#0FEH, L1


ACA
LL DELAY


MOV P2, #05H


ACALL DELAY


SJMP BACK

L1: CJNE, #0FDH, L2


ACALL DELAY


MOV P2, #0AH


ACALL DELAY


SJMP BACK

L2: NOP


SJMP BACK



DELAY: MOV R
2, #255

AGAIN: MOV R
1,#255

HERE: D
JNZ R1, HERE


DJNZ R2, AGAIN


RET


END













Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


35




Snapshot of the Project

























Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


36



Cost of components




Component

Cost

1.

89S52


2. 7805


3. LM358


4. L293D


5.


Crystal oscillator


6.

IR sensors





























Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


37




Limitation of the project


Existing System:
-

1. Manual/Physical gate closing & opening.

2. Manual switch based gate closing & opening.



Limitations of existing system:
-

1. Cha
nces of human error.

2. Time consuming.

3. A lot of human resource is required.



Features of Proposed System:
-

1. The system will consist of 2 IR trans
-
receiver pairs.

2. Micro controller based circuit design.

3. Automatic train sensing & gate controlling
.

4. Bidirectional gate controlling or Bidirectional train sensing.

5. If required PC based GUI for better interface.

6. The gate will be closed till the whole train passes out.

7. The opening of gate will be sensor based not delay based.


Limitation
:


In
this project sensors are placed on two sides of the track an when tarin comes the two
sensors get disconnected which gives signal to controller and if any obstacle comes
inbetween the track then also the signal will go to the controller which can create
in
convenience to the road users.

Moreover we are using wired system in this project so further project can be improved by
using wireless system.



Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


38



Future Enhancement


This paper has satisfactorily fulfilled the basic things such as p
revention of accidents inside
the gate and the unnecessary of a gatekeeper. But still the power supply for the motor
operation and signal lights. It can be avoided and a battery charged by means of a solar cell. It
can be used directly during the daytime a
nd by charging the battery during night. Hence this
arrangement can be used in remote areas where the power supply can’t be expected. The
obstacle detection part can be implemented using Fuzzy logic. As it thinks in different angles
or aspects, the system
works still more efficiently.



Conclusion


The idea of automating the process of railway gate operation in level crossings has been
undertaken. 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
89C51 performs the complete operation i.e., sensing ,gate closing and opening operation is
done by softw
are coding written for the controller. The mechanism works on a simple
principle and there is not much of complexity needed in the circuit.













Automatic Railway Gate Control

Lov ely Prof essional Uni
v ersity Punjab


39



References