Automatic Railway Gate Control Using Arduino Uno11
Automatic Railway Gate Control Using Arduino Uno11
Arduino Uno
A PROJECT REPORT
Submitted by
------------------------------
------------------------------
------------------------------
------------------------------
A comprehensive project report has been submitted in partial fulfillment of the
requirements for the degree of
Bachelor of Technology
In
--------------
Assistant Professor
Date:
Place:
CERTIFICATE OF APPROVAL
This is to certify that the project titled “Automatic Railway Gate Control Using
Arduino Uno” carried out by
For the partial fulfillment of the requirements for Mini Project in B. E degree in
Electronics and Communication Engineering from Dr. G. U. Pope College of
Engineering, Sawyerpuram is absolutely based on his own work under the
supervision of ------------. The contents of this thesis, in full or in parts, have not
been submitted to any other Institute or University for the award of any degree or
diploma.
......................................................... .........................................................
----------------------------- ----------------------------
DECLARATION.................................................................................................... 3
CERTIFICATE OF APPROVAL…………………………………………………4
ABSTRACT ………………………………………………………………........... 5
CONTENTS…….................................................................................................... 6
LIST OF FIGURES……………………………………………………………….7
LIST OF TABLE………………………………………………………………….8
INTRODUCTION………………………………………………………………..10
1. OBJECTIVE……………………………………………………………
2. RELATED WORK…………………………………………………….
BLOCK DIAGRAM………………………………………………………….
CIRCUIT DIAGRAM………………………………………………………….
WORKING…………………………………………………………………….
CODING……………………………………………………………………….
1. Coding Explanation…………………………………………………….
Description of Components………………………………………………………
1. Arduino Uno………………………………………………………
2. H-Bridge Motor Driver………………………………………………
3. IR Sensor Module………………………………………………
4. DC Motor………………………………………………
5. Battery………………………………………………
6. Software………………………………………………
FUTURE SCOPE……………………………………………………………….
PROBLEMS ………………………………………………
DISCUSSION………………………………………………
APPLICATIONS………………………………………………
CONCLUSION ………………………………………………
COST ANALISIS………………………………………………
LIST OF FIGURES
Fig 1. Circuit Diagram of prototype
Fig 2. Arduino UNO R3
Fig 3. Atmel mega 328P
Fig 4. Motor Driver Circuit
Fig 5. LM 358 IC
Fig 6. LM 358 IC internal Circuitry
Fig 7. IR LED
Fig 8. Photodiode
Fig 9. IR sensor Module circuit
Fig 10. IR sensor Module
Fig 11. DC Motor
Fig 12. 9V Battery
Fig 13. Arduino IDE
LIST OF TABLES
1. Objective:
The objective of this project is to create an automatic railway gate control system
which can be implemented easily in roads. Generally there are manual gate control
system which are maintained by person. As vehicles are increasing day by day it
has become more difficult to control the gate manually. As a result often accident
occurs and many people become injured badly and sometimes it become very
serious when people died due to this type of accidents. This project can help us to
reduce accidents in our country by introducing automatic railway gate control
system.
2. Related work
Earlier opening/closing of crossing gates were fully controlled by gatekeeper. The
method was that when train departs from any station a controller or a station master
was used to call to contact the gatekeeper and inform the gatekeeper about the
departure. On receiving the message, the gatekeeper closes the gate by calculating
the time from station to the gate. However, the gate remains closed for long time
even if the train is late for some reasons. This can be eliminated by using an
automatic railway gate control which uses a sensor near to the railway gate that
detects the arrival of a train and closes the gate. Note this requires very less time
compare to manual operation of the gates and reduces the manpower. The Proposed
model to automatically control the crossing gateway helps in achieving the safety
and to prevent accidents at the unmanned level crossings. The Automatic railway
gate system can be employed in an unmanned level crossing where the chances of
accidents are higher and reliable operation is required. Since, the proposed system
is automatic, it helps in reducing the error which is in manual operation and it can
be used as high reliable source.
Block diagram
CIRCUIT DIAGRAM
WORKING
In this proposed model we use USB cable to connect the Arduino Uno to the PC
that will supply the power Arduino Uno and the sensors are powered by 9v battery.
After this Supply is given to ARDUINO the servo motor/DC motor and IR sensor
are controlled and interfaced through the ARDUINO. Now the IR sensor senses the
arrival/departure of the Train and accordingly sets up the Buzzer to notify the
surrounding/nearby area. After which the servo motor/DC motor which here is used
to control the gateway system at the crossing itself takes the corresponding action
to whether open or close the gateway accordingly.
CODING:
void setup()
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
void loop() {
if(digitalRead(2)==HIGH)
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
else
if(digitalRead(3)==HIGH)
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
}
else
digitalWrite(8,LOW);
Coding Explanation:
First the pin mode for the appropriate pins in Arduino Uno. Set the pin 2 & 3 as a
inputs and set the pin 8 & 9 as a outputs. Then enter into the loop and write the
command. When the digitalRead to pin 2 is HIGH then it will HIGH the pin 8, else
it check digitalRead to pin 3 if it is HIGH then it will also HIGH the pin 8, if the
digitalRead to pin 2 and 3 both are LOW then it will HIGH the pin 9.
Required Components
1. Arduino Uno R3
2. L293D motor driver
3. Lm 358 IC
4. IR sensor Pairs
5. DC Motor
6. Buzzer
7. LEDs
8. Jumper Wires
Description of components
1. Arduino Uno
1.1. Arduino Uno R3
• Microcontroller: ATmega328P
• Operating Voltage: 5v
• Input Voltage: 7-20v
• Digital I/O Pins: 14 (of which 6 provide PWM output)
• Analog Input Pins: 6
• DC Current per I/O Pin: 20 mA
• DC Current for 3.3V Pin: 50 mA
• Flash Memory: 32 KB of which 0.5 KB used by bootloader
• SRAM: 2 KB
• EEPROM: 1 KB
• Clock Speed: 16 MHz
• Length: 68.6 mm
• Width: 53.4 mm
• Weight: 25 g
1.3 PINS
• LED: There is a built-in LED driven by digital pin 13. When the pin is HIGH
value, the LED is on, when the pin is LOW, it's off.
• VIN: The input voltage to the Arduino/ Genuino board when it's using an
external power source (as opposed to 5 volts from the USB connection or other
regulated power source). You can supply voltage through this pin, or, if
supplying voltage via the power jack, access it through this pin.
• 5V: This pin outputs a regulated 5V from the regulator on the board. The board
can be supplied with power either from the DC power jack (7 - 20V), the USB
connector (5V), or the VIN pin of the board (7-20V). Supplying voltage via
the 5V or 3.3V pins bypasses the regulator, and can damage the board.
• 3V3: A 3.3 volt supply generated by the on-board regulator. Maximum current
draw is 50 mA.
• GND: Ground pins.
• IOREF: This pin on the Arduino/ Genuino board provides the voltage
reference with which the microcontroller operates. A properly configured
shield can read the IOREF pin voltage and select the appropriate power source
or enable voltage translators on the outputs to work with the 5V or 3.3V.
• Reset: Typically used to add a reset button to shields which block the one on
the board.
1.4. Communication
The Arduino/Genuino Uno has a number of facilities for communicating with a
computer, another Arduino/Genuino board, or other microcontrollers. The
ATmega328 provides UART TTL (5V) serial communication, which is available
on digital pins 0 (RX) and 1 (TX). An ATmega16U2 on the board channels this
serial communication over USB and appears as a virtual com port to software on
the computer. The 16U2 firmware uses the standard USB COM drivers, and no
external driver is needed. However, on Windows, a. in file is required. The
Arduino Software (IDE) includes a serial monitor which allows simple textual
data to be sent to and from the board. The RX and TX LEDs on the board will
flash when data is being transmitted via the USB-to-serial chip and USB
connection to the computer (but not for serial communication on pins 0 and 1).
A Software Serial library allows serial communication on any of the Uno's digital
pins.
This setup has other implications. When the Uno is connected to either a
computer running Mac OS X or Linux, it resets each time a connection is made
to it from software (via USB). For the following half-second or so, the bootloader
is running on the Uno. While it is programmed to ignore malformed data (i.e.
anything besides an upload of new code), it will intercept the first few bytes of
data sent to the board after a connection is opened.
Table 1.
Parameter Value
Flash memory 32 kB
SRAM 2 kB
EEPROM 1 kB
Hardware Q Touch
No
Acquisition
Maximum I/O pins 23
External interrupts 2
USB Interface No
USB Speed –
2.1. Relays
One way to build an H bridge is to use an array of relays from a relay board.A
"double pole double throw" (DPDT) relay can generally achieve the same electrical
functionality as an H bridge (considering the usual function of the device). However
a semiconductor-based H bridge would be preferable to the relay where a smaller
physical size, high speed switching, or low driving voltage (or low driving power)
is needed, or where the wearing out of mechanical parts is undesirable.
Another option is to have a DPDT relay to set the direction of current flow and a
transistor to enable the current flow. This can extend the relay life, as the relay will
be switched while the transistor is off and thereby there is no current flow. It also
enables the use of PWM switching to control the current level.
2.4. Variants
A common variation of this circuit uses just the two transistors on one side of the
load, similar to a class AB amplifier. Such a configuration is called a "half
bridge".[3] The half bridge is used in some switched-mode power supplies that
use synchronous rectifiers and in switching amplifiers. The half-H bridge type is
commonly abbreviated to "Half-H" to distinguish it from full ("Full-H") H bridges.
Another common variation, adding a third 'leg' to the bridge, creates a three-phase
inverter. The three-phase inverter is the core of any AC motor drive.
The H Bridge with a DC supply will generate a square wave voltage waveform
across the load. For a purely inductive load, the current waveform would be a
triangle wave, with its peak depending on the inductance, switching frequency, and
input voltage.
If you close switch 1 and switch 4, the current will flow from the source, through
switch 1, and then through the load, then through switch 4, and then back to the
load.
An H-bridge circuit with S2 and S3 closed.
In the image above, the circuit has Switch 2 and switch 3 closed. This will cause
the current to flow from the source, through switch 3, and then through the load,
then through switch 2, then back to the load.
One thing you have to be very cautious about when working with H-bridges is to
not create a short circuit. If you create a short circuit, that’s a sure way to burn out
your H-bridge. I may have burned out my very first H-bridge at Digi lent.
3.1. LM 358 IC
The LM358 IC is a great, low power and easy to use dual channel op-amp IC. It is
designed and introduced by national semiconductor. It consists of two internally
frequency compensated, high gain, and independent op-amps. This IC is designed
for specially to operate from a single power supply over a wide range of voltages.
The LM358 IC is available in a chip sized package and applications of this op amp
include conventional op-amp circuits, DC gain blocks and transducer amplifiers.
LM358 IC is a good, standard operational amplifier and it is suitable for your
needs. It can handle 3-32V DC supply & source up to 20mA per channel. This op-
amp is apt, if you want to operate two separate op-amps for a single power supply.
It’s available in an 8-pin DIP package.
Fig 4. LM358 IC
• It consists of two op-amps internally and frequency compensated for unity gain
• The large voltage gain is 100 dB
• Wide bandwidth is 1MHz
• Range of wide power supplies includes single and dual power supplies
• Range of Single power supply is from 3V to 32V
• Range of dual power supplies is from + or -1.5V to + or -16V
• The supply current drain is very low, i.e., 500 μA
• 2mV low I/p offset voltage
• Common mode I/p voltage range comprises ground
• The power supply voltage and differential I/p voltages are similar
• O/p voltage swing is large.
3.4.1 IR LED
IR LED emits light, in the range of Infrared frequency. IR light is invisible to us
as its wavelength (700nm – 1mm) is much higher than the visible light range.
Everything which produce heat, emits infrared like for example our human body.
Infrared have the same properties as visible light, like it can be focused, reflected
and polarized like visible light.
Fig 6. IR LED
3.4.2 Photodiode
Photodiode is considered as Light dependent Resistor (LDR), means it has very
High resistance in absence of light and become low when light falls on it.
Photodiode is a semiconductor which has a P-N junction, operated in Reverse
Bias, means it start conducting the current in reverse direction when Light falls on
it, and the amount of current flow is proportional to the amount of Light. This
property makes it useful for IR detection.
Fig 7. Photodiode
Components
Voltage at inverting end, which is also called Threshold Voltage, can be set by
rotating the variable resistor’s knob. Higher the voltage at inverting end (-), less
sensitive the sensor and Lower the voltage at inverting end (-), more sensitive the
sensor.
4. DC Motor:
A DC motor usually means a permanent-magnet, direct-current (DC) motor
of the sort used in toys, models, cordless tools, and robots. These motors are
particularly versatile because both their speed and direction can be readily
controlled; speed by the voltage or duty cycle of their power supply, and direction
by its polarity.
Torque is a measurement of the motors power. The higher the torque of the motor
the more weight it can move. DC motors provide different amounts of torque
depending on their running speed, which is measured in RPM (revolutions per
minute). At low RPM DC motors produce poor torque, and generally the higher the
RPM, the better the motors torque. However, in high torque, the speed may be too
high for an application. That's why we have to use gears (or geared motor) to reduce
the overall speed of the motor and running at the top speed to get the most power
to, say, a wheel attached to the shaft of the motor.
5. Battery
A 9V battery is required to supply the dc power to drive the Arduino Uno and other
components connected to the Arduino.
6. Software
Arduino IDE is used to develop the prototype of the software. Arduino IDE is
available at the official website of Arduino. This is open source. So any one can
develop anything according to their choices.
Fig 11. Arduino IDE interface
FUTURE SCOPE
1. Possible obstacles
Though this prototype is simple to build and highly reliable but there’re some
obstacles too. Rather than a train if an animal or other object is placed in front of
the IR sensor the alarm will and the gate will be closed which is not desirable at all.
Also other natural obstacles like fog may arise problems. There’re also a scope of
alerting the nearest railway station about arrival and departure of the train.
The problems indicated above can be overcome by adding some extra modules.
Like we left the GSM module for future scope. After adding this module, upon
arrival and departure of train, the GSM module will send an SMS to registered
phone number for acknowledgement and safety. Also adding a pair of pressure
sensor increases the chance of fault triggering of gate as well as alarm. After adding
the pressure sensor, the Arduino closes the gate after receiving both signal from IR
sensor as well as pressure sensor.
Problems:
Working in this project, some problems have been faced by us .The problems are
given below:
First of all, the value of resistances should be changed as the voltage changes
with the change of light .It is very difficult to vary the resistance for the
perfect operation.
Another problem is IR sensor easily damages so that the operation hampers.
IR sensor is light dependent sensor. It varies with the change of light so it is
not applicable for all environment.
IR sensor works at a certain distance .If the distance is increased the IR will
not work which is a drawback of this project.
Discussion:
This project helps us to know about the operations of IR sensor and Arduino Uno.
Though the project has some limitations for using in practical purpose, its concept
is very useful to us. This project can be improved by using LASER and LDR for
increasing the distance for real train .A buzzer can be added for safety .This project
can be developed in future using the concept which will be preferable for practical
use.
CONCLUSION
Automatic gate control system offer an effective way to reduce the occurrence of
railway accidents. This system can contribute a lot of benefit either to the road users
or to the railway management. Since the design is completely automated it can be
used in remote villages where no station master or line man is present. Railway
sensors are placed at two sides of gate. It is used to sense the arrival and departure
of the train. This system uses the DC motor to open and close the gates automatically
when it is rotated clockwise or anticlockwise direction. The LCD display shows the
speed of the train. The system can also generate buzzer while gate close. In this
system, this is controlled by using ATmega328p microcontroller. Now a day’s
automatic system occupies each and every sector of applications as it is reliable and
accurate.
COST ANALISIS:
3. Motor Driver 1 55
4. DC Motor 1 50
5. 9V Battery 2 40
6. PCB 2 50
9. Battery Cap 2 10