You are on page 1of 22

Vehicle Speed Detection System

With SMS Alert

Group Members:
Names Roll No

Muazzam Ali
Muhammad Asif
Muhammad Shahid Rafiq
Amir
Toseef

DEPARTMENT OF PHYSICS
ALLAMA IQBAL OPEN UNIVERSITY​
5
ABSTRACT

It is a fact that the maximum death ratio is due to the road accidents and the
reason of so many road accident is over speeding of the vehicles. Therefore to
reduce the death ratio of the road accidents we must compel the drivers to follow
the speed limits notified by the government’s agencies for different areas and
roads.
Our final year project is addressing the same problem and we have tried
to design a speed detection system for roads and highways. This system will
automatically measure the speed of the vehicle passing the speed detection
area. And display the speed of vehicle on the LCD display. Whenever any vehicle
will violate the speed limits, the system will display the message on the screen
and also send an SMS to the highway police check post, so that the vehicle
violating the speed limits must be properly fined.

The heart of this system is Microcontroller 8051, we have used the


AT89S52, which is the CMOS version of the 8051 Microcontroller made by
ATMEL Inc. USA. And has 8Kbytes of the internal flash memory. For speed
detection we have used the Infrared sensors. For sending automatic SMS we
have used the GSM module SIM900A. For displaying messages the LCD module
with 2 lines and 16 characters per line has been used.

5
CHAPTER 1
INTRODUCTION
(PROJECT RELATED)

Chapter 1
INTRODUCTION
1.1 ​Back ground
1.1 Nowadays almost everywhere the electronic gadgets are being used by the
individuals as well as by the different organizations. So we should also use the
electronic technology for the safety of human lives and other purposes. In our
final year project we have designed a speed detection system for highways and
motorways, as it is the need of the day to provide safety to the human lives.

As we have mentioned earlier in the abstract that the maximum death ratio
is due to the road accidents and the reason of so many road accident is over
speeding of the vehicles. Therefore to reduce the death ratio of the road
accidents we must compel the drivers to follow the speed limits notified by the
government’s agencies for different areas and roads.

Our final year project is addressing the same problem and we have tried
to design a speed detection system for roads and highways. This system will
automatically measure the speed of the vehicle passing the speed detection
area. And display the speed of vehicle on the LCD display. Whenever any vehicle
will violate the speed limits, the system will display the message on the screen
and also send an SMS to the highway police check post, so that the vehicle
violating the speed limits must be properly fined.

The heart of this system is Microcontroller 8051; we have used the


AT89S52, which is the CMOS version of the 8051 Microcontroller made by
ATMEL Inc. USA. And has 8Kbytes of the internal flash memory. For speed
detection we have used the Infrared sensors. For sending automatic SMS we
have used the GSM module SIM900A. For displaying messages the LCD module
with 2 lines and 16 characters per line has been used.

1.2 ​Description
Our project is concentrated on the speed detection of the vehicles on the
roads and highways. This system uses the IR sensors to determine the speed of
moving vehicle on a highway. And with the help of microcontroller the speed is
measured and displayed on the LCD. If any speed limits are violated the system
automatically sends an SMS to toward the Highway Police.
1.3 ​Objectives
➢ Schematic Design
➢ Project circuits simulation.
➢ Designing of hardware, to detect the vehicle speed.
➢ Interfacing of LCD with microcontroller.
➢ Interfacing of GSM Module with Microcontroller
➢ Interfacing of all circuitry with microcontroller.

1.4 ​Problem statement


It is a fact that the maximum death ratio is due to the road accidents and the
reason of so many road accident is over speeding of the vehicles. Therefore to
reduce the death ratio of the road accidents we must compel the drivers to follow
the speed limits notified by the government’s agencies for different areas and
roads.

1.5 ​Scope
The scope of this project is very wide, because the speed detection is the need
of all the governments and other organization, where they want to reduce death
ratio due to the road accidents.

1.6 ​Functional Block Diagram Description


Below in Fig.1.3 we have given the complete block diagram of our project
hardware.
5

In the above block diagram it can be easily seen, that an infrared transmitter will
continuously transmit the Infrared radiation toward the Infrared receiver, both of
them are fixed at opposite sides of the road. When there is no car passing at that
point the infrared light will be put on the surface of infrared receiver, and the
sensor will provide high level voltage to the microcontroller. But as a vehicle will
pass through that point the infrared wave will be interrupted and Low level
voltage will be given to the microcontroller. The software inside the
microcontroller will check the change in status of the voltage. When the first
sensor will be interrupted the microcontroller will start counting the time and
when the second sensor will be interrupted it will stop time counting. Since the
distance between both pair of sensors is fixed and microcontroller has also got
the time. So now its very easy to find the speed of this vehicle. The speed is
displayed on the LCD and if there is speed violation, the SMS is sent toward the
Highway Police.

25
CHAPTER 2
HARDWARE DESIGN
25

2.1 Project Block Diagram:

Here in the figure below we have given the architecture of the entire system.

Figure 2- 1Project diagram

2.2 Introduction of AT89S51-2 Microcontroller

The device which control all the operation or all function of a system are called micro
controller. Like CPU which control all the function of computer. Microcontroller have
ROM, RAM and many number of I/O ports.
Because of these advantages Microcontroller are used for so many applications in which
cost and space are critical. It is necessary to be noted that some of the microcontroller
manufacture have gone as far as integrating on ADC [10].
Figure 2- 2 Micro controller 89S51-2 1

2.3 ​Internal study of 8051/2 MCU


2.3.1 Registers

There are 8bit registers in the 8051/2


microcontroller are shown in following
diagrams

D7 D6 D5 D4 D3 D2 D1 D0

In the 8051 mostly used registers are A,


B, R0, R1, R2, R3, R4, R5, R6, R7,
DPTR and PC. These all registers are
8bit registers along with DPTR and Program Counter.

2.3.2 Program Counter

This is the most important register in microcontroller which is used for the counting of
next executing or upcoming instructions. The starting address of the executing instruction
is 0000H and the ending address is FFFFH [11].

2.3.3 ROM

ROM is stand for ‘Read Only Memory’, It is located inside the AT89S52 microcontroller
chip, while in microprocessor it is connected externally. In this microcontroller chip the
ROM may be of 4kb, 8kb, 32kb and 64kb. With 64kb of ROM this microcontroller can
access more op code than any other microcontroller of this family.

2.3.4 RAM

RAM is the abbreviation of “Random Access Memory”. This microcontroller has 128
bytes of RAM which can gain address from 00 to 7FH. It can be accessed directly or as
by memory location.

2.4 Basic Circuit Configuration


Figure 2- 3 Basic circuit view

This is the basic configuration of the microcontroller due to this proper circuitry this can
be initialized to work with. Without externally connected clock oscillator we cannot
provide any pulse or frequency so in this situation the microcontroller will not
functioning.

2.4.3 Oscillator Circuit

Crystal oscillator is used for synchronization of microcontroller AT89S52 operation. The


minimum time required for the execution of any single instruction by microcontroller is
known as one machine cycle. For a single instruction execution microcontroller needs a
pulse which is provided it by connecting crystal oscillator between pin 18 and pin 19 that
generate clock pulses.
Figure 2- 4Oscillator Circuit
The micro controller often works with the following crystal frequencies.
12 MHz
16MHz
11.0592MHz

2.4 ​Introduction to LCD


LCD stands for the liquid crystal display. This is the latest device used for displaying
text, numbers, pictures and video. The portable display devices like mobile phone and
television are possible due to this LCD screen. The LCD screens are use in the
calculators, rest watches and measuring meters. Its pin configuration is shown in the
following figure 2- 5.

Figure 2- 5 LCD pin configuration

2.4.1 ​LCD Interfacing


The data which is coming from DB-9 connector along with pin 3 is given to MAX-232 at
pin 8. Now a day’s microcontrollers are not compatible with RS-232, so to solve this
problem MAX-232 are used.
The output of the MAX-232 is given to microcontroller as input by pin 10. For example
port 3.0. This pin is also known as RxD. Then we send out this data to LCD for
displaying.
st
To send data 1 make RS=1, then high to low pulse applied to the E pin of LCD to latch
in the data which is previously present at the data pin. When we perform writing on LCD
pin RW=0 [12]

2.4.2 ​Data Sheet of LCD

Data which is displaying can be entered in different location in LCD. Different address
location is shown below.

RS RW DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

0 0 1 A A A A A A A

Here
AAAAAAA=0000000 to 0100111 for line one and
AAAAAAA=1000000 to 1100111 for line two.

Figure 2- 6LCD interfacing with 8051

2.5 ​GSM Module and Its Working Principle

2.5.1 GSM Technology

GSM is a mobile communication network device which stands for Global System Mobile
communication networks. In the early days of mobile communicational analog
communication is introduced which is known as first generation of mobile
communication network. But that was analog communication and because of very low
band width it was not possible to use GSM every man of the world commonly and
subscriber can connect through. For the 1G problems solution and presently new digital
system is achieved that is now a day’s everyone use GSM commonly. So many features
like GPRS, vice call, text etc are include in it but the internet and more people assessing
through the vice connection is still not too many but some thousand is possible like
communication is possible in 2G. But presently its advance generation is so much better
than first in which the video calls and more internet speed is achieved which is known as
3G. Presently in some countries only 2G use but in some countries its working range are
in 4G and 5G. These ad vans generations are very high speed communication for so many
large numbers of users.
There are so many different frequencies ranges just like in 2G GSM network the
operating frequency bandwidth lies between 900 MHz to 1800MHz. But it is different in
other countries and in Pakistan this bandwidth is lies from 850 MHz to 1900 MHz and
the power rate for 850 to 900 MHz cell phone is 2 watt and the power rate for 1800 to
1900 MHz is 1 watt.

2.5.3 SIM

One of the most commend part of GSM technology is SIM which is abbreviation of
Subscriber identity module. SIM is smart card which contains the information about the
subscriber and its memory also has a specific phone numbers. It’s save also text. By help
of this SIM the subscriber location can be find and also its phone model and its company.

2.6 Implementation and Circuit Diagram:

​CIRCUIT DIAGRAM AND ANALYSIS


Figure 2- 7Schematic Diagram

2.6.1 ​Introduction
As the name represents, this project measures the speed of vehicles passing on the
highway and displays the speed value on the LCD display. If the vehicle is doing some

violation of the speed limits it will automatically send an SMS to the Highway Police and
inform them about this violation.

​The GSM module used is SIM900A, which is a very powerful GSM module
having all the features of working on GSM network.

2.6.2 ​Connectivity of LCD with microcontroller


LCD is abbreviation of liquid crystal display, according to the project idea LCD are used
to display the normal temperature. In this project we used 16*2 LCD and connected it
with port zero of the microcontroller. Pull up resistor connected between microcontroller
and LCD, Microcontroller produce data and transmit it serially which display in LCD.
The data input pin in LCD is eight, in our project we declare only four pin for data
receiving, the disadvantage of this is that it will take some time but the advantage of this
connection wires will used less.

2.6.3 ​GSM connectivity with microcontroller


GSM is the output device in our project because it used only for transmission of text.
There are two input and out pin in microcontroller which is Rx and Tx. The pin Rx are
connected with the port p3.1, According to project idea when there is no occur of gas
leakage or fire, no data will transmit, But when any problem creates, At that time GSM
sand an SMS like “GAS LEAKAGE” to specific number, Such that when temperature
sensor detect the presents of fire, It give signal to microcontroller through ADC and
microcontroller take action and generate pulse for GSM. Now it depends on the project
code that how much time it will sand and to how many number.
CHAPTER 3
SOFTWARE DESIGN

Chapter 3
SOFTWARE DESIGN

3.1 Program written for Highway Speed Detection System

The complete program is given below.



#include <at89x51.h>
#include <stdio.h>
#include <intrins.h>
#include <string.h>
#include <LCD.h>

#define uchar unsigned char


#define uint unsigned int
#define delayval 40
#define sensor1 P1_0
#define sensor2 P1_1

void delay(uint x); ​//x*0.14MS


int i,j,k;
unsigned char buffer[20];
//unsigned char msg[80];

void sendstr(unsigned char * chrr)


{
​while(*chrr!='\0')
​{
​SBUF = *chrr;
​while(TI);
​TI=0;
​chrr++;
​}
}

/**********************************************************/
/**********************************************************/
void delay(unsigned int x) //x*0.14MS
{
​for(i=0;i<1000;i++)
​for (j = 0; j<x; j++);
}
/**********************************************************/
//**************************************************************
// ​Function to check the status of keys
//**************************************************************
void initserial(void)
{
​SCON = 0x52; ​ //9600BPS
​TH1 = -3;
​TR1 = 1;
}
void sendmsg()
{
​sendstr("AT+CMGS=03006003057"); ​//Asif No.
​delay(100);
​sendstr("The Vehicle has voilated the speed rules!!!!");
​delay(100);

}
main()
{
​float tval;
​float dist = 20;
​float speed;
​initserial(); ​//Will Initialize the GSM Module
​LCD_init(); /​ /Will Initialize the LCD

​LCD_position(1,1);
​LCD_puts("Speed Detection ");
​LCD_position(2,1);
​LCD_puts("System with SMS ");
​delay(250);
​delay(100);

​LCD_command(0x01); ​//to clear the LCD


​LCD_puts("Deptt of Physics");
​LCD_position(2,1);
​LCD_puts("A.I.O.U Islamabd");
​delay(250);
​delay(100);

​LCD_command(0x01);
​LCD_puts("By: Asif, Shahid");
​LCD_position(2,1);
​LCD_puts(" Muazzam & Amir ");
​delay(250);
​delay(100);
​LCD_command(0x01);
​LCD_puts(" Supervised By: ");
​LCD_position(2,1);
​LCD_puts("Mr. Shakib Ahmed");
​delay(250);
​delay(100);

​while(1)
​{
​LCD_command(0x01); /* Clear */
​LCD_position(1,1);
​LCD_puts("Waiting for CAR");

​while(sensor1);
​LCD_command(0x01); /* Clear */
// ​LCD_position(1,1);
​LCD_puts("!!Car Detected!!");

​while(sensor2 == 0);
​speed = dist / tval;
​sprintf(buffer,"Speed =%5.2fKM/H",speed);
​LCD_position(2,1);
​LCD_puts(buffer);
​delay(delayval);
​delay(250);

​if(speed > 100)


​{
​LCD_command(0x01); /* Clear */
​LCD_position(1,1);
​LCD_puts("Voilation Detect");
​LCD_position(2,1);
​LCD_puts("SMS Sent>>Police");
// ​strcpy(msg,"The Vehicle has voilated the speed rules!!!!");
s​ endmsg(); ​
​delay(delayval);
​delay(400);
​}
​else if(speed < 30)
​{
​LCD_command(0x01); /* Clear */
​LCD_position(2,3);
​LCD_puts("Under Speed");
​delay(delayval);
​delay(250);
​}
​else
​{
​LCD_command(0x01); /* Clear */
​LCD_position(2,3);
​LCD_puts("Normal Speed");
​delay(delayval);
​delay(250);
​}
​while(P3_2 == 0);

​}
}

25

CHAPTER 4
RESULTS AND
DISCUSSIONS
25

Chapter 4
RESULTS AND DISCUSSIONS
4.1 ​RESULTS
This project having concentration to detect speed of vehicles can be used in every place
where gas are used and should be implemented in existing everywhere, without any
change in place infrastructure. It allows all users to find the speed of vehicles
automatically.
The status of the system at any instant will be available to user through LCD. The
solenoid valve will be ON/OFF through microcontroller in response to these two sensors
reading.

4.2 ​Limitations
• Continuous power is required all the time.
• Mobil will keep always on.

4.3 ​Future work


• Introduction of GSM module to control any device through text message.
• Use of Solar power for continuous DC supply.​
25

25