Automatic Railway Gate Control
Automatic Railway Gate Control
Automatic Railway Gate Control
ACKNOWLEDGEMENT
By,
G.Valarumathi,
P.Valarmathi,
M.Vasanthamani,
3
CONTENTS
NO. NO.
1 ABSTRACT 4
3 CIRCUIT DIAGRAM 8
4 CIRCUIT DESCRIPTION 9
5 HARDWARE DESCRIPTION
a 1.PIC 16F873 10
b 2.STEPPER MOTOR 12
c 3.SENSORS 18
d 5.OTHERS 20
6 COMPONENT SPECIFICATIONS
7 APPLICATIONS
8 DETAILED BUDGET
9 BIBILIOGRAPHY
4
CHAPTER-1
ABSTRACT
Railways being the cheapest mode of transportation are preferred over all the
other means .When we go through the daily newspapers we come across many
railway accidents occurring at unmanned railway crossings. This is mainly
due to the carelessness in manual operations or lack of workers. We, in this
project have come up with a solution for the same. Using simple electronic
components we have tried to automate the control of railway gates. As a train
approaches the railway crossing from either side, the sensors placed at a
certain distance from the gate detects the approaching train and accordingly
controls the operation of the gate. Also an indicator light has been provided to
alert the motorists about the approaching train.
5
. CHAPTER-2
BLOCK DIAGRAM & DESCRIPTION
6
This project use PIC16F873 microcontroller for programming and operation along
withULN2003 driver.
To avoid these ripples, the output of the rectifier is connected to filter. But
the controller operates at 5V dc and the relays and driver operates at 12V dc
voltage. So the regulator is required to reduce the voltage. Regulator 7805
produces 5V dc and regulator 7812 produces 12V dc. Both are positive ULN2003
the current driver chip. The supply of 12v is given to drive the stepper motor for
the purpose of gate control
7
OPERATION:
The above figure shows the view model of the project.This project utilizes two
powerful IR transmitters and two receivers; one pair of transmitter and receiver is
fixed at up side (from where the train comes) at a level higher than a human being
in exact alignment and similarly the other pair is fixed at down side of the train
direction. Sensor activation time is so adjusted by calculating the time taken at a
certain speed to cross at least one compartment of standard minimum size
The gate controlling unit consists of two pairs of infrared sensors placed at two
sides of gate. They should keep at a distance of 9 cm (2km in usual case) from the
gate. and a stepper motor is used for the purpose of the gate closing and opening.
Interfaced to the ULN2003.
When train reaches the sensor, it is detected by IR sensors placed 9 cm before the
station and led in the sensor will glow because the 555 timer works into quasi state
of operation. such that the IR LED should glow till the timer works in quasi state
i.e., when train passes away the sensors it again into normal state then it receives
5v at terminals that pin at the PIC 16F873 terminal goes high which enables the
8
power to the stepper motor to rotate in steps which drives gate to close similarly
when it reaches the second pair of sensors it senses and send the signal to the
microcontroller to enable the current driver to open the gate by rotating the stepper
motor in steps to get back in to original position
Signals are placed near gate each at a specified distance. Train may be approaching
gate at either direction so all four signals are made RED initially to indicate gate is
OPENED and vehicles are going through gate. The road user signals are made
GREEN so that they freely move through gate. Buzzer is OFF since there is no
approach of train and users need not be warned.
10
CHAPTER-3
CIRCUIT DIAGRAM
11
CHAPTER-4
CIRCUIT DIAGRAM DESCRIPTION
The supply +5v is given to the pin no.20 of PIC 16F73. The crystal oscillator of
4Mhz is connected to the pins 9 & 10 with two capacitors of 22pF in parallel. The
reset switch is connected to the port A, first pin with the supply of 5v. The 8th &
19th pins are grounded. The two sensors IR1 & IR2 are connected to the port C ,1st
& 2nd pins(11th & 12th pins). The input pins 1,2,3 &4 0f ULN2003A are connected
to port C – 7,6,5 & 4th (18,17,16 & 15th pins) pins correspondingly. The buzzer is
connected to the port B – 1st pin(21st pin). The LEDs indicating the traffic signals
are connected to port B – 2nd & 3rd pins(22 & 23rd pins).
WORKING:
Initially the green signal glows, allowing the road users to cross the track.
When train arrives between the transmitter & receiver of a sensor1 which is
mounted on sides of the track few meters infront of the gate ,the sensor output
goes low. As a result the PIC controller energises the stepper motor to rotate 90◦
forward which closes the gate. Simultaneously green signal turns OFF and red
signal begins to glow. The buzzer beeps for three times indicating the closure of
the gate. When the train reaches the sensor2 mounted on the sides of the track a
few meters behind the gate the sensor output goes low. The PIC waits until the
sensor2 output goes high again. Then it energises the stepper motor to rotate 90◦
reverse. So the gate opens and the green signal begin to glow, switching OFF the
red signal. Thus the circuit works.
12
CHAPTER-5
HARDWARE DESCRIPTION
5a. PIC 16F873
PIN DIAGRAM:
13
PIN DESCRIPTION:
14
5b.INFRARED SENSORS
Overview
The solution proposed doesn't contain any special components, like photo-diodes, photo-transistors, or IR receiver ICs, only a couple if IR leds, an
Op amp, a transistor and a couple of resistors. In need, as the title says, a standard IR led is used for the purpose of detection. Due to that fact, the
15
circuit is extremely simple, and any novice electronics hobbyist can easily understand and build it.
It is the same principle in ALL Infra-Red proximity sensors. The basic idea is to send infra red light
through IR-LEDs, which is then reflected by any object in front of the sensor.
schematic, we are going to use a Op-Amp (operational Amplifier) to accurately detect very small voltage changes.
Two different designs are proposed, each one of them is more suitable for different applications. The
main difference between the 2 designs is the way infra-red (IR) light is sent on the object. The receiver
part of the circuit is exactly the same in both designs.
Note: Both the sender and the receiver are constructed on the same board. They are separated in the
schematics for simplification.
As the name implies, the sensor is always ON, meaning that the IR led is constantly emitting light. this
design of the circuit is suitable for counting objects, or counting revolutions of a rotating object, that may be of the
order of 15,000 rpm or much more. However this design is more power consuming and is not optimized for high ranges. in this design, range can be
from 1 to 10 cm, depending on the ambient light conditions.
detected using an Op-Amp (operational Amplifier LM358). You will have to adjust the variable resistor
(POT.) R8 so the the voltage at the positive input of the Op-Amp (pin No. 5) would be somewhere near 1.6
Volt. if you understand the functioning of Op-Amps, you will notice that the output will go High when the
volt at the cathode of D1 drops under 1.6. So the output will be High when IR light is detected, which is
the purpose of the receiver.
In case you're not familiar with op-amps, here is shortly and in a very simplified manner, what you need
to know to understand how this sensor functions: The op-amp has 2 input, the +ve input, and the -ve
17
input. If the +ve input's voltage is higher than the -ve input's voltage, the output goes High (5v, given
the supply voltage in the schematic), otherwise, if the +ve input's voltage is lower than the -ve input's
voltage, then the output of the Op-Amp goes to Low (0V). It doesn't matter how big is the difference
between the +ve and -ve inputs, even a 0.0001 volts difference will be detected, and the the output will
swing to 0v or 5v according to which input has a higher voltage.
In this design, which is oriented to obstacle detection in robots, our primary target is to reach high ranges,
from 25 to 35 cm, depending on ambient light conditions. The range of the sensor is extended by
increasing the current flowing in the led. This is a delicate task, as we need to send pulses of IR instead of
constant IR emission.The duty cycle of the pulses turning the LED ON and OFF have to be calculated with
precision, so that the average current flowing into the LED never exceeds the LED's maximum DC current
(or 10mA as a standard safe value).
previous cycle.
Now, hands on the circuit that will put all this theory into practice. The CTRL input in the figure, stands
for Control, and this pin should be connected to the source of the low duty cycle pulses discussed above,
whether it is a microcontroller or an LM555 timer that generates the pulses.
The calculations yielded that a 10 ohm resistor is series with the LED D2, would cause a current of
approximately 250 mA to flow through the LED. A current this high, would destroy the LED if applied for a
long period of time (some dozens of seconds), this is why we have to send low duty cycle pulses.
The first Op-amp will provide voltage buffer, to enable any kind of device to control the
20
When the sensor is controlled by a microcontroller to generate the low duty cycle pulses, you can benefit
from the High and Low pulses to be able to detect any false readings due to ambient light. This is done by
recording 2 different outputs of the sensor, one of them during the ON pulse (the sensor is emitting infra
red light) and the other during the OFF time. and compare the results.
21
#include <REGX51.h>
#include <math.h>
unsigned int i;
for(i=0;i<y;i++){;}
}
void main(){
//P2.0 IR control pin going to the sensor
//P2.1 IR output pin coming from the sensor
while(1){
P2_0 = 1; //send IR
delay(20);
ir1 = P2_1;
P2_0 = 0; //stop IR
delay(98);
ir2 = P2_1;
Components positioning:
23
The correct positioning of the sender LED, the receiver LED with regard to each other and to the Op-Amp
can also increase the performance of the sensor. First, we need to adjust the position of the sender LED
with respect to the receiver LED, in such a way they are as near as possible to each others , while
preventing any IR light to be picked up by the receiver LED before it hit and object and returns back. The easiest
way to do that is to put the sender(s) LED(s) from one side of the PCB, and the receiver LED from the other side, as shown in the 3D model below.
Another important issue about components positioning, is the distance between the receiver LED and the Op-Amp. which should be as small as
possible. Generally speaking, the length of wires or PCB tracks before an amplifier should be reduced, otherwise, the amplifier will amplify - along
with the original signal - a lot of noise picked up form the electromagnetic waves traveling the surrounding.
Here is an example PCB where the distance between the LED and the Op-
Amp is shown. Sure this distance is not as critical as you may think, it can be
up to 35mm without causing serious problems, but trying to reduce this
distance will Always give you better results.
Actually, when I design the PCB, I start by placing the receiver LED and the
Op-Amp, as near to each others as possible, then continue the rest of the
design.
24
Here is an example construction of the PCB for the High Range, Pulsed IR proximity sensor.
You can download here the project folder containing the schematic, the PCB design, and an example
code for 8051 microcontroller to send the low duty cycle pulses.
The last step, is to test the performance of the pulsed IR proximity sensor. To do this, I connected the sensor to a 89S52 microcontroller, loaded with
a program to generate pulses with a duty cycle of approximately 1.6. at a frequency of 3Khz. LEDs are deigned to operate at very high frequencies,
so you don't have to worry about the response time. To make sure your duty cycle calculations are correct, let the sensor running for a minute, and
check with your fingers the temperature of the IR sender LED. If its not hot, then everything is alright. On the other hand, if the LED is getting hot, to
an extent that you can feel it, there is probably something wrong, you should then try to decrease the duty cycle, or increase the series resistor, in
order to decrease the average current flowing into the LED.
Then, you can start testing the range of the sensor, and experiment it in different ambient light conditions, but the potentiometer may have to be
adjusted carefully, to cope with ambient light.
25
In the example C code above, the final output of the sensor appears on the pin P2_3 of the
microcontroller, as explained before.
26
5b.STEPPER MOTOR
Description:
Fundamentals of Operation :
Stepper motors operate differently from normal DC motors, which rotate when
voltage is applied to their terminals. Stepper motors, on the other hand, effectively
have multiple "toothed" electromagnets arranged around a central gear-shaped
piece of iron. The electromagnets are energized by an external control circuit, such
as a microcontroller. To make the motor shaft turn, first one electromagnet is given
power, which makes the gear's teeth magnetically attracted to the electromagnet's
teeth.
27
When the gear's teeth are thus aligned to the first electromagnet, they are slightly
offset from the next electromagnet. So when the next electromagnet is turned on
and the first is turned off, the gear rotates slightly to align with the next one, and
from there the process is repeated. Each of those slight rotations is called a "step,"
with an integral number of steps making a full rotation. In that way, the motor can
be turned by a precise angle. 7.5.3 Stepper motor characteristics
Stepper motors are constant power devices. As motor speed increases, torque
decreases. The torque curve may be extended by using current limiting drivers and
increasing the driving voltage. Steppers exhibit more vibration than other motor
types, as the discrete step tends to snap the rotor from one position to another. This
vibration can become very bad at some speeds and can cause the motor to lose
torque. The effect can be mitigated by accelerating quickly through the problem
speed range, physically damping the system, or using a micro-stepping driver.
Motors with a greater number of phases also exhibit smoother operation than those
with fewer phases.
Steppers are generally commutated open loop, i.e. the driver has no feedback on
where the rotor actually is. Stepper motor systems must thus generally be over
engineered, especially if the load inertia is high, or there is widely varying load, so
that there is no possibility that the motor will lose steps. This has often caused the
system designer to consider the trade-offs between a closely sized but expensive
servomechanism system and an oversized but relatively cheap stepper.
An advance on this technique is to normally run the motor in open loop mode, and
only enter closed loop mode if the rotor position error becomes too large -- this
will allow the system to avoid hunting or oscillating, a common servo problem.
Types:
There are two basic winding arrangements for the electromagnetic coils in a
Unipolar motors :
A unipolar stepper motor has logically two windings per phase, one for each
direction of magnetic field. Since in this arrangement a magnetic pole can be
reversed without switching the direction of current, the commutation circuit can be
made very simple (e.g. a single transistor) for each winding. Typically, given a
phase, one end of each winding is made common: giving three leads per phase and
six leads for a typical two phase motor. Often, these two phase commons are
internally joined, so the motor has only five leads.
29
Unipolar stepper motor coils In the construction of unipolar stepper motor there
are four coils. One end of each coil is tide together and it gives common terminal
which is always connected with positive terminal of supply. The other ends of each
coil are given for interface. Specific color code may also be given. Like in my
motor orange is first coil (L1), brown is second (L2), yellow is third (L3), black is
fourth (L4) and red for common terminal.
To vary the RPM of motor we have to vary the PRF (Pulse Repetition Frequency).
Number of applied pulses will vary number of rotations and last to change
direction we have to change pulse sequence.
So all these three things just depends on applied pulses. Now there are three
different
Unipolar stepper motors with six or eight wires may be driven using bipolar drivers
by leaving the phase commons disconnected, and driving the two windings of each
phase together [diagram needed]. It is also possible to use a bipolar driver to drive
only one winding of each phase, leaving half of the windings unused [diagram
needed].
Bipolar motor :
30
Bipolar motors have logically a single winding per phase. The current in a winding
needs to be reversed in order to reverse a magnetic pole, so the driving circuit must
be more complicated, typically with an H-bridge arrangement.
There are two leads per phase, none are common. Static friction effects using an H-
bridge have been observed with certain drive topologies Because windings are
better utilized, they are more powerful than a unipolar motor of the same weight.
8-lead stepper:
An 8 lead stepper is wound like a unipolar stepper, but the leads are not joined to
common internally to the motor. This kind of motor can be wired in several
configurations:
• Unipolar.
• Bipolar with series windings. This gives higher inductance but lower current per
winding.
• Bipolar with parallel windings. This requires higher current but can perform
better
• Bipolar with a single winding per phase. This method will run the motor on only
half the available windings, which will reduce the available low speed torque but
require less current.
Theory :
A step motor can be viewed as a synchronous AC motor with the number of poles
(on both rotor and stator) increased, taking care that they have no common
denominator. Additionally, soft magnetic material with many teeth on the rotor and
stator cheaply multiplies the number of poles (reluctance motor). Modern steppers
are of hybrid design, having both permanent magnets and soft iron cores.
31
To achieve full rated torque, the coils in a stepper motor must reach their full rated
current during each step.
Winding inductance and reverse EMF generated by a moving rotor tend to resist
changes in drive current, so that as the motor speeds up, less and less time is spent
at full current -- thus reducing motor torque. As speeds further increase, the current
will not reach the rated value, and eventually the motor will cease to produce
torque.
Pull-in torque :
This is the measure of the torque produced by a stepper motor when it is operated
without an acceleration state. At low speeds the stepper motor can synchronize
itself with an applied step frequency, and this Pull-In torque must overcome
friction and inertia.
Pull-out torque :
The stepper motor Pull-Out torque is measured by accelerating the motor to the
desired speed and then increasing the torque loading until the motor stalls or "pulls
Out of synchronism" with the step frequency. This measurement is taken across a
wide range of speeds and the results are used to generate the stepper motor's
dynamic performance curve. As noted below this curve is affected by drive
voltage, drive current and current switching techniques. It is normally
recommended to use a safety factor of between 50% and 100% when comparing
your desired torque output to the published "pull-Out" torque performance curve of
a step motor.
Detent torque :
when not driven electrically. Soft iron reluctance cores do not exhibit this
behavior.
A stepper's low speed torque will vary directly with current. How quickly the
torque falls off at faster speeds depends on the winding inductance and the drive
circuitry it is attached to, especially the driving voltage.
circuitry. It is not guaranteed that you will achieve the same performance given
different drive circuitry, so the pair should be chosen with great care. Fig 7.5.6.0
RPM calculation:-
One can calculate the exact RPM at which motor will run. We know that motor
needs 200 pulses to complete 1 revolution. Means if 200 pulses applied in 1 second
motor will complete 1 revolution in 1 second. Now 1 rev. in 1 sec means 60 rev. in
1 minute. That will give us 60 RPM. Now 200 pulses in 1 sec means the PRF is
200 Hz. And delay will be 5 milli second (ms). Now let’s see it reverse.
Applications
2. Industrial applications are in high speed pick and place equipment and multi-
axis machine CNC machines often directly driving lead screws or ball screws.
3. In the field of lasers and optics they are frequently used in precision positioning
equipment such as linear actuators, linear stages, rotation stages, goniometers, and
mirror mounts.
4, Other uses are in packaging machinery, and positioning of valve pilot stages for
fluid control systems.
5. Commercially, stepper motors are used in floppy disk drives, flatbed scanners,
computer printers, plotters and many more devices.
34
Introduction:
1. IR transmitter circuit
2. IR receiver unit
35
5d.OTHERS
ULN 2003A
Relay drivers
Introduction:
IC, ULN2003A description:
• Case Style:DIP-16
• Base Number:2003
• IC Generic Number:2003
These versatile devices are useful for driving a wide range of loads
including solenoids, relays DC motors; LED displays filament lamps, thermal print
heads and high power buffers. The ULN2001A/2002A/2003A and 2004A are
supplied in 16 pin plastic DIP packages with a copper lead frame to reduce thermal
resistance. They are available also in small outline package (SO-16) as
ULN2001D/2002D/2003D/2004D.
37
STEPDOWN TRANSFORMER :
The Step down Transformer is used to step down the main supply voltage
from 230V AC to lower value. This 230 AC voltage cannot be used directly, thus it
is stepped down. The Transformer consists of primary and secondary coils. To
reduce or step down the voltage, the transformer is designed to contain less number
of turns in its secondary core. The output from the secondary coil is also AC
waveform. Thus the conversion from AC to DC is essential. This conversion is
achieved by using the Rectifier Circuit/Unit.
RECTIFIER UNIT:
The Rectifier circuit is used to convert the AC voltage into its corresponding
DC voltage. There are Half-Wave, Full-Wave and bridge Rectifiers available for
this specific function. The most important and simple device used in Rectifier
circuit is the diode. The simple function of the diode is to conduct when forward
biased and not to conduct in reverse bias. The Forward Bias is achieved by
connecting the diode’s positive with positive of the battery and negative with
battery’s negative. The efficient circuit used is the Full wave Bridge rectifier
circuit. The output voltage of the rectifier is in rippled form, the ripples from the
obtained DC voltage are removed using other circuits available. The circuit used
for removing the ripples is called Filter circuit.
38
INPUT FILTER:
Capacitors are used as filter. The ripples from the DC voltage are removed and
pure DC voltage is obtained. And also these capacitors are used to reduce the
harmonics of the input voltage. The primary action performed by capacitor is
charging and discharging. It charges in positive half cycle of the AC voltage and it
will discharge in negative half cycle. So it allows only AC voltage and does not
allow the DC voltage. This filter is fixed before the regulator. Thus the output is
free from ripples.
REGULATOR UNIT
Regulator regulates the output voltage to be always constant. The output voltage is
maintained irrespective of the fluctuations in the input AC voltage. As and then the
AC voltage changes, the DC voltage also changes. Thus to avoid this Regulators
are used. Also when the internal resistance of the power supply is greater than 30
ohms, the output gets affected. Thus this can be successfully reduced here. The
regulators are mainly classified for low voltage and for high voltage. Further they
can also be classif
i) Positive regulator
1---> input pin 2---> ground pin 3---> output. It regulates the positive volt
OUTPUT FILTER:
The Filter circuit is often fixed after the Regulator circuit. Capacitor is most
often used as filter. The principle of the capacitor is to charge and discharge. It
charges during the positive half cycle of the AC voltage and discharges during the
negative half cycle. So it allows only AC voltage and does not allow the DC
voltage. This filter is fixed after the Regulator circuit to filter any of the possibly
found ripples in the output received finally. Here we used 0.1µF capacitor. The
output at this stage is 5V and is given to the Microcontroller
39
CHAPTER-6
COMPONENT SPECIFICATIONS
CHAPTER-7
APPLICATIONS
4. This circuit can be expanded and used in a station with any number of
platforms as per the usage.
7. Each Level crossing should be assigned a hazard rating and the priority
of safety enhancement works be decided accordingly.
CHAPTER-8
DETAILED BUDGET
CHAPTER-9
BIBLIOGRAPHY
SITES:
1.www.google.com
2.www.scribd.com
44