Professional Documents
Culture Documents
Vamshi Goud
Vamshi Goud
BACHELOR OF TECHNOLOGY
In
MECHANICAL ENGINEERING
Submitted by
SHAIK SOHAIL ALI 21TQ5A0319
We hereby declare that the results embodied in this dissertation entitled "AUTOMATIC
RAILWAY GATE CONTROLLING (using Arduino) uno and ultrasonic sensor is
carried out by us during the year 2021–2024 in partial fulfilment of the award of Bachelor
of Technology in MECHANICAL ENGINEERING from SIDDHARTHA INSTITUTE
OF TECHNOLOGY AND SCIENCE NARAPLLY, is an authentic record of my own
work carried under the guidance of Mr. K. MAHENDER (Ph.D.), Assistant
Professor., Department of Mechanical Engineering.
PROJECT BY:
As Human safety is major goal for Railways. The intention of this project is to achieve automatic
control at the level crossings when the arrival/departure of the train takes place replacing the
manual gate control. The railway gate automatically is closed when a train passes through the
railway crossing. The detection of arrival and departure of train is done by using two Ultrasonic
sensors. The gate opening and closing is to be done using servo motors which Are controlled by
Arduino Uno.
In addition, with this the status of the gate will be given to the motor in advance which ensures
more safety from the accident. Buzzers are used to indicate the closing of gate for the people who
are trying to cross the gate. This system helps in avoiding the increased number of the accidents at
level crossing in India. The hardware is supported by the Arduino C programming. The proposed
system is more reliable and cost efficient.
KEY WORDS: Arduino, Ultrasonic sensor, GSD modern obstacle, Infrared sensor
INDEX
TITLE PAGENO
Certificate ........................................................................................... ii
Declaration .......................................................................................... iii
Acknowledgement .............................................................................. iv
Abstract ................................................................................................v
❖ CHAPTER 1: INTRODUCTION
1.1. Overview ....................................................................................................1
1.2. Existing Method ...................................................................................................2
1.3 Proposed Method ...................................................................................................2
❖ CHAPTER 2: LITERATURE SURVERY
2.1 Domain Description .................................................................................3
2.1.1 Embedded Systems ................................................................................3
2.2 Characteristics of Embedded System .......................................................4
2.3 Basic Blocks of Embedded System ..........................................................5
2.4 Project outline 5 ........................................................................................5
❖ CHAPTER 3: FUNCTIONAL BLOCK DIAGRAM
3.1. Block Diagram and its Description ...........................................................6
3.2. Block Diagram Components......................................................................6
3.3. Project Desig……………………………………………………………..6-7
❖ CHAPTER 4: HARDWARE REQUIREMENTS
4.1 Hardware Components ..............................................................................8
4.1.1 Overview of Arduino Uno ......................................................................8
4.2 Arduino Introduction .................................................................................9
4.2.1 Introduction.............................................................................................9
4.2.2 How to use Arduino Board .....................................................................9-10
4.2.3 Communication.......................................................................................11
4.3 Pin Description ..........................................................................................12
4.4 Arduino Uno Technical Specifications ......................................................13
4.5 Arduino Uno to ATmega328 Pin Mapping ................................................14
i
4.6 servo motor ...........................................................................................................17
4.6.1 Overview ................................................................................................18
4.6.2 Servo Mechanism ...................................................................................18-19
4.6.3 Working Principle of Servo Motors ........................................................20
4.6.4 Controlling Servo Motors .......................................................................20-21
4.6.5 Arduino Servo Motors Control ...............................................................22
4.7 Ultrasonic sensor .......................................................................................23-24
4.7.1 HC-SR04 Ultrasonic Sensor – working ..................................................24-25
4.7.2 How to use the HC-SR04 Ultrasonic Sensor ..........................................25
4.7.3 Applications ............................................................................................25
4.7.4 Ultrasonic Sensor Pin Configuration .......................................................25
4.7.5 HC-SR04 Ultrasonic Sensor Features .....................................................26-27
4.8 liquid crystal display ..................................................................................27
4.8.1 Pin Description .......................................................................................28
4.8.2 Pin Description of Alpha Numeric LCD .................................................29
4.8.3 16x2 LCD Module Commands ...............................................................29-30
❖ CHAPTER 5: SOFTWARE REQUIREMENTS
5.1 ARDUINO UNO IDE ...............................................................................31
5.2 Use your Arduino Uno on the Arduino Desktop IDE ...............................32
❖ CHAPTER 6: IMPLEMENTATION
6.1 Module description ...................................................................................33-34
❖ APPLICATIONS, ADVANTAGES AND DISADVANTAGES
Applications ....................................................................................................35
Advantages ......................................................................................................35
Disadvantages .................................................................................................35
ii
RESULT ..........................................................................................................36
❖ CONCLUSION&FUTURESCOPE
8.1. Conclusion ................................................................................................37
8.2. Future Scope ............................................................................................38
REFERENCES..............................................................................................................39
iii
CHAPTER-1
INTRODUCTION
In today’s scenario Railway safety becomes the most important aspect of railways all over the
world. As we know the Railways are the cheapest mode of transportation, and due to manual
operation, accidents are likely to happen. There are 30348 level crossings on Indian Railways
across the country. 18785 are man handled and 11563 are non-man handled level crossings out
of 303048 level crossings. To avoid accidents over previous five years 4792 level crossings have
been removed by the respective Zonal railways of Indian Railways.
The Indian ministry of Railways made a decision focusing on eliminating all level crossings on
availability of railway funds, which could be controlled automatically. The suggest system helps
in achieving the safety and to prevent accidents at the level crossings that are non-man handled.
The Automatic railway gate control system can be employed under non man handled level
crossing where the chances of accidents are higher and requirement of reliable operation are
there. Since, the proposed model suggests an automatic system, it helps in reducing the error
which is in manual operation and it will be used as highly reliable source.
The proposed model of automatic gate control at level crossings is highly economical based on
the arrangement done by using Arduino and Servo motor which makes the design for use in
almost every non man handled that is unmanned railway crossings. The proposed model suggests
a design to control a railway level-crossing by servo motor using Arduino controller. The
connection of motor is done from Arduino with the help of a driver IC for controlling the railway
gate. Two Ultrasonic sensors are used to detect arrival of the train and departure of the train.
Ultrasonic sensors are checking the complete closing of gate. 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.
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,
1
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
EXISTING METHOD:
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.
PROPOSED METHOD:
In the proposed system, sensors are used to detect the train arrival and departure. The System
uses three different sensors to control the rail arrival and departure. Arduino is used for program
the sensors. The following materials and components are used in this proposed system for
automatic gateway control system. Where an Arduino is used for connecting devices like
Ultrasonic sensor, Servo Motor.
In the Proposed Model the servo motor is used for monitoring of cross Way and Ultrasonic
sensors is used to detect the motion of objects nearby the crossway, which when detects the train
or motion of any other vehicle nearby the crossway it takes the corresponding action of whether
opening or closing the gateway at the crossing.
2
CHAPTER 2
3
CHARACTERISTICS OF EMBEDDED SYSTEMS:
Embedded systems are designed to do some specific tasks, rather than be a general-purpose
computer for multiple tasks. Some also have real-time performance constraints that must be met,
for reasons such as safety and usability; others may have low or no performance requirements,
allowing the system hardware to be simplified to reduce costs. Embedded systems are not always
standalone devices. Many embedded systems consist of small, computerized parts within a larger
device that serves a more general purpose. For example, the features an embedded system for
tuning the strings, but the overall purpose of the Robot Guitar is, of course, to play music.
Similarly, an embedded system in automobiles provides a specific function as a subsystem of
the car itself. The program instructions written for embedded systems are referred to as firmware,
and are stored in read-only memory or flash memory chips. They run with limited computer
hardware resources: little memory, small or non-existent keyboard and/or screen.
4
BASIC BLOCKS OF EMBEDDED SYSTEM:
Now, the details of the various building blocks of the hardware of an embedded system are
• Central Processing Unit (CPU)
• Memory (Read-only Memory and Random Access Memory)
• Input Devices
• Output devices
• Communication interfaces
• Application-specific circuitry.
PROJECT OUTLINE:
In view of the proposed thesis work explanation of theoretical aspects and algorithms used in
this work are presented as per the sequence described below.
Describes a brief review of the objectives, existing method, proposed method and
goals of the work.
Describes the Block diagram and various modules used for the application is
described in detail.
The Circuit diagram implementation and coding for the design.
Presents the results and discussion.
Applications, Advantages & Disadvantages of the project.
Presents conclusions of the study and future scope
5
CHAPTER -3
PROJECT DESIGN:
6
design meets the objective, carrying out the PCB layout of the schematic tested on breadboard,
finally preparing the board and testing the designed hardware.
The software part deals in programming the microcontroller so that it can control the operation
of the IC’s used in the implementation. In the present work, we have used the or cad design
software for PCB circuit design, the Keil µv3 software development tool to write and compile
he source code, which has been written in the C language. The Pro load programmer has been
used to write this compile code into the microcontroller. The hardware and software
implementation is explained in the next chapter.
7
CHAPTER 4
HARDWARE REQUIREMENTS
The Arduino Uno is a micro controller board based on the ATmega328. It has 20 digitals input/output
pins (of which 6 can be used as PWM outputs and 6 can be used as analog inputs), a 16 MHz resonator,
a USB connection, a power jack, an in-circuit system programming (ICSP) header, and a reset button.
It contains everything needed to support the microcontroller; simply connect it to a computer with a
USB cable or power it with a AC to DC converter or battery to get started.
The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip.
Instead, it features an ATmega16U2 programmed as a USB-to-serial converter. This auxiliary
microcontroller has its own USB boot loader, which allows advanced users to reprogram it.
The Arduino has a large support community and an extensive set of support libraries and hardware
addon “shields” (e.g. you can easily make your Arduino wireless with our Weixel shield), making it
a great introductory platform for embedded electronics.
Note that we also offer a Spark Fun Inventor’s Kit, which includes an Arduino Uno along with an
assortment of components (e.g. breadboard, sensors, jumper wires, and LEDs) that make it possible
to create a number of fun introductory projects.
This is the 3rd revision of the Uno (R3), which has a number of changes:
The USB controller chip changed from ATmega8U2 (8K flash) to ATmega16U2 (16K flash). This
does not increase the flash or RAM available to sketches.
Three new pins were added, all of which are duplicates of previous pins. The I2C pins (A4, A5) have
been also been brought out on the side of the board near AREF.
There is an IOREF pin next to the reset pin, which is a duplicate of the 5V p∙ The reset button is now
next to the USB connector, making it more accessible when a shield is used.
Arduino Introduction:
9
Fig. 4.1 Arduino Uno
➢ SPI Pins 10 (SS), 11 (MOSI), 12 (MISO) and 13 (SCK): These pins are used for
SPI communication.
➢ In-built LED Pin 13: This pin is connected with an built-in LED, when pin 13 is
HIGH – LED is on and when pin 13 is LOW, its off. Along with 14 Digital pins,
there are 6 analog input pins, each of which provide 10 bits of resolution, i.e. 1024
different values. They measure from 0 to 5 volts but this limit can be increased by
using AREF pin with analog Reference () function.
➢ Analog pin 4 (SDA) and pin 5 (SCA) also used for TWI communication using Wire
library.
➢ Arduino Uno has a couple of other pins as explained below:
AREF: Used to provide reference voltage for analog inputs with analog Reference () fructi Reset
Pin: Making this pin LOW, resets the microcontroller.
Communication:
Arduino can be used to communicate with a computer, another Arduino board or other
microcontrollers.
The ATmega328P microcontroller provides UART TTL (5V) serial communication which can be
done using digital pin 0 (Rx) and digital pin 1 (Tx).
10
An ATmega16U2 on the board channels this serial communication over USB and appears as a virtual
com port to software on the computer. The ATmega16U2 firmware uses the standard USB COM
drivers, and no external driver is needed.
However, on Windows, a .inf file is required. The Arduino software includes a serial monitor which
allows simple textual data to be sent to and from the Arduino board. There are two RX and TX LEDs
on the Arduino board which will flash when data is being transmitted via the USB-to-serial chip and
USB connection to the computer (not for serial communication on pins 0 and 1). A Software Serial
library allows for serial communication on any of the Uno's digital pins. The ATmega328P also
supports I2C (TWI) and SPI communication. The Arduino software includes a Wire library to
simplify use of the I2C bus.
Rather than requiring a physical press of the reset button before an upload, the Arduino/Genuine Uno
board is designed in a way that allows it to be reset by software running on a connected computer.
One of the hardware flow control lines (DTR) of the ATmega8U2/16U2 is connected to the reset line
of the ATmega328 via a 100 nano farad capacitor. When this line is asserted (taken low), the reset
line drops long enough to reset the chip.
This setup has other implications. When the Uno is connected to 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.
11
Pin Description
10 (SS), 11 (MOSI),
SPI 12 (MISO) and 13 Used for SPI communication.
(SCK)
12
Arduino Uno Technical Specifications
Operating Voltage 5V
SRAM 2 KB
EEPROM 1 KB
13
Arduino Uno to ATmega328 Pin Mapping
When ATmega328 chip is used in place of Arduino Uno, or vice versa, the image below shows the
pin mapping between the two.
14
Advantages and Disadvantages
1. Ready to Use:
The biggest advantage of Arduino is its ready to use structure. As Arduino comes in a complete
package form which includes the 5V regulator, a burner, an oscillator, a micro-controller, serial
communication interface, LED and headers for the connections. You don’t have to think about
programmer connections for programming or any other interface. Just plug it into USB port of your
computer and that’s it. Your revolutionary idea is going to change the world after just few words of
coding.
Example2
Another big advantage of Arduino is its library of examples present inside the software of Arduino.
I’ll explain this advantage using an example of voltage measurement. For example, if you want to
measure voltage using ATmega8 micro-controller and want to display the output on computer screen
then you have to go through the whole process. The process will start from learning the ADCs of
micro-controller for measurement, went through the learning of serial communication for display and
will end at USB – Serial converters.
Effortless functions:
During coding of Arduino, you will notice some functions which make the life so easy. Another
advantage of Arduino is its automatic unit conversion capability. You can say that during debugging
you don’t have to worry about the unit’s conversions. Just use your all force on the main parts of your
projects. You don’t have to worry about side problems.
Large community:
There are many forums present on the internet in which people are talking about the Arduino.
Engineers, hobbyists and professionals are making their projects through Arduino. You can easily
find help about everything. Moreover, the Arduino website itself explains each and every function of
Arduino.
Inexpensive
Arduino boards are relatively inexpensive compared to other microcontroller platforms. The least
expensive version of the Arduino module can be assembled by hand, and even the pre-assembled
Arduino modules cost less than 400 rupees.
Cross-platform
The Arduino software runs on Windows, Macintosh OSX, and Linux operating systems. Most
microcontroller systems are limited to Windows.
Simple, clear programming environment
The Arduino programming environment is easy-to-use for beginners, yet flexible enough for
advanced users to take advantage of as well. For teachers, it's conveniently based on the Processing
15
programming environment, so students learning to program in that environment will be familiar with
the look and feel of Arduino.
Open source and extensible software
The Arduino software is published as open-source tools, available for extension by experienced
programmers. The language can be expanded through C++ libraries, and people wanting to
understand the technical details can make the leap from Arduino to the AVR C programming -14
language on which it's based.
Similarly, you can add AVR-C code directly into your Arduino programs if you want to open source
and extensible hardware The Arduino is based on Atmel's ATMEGA8 and ATMEGA168
microcontrollers. The plans for the modules are published under a Creative Commons license, so
experienced circuit designers can make their own version of the module, extending it and improving
it. Even relatively inexperienced users can build the breadboard version of the module in order to
understand how it works and save money.
Disadvantages
1. The form factors Consider the size of Arduino boards like the Uno. For the performance it
provides, it is extremely bulky. Of course, it is designed to be used for learning and
experimenting, but if you want to deploy even a prototype using a Uno, you need to really think
about providing it enough space.
2. It’s not optimized for performance Arduino is a platform. So, the entire hardware + software
package is designed to help you program and create a wide variety of sketches easily.
▪ This of course comes at the cost of optimization. For the maximum output an Arduino
sketch can give you, the same microcontroller, if used with a standard avr
programming IDE and flashed with avrdude and an usbasp can allow you much
superior performance.
3. Language of arudino have been ported to a lot of microcontrollers but still mere knowledge
ofarduino would never leverage you proper hardware level expertise which is required very much as
embedded engineer/enthusiast.
4. Communication mediums Lot of the libraries of Arduino are needs to address issues like Ethernet,
Zigbee, which are not optimized well and needs a lot of improvement. The Arduino library controls
a lot of peripherals of your MCU which you might not now.
For example, it uses at least one of the timers on your ATMega. If you are using other libraries, or
need to use timers, you sometimes have to figure out a lot of stuff the Arduino framework does under
the hood or replace it, because it conflicts with whatever you need the timers for.
16
An example are the PWMs and the Soft PWM library. It took me quite a while to figure out that
you can't use all PWMs and the Soft PWM library on an ATMega328 together, because they both
use timers.
SERVO MOTOR
A servo motor is an electrical device which can push or rotate an object with great precision. If you
want to rotate and object at some specific angles or distance, then you use servo motor. It is just made
up of simple motor which run through servo mechanism. If motor is used is DC powered then it is
called DC servo motor, and if it is AC powered motor then it is called AC servo motor. We can get a
very high torque servo motor in a small and light weight package. Doe to these features they are being
used in many applications like toy car, RC helicopters and planes, Robotics, Machine etc.
Servo motors are rated in kg/cm (kilogram per centimeters) most hobby servo motors are rated at
3kg/cm or 6kg/cm or 12kg/cm. This kg/cm tells you how much weight your servo motor can lift at a
particular distance. For example: A 6kg/cm Servo motor should be able to lift 6kg if the load is
suspended 1cm away from the motors shaft, the greater the distance the lesser the weight carrying
capacity.
The position of a servo motor is decided by electrical pulse and its circuitry is placed beside the motor.
17
Overview:
There are many types of servo motors and their main feature is the ability to precisely control the
position of their shaft. A servo motor is a closed-loop system that uses position feedback to control
its motion and final position.
In industrial type servo motors the position feedback sensor is usually a high precision encoder, while
in the smaller RC or hobby servos the position sensor is usually a simple potentiometer. The actual
position captured by these devices is fed back to the error detector where it is compared to the target
position. Then according to the error, the controller corrects the actual position of the motor to match
with the target position.
Servo Mechanism
Controlled device
Output sensor
Feedback system
18
It is a closed loop system where it uses positive feedback system to control motion and final position
of the shaft. Here the device is controlled by a feedback signal generated by comparing output signal
and reference input signal.
Here reference input signal is compared to reference output signal and the third signal is produces by
feedback system. And this third signal acts as input signal to control device. This signal is present as
long as feedback signal is generated or there is difference between reference input signal and
reference output signal. So the main task of servomechanism is to maintain output of a system at
desired value at presence of noises.
19
WORKING PRINCIPLE OF SERVO MOTORS
A servo consists of a Motor (DC or AC), a potentiometer, gear assembly and a controlling circuit.
First of all, we use gear assembly to reduce RPM and to increase torque of motor. Say at initial
position of servo motor shaft, the position of the potentiometer knob is such that there is no electrical
signal generated at the output port of the potentiometer.
Now an electrical signal is given to another input terminal of the error detector amplifier. Now
difference between these two signals, one comes from potentiometer and another comes from other
source, will be processed in feedback mechanism and output will be provided in term of error signal.
This error signal acts as the input for motor and 19 motor starts rotating. Now motor shaft is connected
with potentiometer and as motor rotates so the potentiometer and it will generate a signal. So as the
potentiometer’s angular position changes, its output feedback signal changes.
After sometime the position of potentiometer reaches at a position that the output of potentiometer is
same as external signal provided. At this condition, there will be no output signal from the amplifier
to the motor input as there is no difference between external applied signal and the signal generated
at potentiometer, and in this situation motor stops rotating.
All motors have three wires coming out of them. Out of which two will be used for Supply (positive
and negative) and one will be used for the signal that is to be sent from the MCU. Servo motor is
controlled by PWM (Pulse with Modulation) which is provided by the control wires.
There is a minimum pulse, a maximum pulse and a repetition rate. Servo motor can turn 90 degrees
from either direction form its neutral position. The servo motor expects to see a pulse every 20
milliseconds (ms) and the length of the pulse will determine how far the motor turns.
For example, a 1.5ms pulse will make the motor turn to the 90° position, such as if pulse is shorter
than 1.5ms shaft moves to 0° and if it is longer than 1.5ms than it will turn the servo to 180°. Servo
motor works on PWM (Pulse width modulation) principle, means its angle of rotation is controlled
by the duration of applied pulse to its Control PIN. Basically servo motor is made up of DC motor
which is controlled by a variable resistor (potentiometer) and some gears. High speed force of
DC motor is converted into torque by Gears. We know that WORK= FORCE X DISTANCE, in DC
motor Force is less and distance (speed) is high and in Servo, force is High and distance is less.
20
The potentiometer is attached on the final gear or the output shaft, so as the motor rotates the
potentiometer rotates as well, thus producing a voltage that is related to the absolute angle of the
output shaft.
In the control circuit, this potentiometer voltage is compared to the voltage coming from the signal
line. If needed, the controller activates an integrated H-Bridge which enables the motor to rotate in
either direction until the two signals reach a difference of zero
A servo motor is controlled by sending a series of pulses through the signal line. The frequency of the
control signal should be 50Hz or a pulse should occur every 20ms. The width of pulse determines
angular position of the servo and these types of servos can usually rotate 180 degrees (they have 2
Generally, pulses with 1ms duration correspond to 0 degrees position, 1.5ms duration to 90 degrees
and 2ms to 180 degrees.
Though the minimum and maximum duration of the pulses can sometimes vary with different brands
and they can be 0.5ms for 0 degrees and 2.5ms for 180 degrees position.
21
ARDUINO SERVO MOTORS CONTROL
Let’s put the above said to test and make a practical example of controlling a hobby servo using
Arduino.
We simply need to connect the control pin of the servo to any digital pin of the Arduino board,
connect the Ground and the positive wires to the external 5V power supply, and also connect the
Arduino ground to the servo ground.
22
ADVANTAGES
High output power relative to motor size and power Encoder determines accuracy and
resolution.
Resonance and vibration free operation High efficiency
There is no out-of-step condition, as heavy load placed on the motor the driver will increase
the current to the motor
High speed operation is possible
Disadvantages
Require tuning to stabilize feedback loop
Complex, require encoder
Poor motor cooling
Motor can be damaged by sustained overload.
ULTRASONIC SENSOR
An ultrasonic sensor is an instrument that measures the distance to an object using ultrasonic
sound waves. An ultrasonic sensor uses a transducer to send and receive ultrasonic pulses that
relay back information about an object’s proximity. High-frequency sound waves reflect from
boundaries to produce distinct echo patterns.
23
the front which forms the Ultrasonic transmitter and Receiver. The sensor works with the simple high
school formula that
The Ultrasonic transmitter transmits an ultrasonic wave, this wave travels in air and when it gets
objected by any material it gets reflected back toward the sensor this reflected wave is observed by
the Ultrasonic receiver module as shown in the picture below
Now, to calculate the distance using the above formulae, we should know the Speed and time.
Since we are using the Ultrasonic wave, we know the universal speed of US wave at room
conditions which is 330m/s.
The circuitry inbuilt on the module will calculate the time taken for the US wave to come back
and turns on the echo pin high for that same particular amount of time, this way we can also
know the time taken. Now simply calculate the distance using a microcontroller or
microprocessor.
Arduino, ARM, PIC, Raspberry Pie etc. The following guide is universally since it has to be followed
irrespective of the type of computational device used.
24
Power the Sensor using a regulated +5V through the Vcc ad Ground pins of the sensor. The current
consumed by the sensor is less than 15mA and hence can be directly powered by the on board 5V
pins (If available). The Trigger and the Echo pins are both I/O pins and hence they can be connected
to I/O pins of the microcontroller. To start the measurement, the trigger pin has to be made high for
10uS and then turned off. This action will trigger an ultrasonic wave at frequency of 40Hz from the
transmitter and the receiver will wait for the wave to return. Once the wave is returned after it getting
reflected by any object the Echo pin goes high for a particular amount of time which will be equal to
the time taken for the wave to return back to the sensor. The amount of time during which the Echo
pin stays high is measured by the MCU/MPU as it gives the information about the time taken for the
wave to return back to the Sensor. Using this information, the distance is measured as explained in
the above heading.
APPLICATIONS
Used to avoid and detect obstacles with robots like biped robot, obstacle avoider robot, path
finding robot etc.
Used to measure the distance within a wide range of 2cm to 400cm
Can be used to map the objects surrounding the sensor by rotating it
Depth of certain places like wells, pits etc can be measured since the waves can penetrate
through water.
Accuracy: 3mm
APPLICATIONS
Ultrasonic sensor is used in oil, chemical, milk or water tanks for level measurements or for
liquid level control.
This sensor is used in car parking system where car entry is controlled through barrier
system, the barrier must not be lowered when there is beneath a vehicle. This whole process
is controlled through ultrasonic sensor.
This sensor is used with bottle cutting and drink filling machines, where bottle is detecting
at serial points and for this continuous monitoring the ultrasonic sensor is used.
This sensor is used in transporting printed circuit boards (PCBs) industry where smart
phones, computer mother boards and home appliances circuit boards are designed and print.
7. This sensor is used in car manufacturing industry for manufacturing or assemble the car
automatically.
This sensor is used in car washing system for detecting and washing the car automatically.
26
This sensor is also used in presence detection system.
ADVANTAGES
The ultrasonic sensor has high frequency, high sensitivity and high penetrating power
therefore it can easily detect the external or deep objects.
These sensors have greater accuracy then other methods for measuring the thickness and
depth of parallel surface.
These sensors could easily sense the nature, shape and orientation of those specific objects
which is within the area of these sensors.
There sensors are easy to use, not dangerous during operation for nearby objects, person,
equipment or material.
DISADVANTAGES
✓ During use of ultrasonic tester for testing it is very important to know the operational manual,
in other words it required careful attention for experienced technician.
✓ During the development inspection procedure of equipment using ultrasonic tester extensive
knowledge is required is testing technicians.
✓ When these sensors are used for inspection purpose then these should be water resistive
otherwise, they could be damaged.
✓ When these sensors are interfaced with microcontroller or any controller then experienced
person or programmer is required.
16×2 LCD module is a very common type of LCD module that is used in 8051 based embedded
projects. It consists of 16 rows and 2 columns of 5×7 or 5×8 LCD dot matrices. The module was
talking about here is type number JHD162A which is a very popular one.
27
It is available in a 16-pin package with back light, contrast adjustment function and each dot matrix
have 5×8 dot resolution. The pin numbers, their name and corresponding functions are shown in the
table below. The liquid crystal display (LCD) is a low power device(microwatts). Now a days in most
application LCDs are used rather than LED displays because of its specifications like low power
consumption, ability to display numbers and special characters which are difficult to display with
other displaying circuits and easy to program. An LCD requires an external or internal light source.
Temperature range of LCD is 0 to 60 degree Celsius and life time is an area of concern, because LCDs
can chemically be degraded. These are manufactured with liquid crystal material that will flow like a
liquid but whose molecular structure has some properties normally associated with solids.
Pin Diagram:
FEATURES:
28
❖ Up to 8 extra characters can be created for custom glyphs or 'foreign' language
support ∙ Comes with strip of header pins
❖ Can adjust contrast with the addition of a potentiometer (not included)
➢ VCC is the power supply for the LCD which we connect the 5 volts pin on the Arduino.
➢ Vo (LCD Contrast) controls the contrast and brightness of the LCD. Using a simple
voltage divider with a potentiometer, we can make fine adjustments to the contrast.
➢ RS (Register Select) pin lets the Arduino tell the LCD whether it is sending commands
or the data. Basically, this pin is used to differentiate commands from the data. For
example, when RS pin is set to LOW, then we are sending commands to the LCD (like
set the cursor to a specific location, clear the display, scroll the display to the right and so
on). And when RS pin is set on HIGH, we are sending data/characters to the LCD.
➢ R/W (Read/Write) pin on the LCD is to control whether or not you’re reading data from
the LCD or writing data to the LCD. Since we’re just using this LCD as an OUTPUT
device, we’re going to tie this pin LOW. This forces it into the WRITE mode.
➢ E (Enable) pin is used to enable the display. Meaning, when this pin is set to LOW, the
LCD does not care what is happening with R/W, RS, and the data bus lines; when this pin
is set to HIGH, the LCD is processing the incoming data.
29
➢ D0-D7 (Data Bus) the pins that carry the 8 bit data we send to the display. For
example, if we want to see the uppercase ‘A’ character on the display we will set
these pins to 0100 0001(according to the ASCII table) to the LCD.
➢ A-K (Anode & Cathode) pins are used to control the backlight of the LCD.
ADVANTAGES
✓ The LCD can be made in large sizes of over 60 inch or 150 cm diagonal.
✓ It has no geometric distortion.
✓ It is very compact, thin, and light CRT displays.
✓ It does not affect by the magnetic fields.
✓ Due to low power consumption, small heat emitted during operation.
✓ It is much thinner than a CRT (cathode ray tube) monitor.
DISADVANTAGES
30
CHAPTER 5
SOFTWARE REQUIREMENTS
If you want to program your Arduino Uno while offline you need to install the Arduino Desktop IDE.
The Uno is programmed using the Arduino Software (IDE), our Integrated Development
Environment common to all our boards. Before you can move on, you must have installed the Arduino
Software (IDE) on your PC, as explained in the home page of our Getting Started.
Connect your Uno board with an A B USB cable; sometimes this cable is called a USB printer The
USB connection with the PC is necessary to program the board and not just to power it up. The Uno
automatically draw power from either the USB or an external power supply. Connect the board to
your computer using the USB cable. The green power LED (labelled PWR) should go on.
31
INSTALL THE BOARD DRIVERS
If you used the Installer, Windows - from XP up to 10 - will install drivers automatically as soon as
you connect your board.
If you downloaded and expanded the Zip package or, for some reason, the board wasn't properly
recognized, please follow the procedure below.
❖ Click on the Start Menu, and open up the Control Panel.
❖ While in the Control Panel, navigate to System and Security. Next, click on System. Once
the System window is up, open the Device Manager.
❖ Look under Ports (COM & LPT). You should see an open port named "Arduino UNO
(COMxx)". If there is no COM & LPT section, look under "Other Devices" for "Unknown
Device".
❖ Right click on the "Arduino UNO (COmxx)" port and choose the "Update Driver
Software" option. Next, choose the "Browse my computer for Driver software" option.
❖ Finally, navigate to and select the driver file named "arduino.inf", located in the "Drivers"
folder of the Arduino Software download (not the "FTDI USB Drivers" sub-directory). If
you are using an old version of the IDE (1.0.3 or older), choose the Uno driver file named
"Arduino UNO.inf"
❖ Windows will finish up the driver installation from there.
32
CHAPTER 6
The proposed system is practically experimented as a working model prototype. The major
components used in the model are an 80cm diameter railway tracks, a toy train, two Ultrasonic
sensors, two servo motor with which the gate operates, LCD Display to convey message and buzzer
to indicate the arrival of train to the traffic. The place where track and highway/road intersect each
other at the same level is known as “level crossing”. There are mainly two types of level crossing
they are manned level crossing and unmanned level crossing. 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 obstacle on track
system. This is mainly due to the carelessness in manual operations or lack of workers. We, in this
paper 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 in the track at a certain distance from the gate detects the approaching train and
accordingly controls the operation of the gate. As a train approaches the railway crossing from either
side, the sensors placed in the track at a certain distance from the gate detects the approaching train
and accordingly controls the operation of the gate.
Gate operation:
An Ultrasonic sensor is placed at a distance of 1 cm on either side of the level crossing. The toy train
passes the first sensor and when it is detected by the sensor, buzzer at the level cross indicating the
traffic that the gate is about to close and closes the gate with the help of servo motors. When the
second sensor senses the departure of the train, gates will open.
Obstacle detection:
Any obstacle on the track is detected by placing an Ultrasonic sensor on the frontend of the train and
the presence of obstacle on the track is notified by a signal at the control room.
The train movement is then controlled based on the presence of the obstacle on the track.
33
COMBINATIONAL WORKING OF ABOVE COMPONENTS:
When the train arrives either it may be right or left side the one of the ultrasonic sensor senses the arrival of
the train (the trigger pulse which is of 10µs being transmitted are objected by the train and receives an echo
signal)then the sensor sends the message to Arduino (echo pin goes high)and the servo motor closes the gate
at the same time the LCD display shown “CLOSE” ,it is an indication for the people intimating that the train
is arriving and showing a sign of stop. When the gate is closed the buzzer gives a beep sound. When the train
passes another sensor, the gate will be opened which means the train gets departed. The echo pin goes low and
the servo motor opens the gate and the display shows on LCD will be “OPEN “and letting people to cross
the railway gate.
34
APPLICATIONS, ADVANTAGES & DISADVANTAGES
APPLICATIONS:
The arrival and departure of trains is done by the sensor set. This can be used in safe rooms in banks
and also in parking areas.
This can be used in security areas like military and also own apartments etc.
ADVANTAGES:
An Automatic Railway Gate Control is implemented with very simple hardware and easy control.
Human intervention at level crossings can be removed with the help of this project and many railway
level crossing accidents can be prevented.
DISADVANTAGES:
The system can be implemented more efficiently by incorporation more efficient sensor network. A
combination manual wireless control and sensors-based control can be used for better operation.
35
RESULT:
The result of building an automatic railway gate controller using an Arduino and an ultrasonic sensor
would be a functional system that can detect approaching trains and automatically control the railway
gate. When a train is detected by the ultrasonic sensor, the system will activate the gate-closing
mechanism, ensuring that the gate is closed to prevent any vehicles or pedestrians from crossing the
railway tracks. Once the train passes, the gate will open again, allowing normal traffic flow to resume.
This project enhances safety at railway crossings by eliminating the need for manual gate operation
and reducing the risk of accidents. It demonstrates the practical application of sensors and
microcontrollers in real-world scenarios and highlights the potential for automation to improve
transportation infrastructure. Keep in mind that the effectiveness and reliability of the system will
depend on the accuracy of the ultrasonic sensor, the quality of the Arduino programming, and proper
integration with the gate mechanism.
36
CONCLUSION
CONCLUSION:
In this work, a smart railway crossing system is proposed based Internet of Things. We developed a
prototype for this and successfully verified the opening and closing of the gate during train arrival. It is
user friendly, and has required options, which can be utilized by the user to perform the desired
operations. The goals that are achieved are:
1. less human involvement
3. Cost effective
This work offered a very quick and enhanced working model of a SMART RAILWAY GATE. This
is very helpful to the people living in the remote areas with unmanned railway gates.
37
FUTURESCOPE:
The accidents due to railway level crossing and the obstacle can be avoided in real time by
implementing this system and the whole process is completely automatic. In future the features like
wireless system can be implemented in the real time operation. In real time operation vibration
sensors can be used in place of IR sensors for the detection of arrival and departure of train. So, the
vibration sensor serves better when compared to the IR sensors for the real time. And also, the GPS
system can be implemented and interfaced with the circuitry. GPS system ensures that the correct
location of the obstacle can be sent to the nearby railway station through GSM modem. This helps to
get the exact location of the obstacle so that the work for the clearance of obstacle can be done faster.
38
REFERENCES:
∙ https://www.ijareeie.com/upload/2016/may/105_22_Arduino.pdf
∙ https://www.arduino.cc/en/Guide/ArduinoUno
∙ https://www.techylib.com/en/view/forestevanescent/project_report_on_automatic_railway_ga
te_control
∙ www.scribd.com
∙ https://www.academia.edu/31327495/AUTOMATIC_RAILWAY_GATE_CONTROL_SYSTEM_2015_A
UTOMATIC_RAILWAY_GATE_CONTROL_SYSTEM
https://www.electronicwings.com/arduino/servo-motor-interfacing-with-arduino-uno ∙
https://www.theengineeringprojects.com/2017/08/ultrasonic-sensor-arduino-interfacing.html
40