Sei sulla pagina 1di 63

CHAPTER 1

INTRODUCTION

In India there are different types of terrains like hilly area, plateaus etc., due to
improper road facilities accidents and death rate is increasing rapidly. India faces the
highest number of accidents and accidental fatalities in the world. The maximum number
of accidents are reported from the transport sector i.e. roadways as well as railways.

In this technological revulsion world there is no time for anyone to know what
happening round them they keep on moving without any care. As they give importance to
their work rather than others. Due to reduce in moral values one cannot get proper help
when they need. This can be solved by this technology itself.

Due to time laps many lives are in risk. To reduce this risk factor automatic
accident detection and victim analysis plays an important role. By eliminating the time
between when an accident occurs and when the first responders are dispatched to the
scene decreases mortality rates, we can save lives. One approach to eliminating the delay
between accident occurrence and first responder dispatch is to use in-vehicle automatic
accident detection and notification systems, which sense when a traffic accident is likely
to occur and immediately notify emergency occurred.

Probability of victim security will be more. Now a days mobile is most


commonly used electronic gadget that is present with everyone and this problem can be
solved by its usage. Short message service (SMS) provided by the mobile will help to
solve this problem. By this embedded system technology we can know the place of
accident and respond immediately to the situation

1
For a noticeable reduction in rescue time, two major steps must be taken:
a. Fast and accurate accident detection and reporting to an appropriate public
safety answering point (PSAP) and
b. Fast and efficient evacuation of occupants trapped inside a vehicle

Study of different kinds of IEEE papers for the technologies and hardware and software
that are used in the detection and indicating that accident and victim condition.

Jorge Zaldivar proposed an Android based application that monitors the vehicle through
an On Board Diagnostics (OBD-II) interface, being able to detect accidents and
application estimates the G force experienced by the passengers in case of a frontal
collision, which is used together with airbag triggers to detect accidents. The application
reacts to positive detection by sending details about the accident through either e-mail or
SMS to predefined destinations, immediately followed by an automatic phone call to the
emergency services. Experimental results using a real vehicle show that the application is
able to react to accident events in less than 3 seconds, a very low time, validating the
feasibility of Smartphone based solutions for improving safety on the road. [1]

Manuel Foguethe proposed system requires each vehicle to be endowed with an onboard
unit (OBU) responsible for detecting and reporting accident situations to an external
control unit (CU) that estimates its severity, allocating the necessary resources for the
rescue operation. The development of a prototype based on off-the-shelf devices and its
validation at the Applus+ IDIADA Automotive Research Corporation facilities show that
our system could notably reduce the time needed to alert and deploy the emergency
services after an accident takes place. [2]

2
Prabakar S proposed the system that has been developed and implemented using the
bio-medical smart sensors and microcontroller based mobile technology integrated with
the evolving Lab View platform. The system will automatically identify the accident,
then immediately transmit the location of the accident and the status of the physiological
parameters of the victims to the emergency care center phone number through Short
Message Service (SMS). The victims physiological parameters such as body
temperature, Heartbeat, Coma stage recovery status have been transmitted in the SMS.
[3]

Md. Syedul Amin proposes to utilize the capability of a GPS receiver to monitor speed
of a vehicle and detect accident basing on monitored speed and send accident location to
an Alert Service Center. The GPS will monitor speed of a vehicle and compare with the
previous speed in every second through a Microcontroller Unit. Whenever the speed will
be below the specified speed, it will assume that an accident has occurred. The system
will then send the accident location acquired from the GPS along with the time and the
speed by utilizing the GSM network. This will help to reach the rescue service in
time and save the valuable human life. [4]

C.Vidya Lakshmi proposed automatically find a traffic accident, search for the spot and
then send the basic information to first aid center within two seconds covering
geographical coordinates, the time and circumstances in which a traffic accident takes
place. GPS software is fitted in the vehicle will now start communicate with the satellite
and get the latitude and longitude values and send the information to the centralized
server. [5]

Main aim of our work is to provide security to the vehicle in very reasonable cost
so in this work we are using the basic microcontroller AT89S52 for cost effective and also
for easy understanding. In this work we used GPS and GSM modules which helps use to
trace the vehicle anywhere on the globe and send the message to the authorized members.
1.1 EMBEDDED SYSTEMS

3
Each day, our lives become more dependent on 'embedded systems', digital
information technology that is embedded in our environment. More than 98% of
processors applied today are in embedded systems, and are no longer visible to the
customer as 'computers' in the ordinary sense. An Embedded System is a special-purpose
system in which the computer is completely encapsulated by or dedicated to the device or
system it controls. Unlike a general-purpose computer, such as a personal computer, an
embedded system performs one or a few pre-defined tasks, usually with very specific
requirements. Since the system is dedicated to specific tasks, design engineers can
optimize it, reducing the size and cost of the product.

Typically, an embedded system is housed on a single microprocessor board with


the programs stored in ROM. Virtually all appliances that have a digital interface --
watches, microwaves, VCRs, cars -- utilize embedded systems.

Embedded systems range from portable devices such as digital watches and MP3
players, to large stationary installations like traffic lights, factory controllers, or the
systems controlling nuclear power plants.

1.1.1. DEFINITION OF AN EMBEDDED SYSTEM

An embedded system is a single-purpose computer built into a larger system for


the purposes of controlling and monitoring the system.
Embedded system can also be defined as the interaction of hardware with
software to perform a specific task or operation.
Software is used for providing features and flexibility, Hardware = {Processors,
ASICs, Memory,...} is used for Performance (& sometimes security).
A general purpose computer (e.g. a personal computer) cannot be defined as an
embedded system.
Examples: cell phones, DSTV decoders, MP3 players, ABS breaking systems, and
satellite guidance avionics.

1.1.2. CHARACTERISTICS OF EMBEDDED SYSTEMS

4
The important characteristics of an embedded system are

Speed (bytes/sec) : Should be high speed


Power (watts) : Low power dissipation
Size and weight : As far as possible small in size and low weight
Accuracy (% error) : Must be very accurate
Adaptability : High adaptability and accessibility.
Reliability : Must be reliable over a long period of time.

1.1.3. OVERVIEW OF AN EMBEDDED SYSTEM ARCHITECTURE

Every Embedded system consists of a custom-built hardware built around a central


processing unit. This hardware also contains memory chips onto which the software is
loaded.

Figure 1.1: Layered Architecture of Embedded system

The operating system runs above the hardware and the application software runs above
the operating system. The same architecture is applicable to any computer including
desktop computer. It is not compulsory to have an operating system in every embedded
system. For small applications such as remote control units, air conditioners, toys etc.

5
Coming to the hardware details of the embedded system, it consists of the following
important blocks.
CPU(Central Processing Unit)
RAM and ROM
I/O Devices
Communication Interfaces
Sensors etc. (Application specific circuitary)

This hardware architecture can be shown by the following block diagram.

Figure 1.2: Hardware Architecture

1.1.4.1 Central Processing Unit: A CPU is composed of an Arithmetic Logic Unit


(ALU), a Control Unit (CU), and many internal registers that are connected by buses.
The ALU performs all the mathematical operations (Add, Sub, Mul, Div), logical

6
operations (AND, OR), and shifting operations within CPU .The timing and
sequencing of all CPU operations are controlled by the CU. The CU is responsible for
directing the flow of instruction and data. The CPU works in a cycle of fetching an
instruction, decoding it, and executing it, known as the fetch-decode-execute cycle.

1.1.4.2 Memory: Embedded system memory can be either on-chip or off-chip. On chip
memory access is much fast than off-chip memory, but the size of on-chip memory is
much smaller than the size of off-chip memory. Generally the data is stored in RAM
and the program is stored in ROM.

1.1.4.3 I/O Ports: The I/O ports are used to connect input and output devices. The
common input devices for an embedded system include keypads, switches, buttons,
knobs, and all kinds of sensors.The output devices include Light Emitting Diodes
(LED), Liquid Crystal Displays (LCD), printers, alarms, actuators, etc.

1.1.4.4 Communication Interfaces: To transfer the data or to interact with other devices
the embedded devices are provided the various communication interfaces like
RS232, RS422, RS485 ,USB, SPI(Serial Peripheral Interface) ,SCI (Serial
Communication Interface) ,Ethernet etc.

1.1.4.5 Application Specific Circuitry: The embedded system some times receives the
input from a sensor or actuator. In such situations certain signal conditioning circuitry
is needed. This hardware circuitry may contain ADC , Op-amps ,DAC etc. Such
circuitry will interact with the embedded system to give correct output.

1.1.4.6 Power supply: Most of the embedded systems now days work on battery
operated supplies. Because low power dissipation is always required. Hence the
systems are designed to work with batteries.

7
1.1.5. APPLICATIONS OF EMBEDDED SYSTEMS

Some of the most common embedded systems used in everyday life are

S.No Embedded System Application


1 Home Appliances Dishwasher, washing machine, microwave, Top-
set box, security system, HVAC system, DVD,
answering machine, garden sprinkler systems etc..
2 Office Automation Fax, copy machine, smart phone system, modern,
scanner, printers.
3 Security Face recognition, finger recognition, eye
recognition, building security system, airport
security system, alarm system.
4 Academia Smart board, smart room, OCR, calculator, smart
cord.
5 Instrumentation Signal generator, signal processor, power supplier,
Process instrumentation,
6 Telecommunication Router, hub, cellular phone, IP phone, web camera
7 Automobile Fuel injection controller, anti-locking brake
system, air-bag system, GPS, cruise control.
8 Entertainment MP3, video game, Mind Storm, smart toy.
9 Aerospace Navigation system, automatic landing system,
flight attitude controller, space explorer, space
robotics.
10 Industrial automation Assembly line, data collection system, monitoring
systems on pressure, voltage, current, temperature,
hazard detecting system, industrial robot.
11 Personal PDA, i-Phone, palmtop, data organizer.
12 Medical CT scanner, ECG, EEG, EMG, MRI, Glucose
monitor, blood pressure monitor, medical
diagnostic device.
13 Banking & Finance ATM, smart vendor machine, cash register ,Share
market
14 Miscellaneous: Elevators, tread mill, smart card, security door etc.
Table 1.1: Applications of Embedded systems

1.2 TYPES OF EMBEDDED SYSTEMS


Based on functionality and performance embedded systems categorized as 4 types

1. Stand alone embedded systems

2. Real time embedded systems

8
3. Networked information appliances

4. Mobile devices

1.2.1 STAND ALONE EMBEDDED SYSTEMS

As the name implies, stand alone systems work in standalone mode. They
take input, process them and produce the desire output. The input can be an
electrical signal from transducer or temperature signal or commands from human
being. The output can be electrical signal to drive another system an led or LCD
display

Ex: digital camera, microwave oven, CD player, Air conditioner etc

1.2.2 REAL TIME EMBEDDED SYSTEMS

In this type of an embedded system a specific work has to be complete in a


particular period of time.

Hard Real time systems: - embedded real time used in missiles

Soft Real time systems: - DVD players

1.2.3 NETWORKED INFORMATION APPLIANCES

Embedded systems that are provided with n/w interfaces and accessed by
n/w such as local area n/w or internet are called Network Information Appliances

Ex: A web camera is connected to the internet. Camera can send pictures in real
time to any computers connected to the internet

1.2.4 MOBILE DEVICES

It is a combination of both VLSI and Embedded System

Mobile devices such as Mobile phone, Personal digital assistants, smart phones
etc are special category of embedded systems

9
1.3 MICROCONTROLLER AND MICROPROCESSOR

A system designer using a general-purpose microprocessor such as the Pentium or the


68040 must add RAM, ROM, I/O ports, and timers externally to make them functional.
Although the addition of external RAM, ROM, and I/O ports makes these systems
bulkier and much more expensive, they have the advantage of versatility such that the
designer can decide on the amount of RAM, ROM and I/O ports needed to fit the task at
hand.A Microcontroller has a CPU (a microprocessor) in addition to a fixed amount of
RAM, ROM, I/O ports, and a timer all on a single chip.; therefore, the designer cannot
add any external memory, I/O ports, or timer to it. The fixed amount of on-chip ROM,
RAM, and number of I/O ports in Microcontrollers makes them ideal for many
applications in which cost and space are critical.

1.3.1 MICROPROCESSOR

Figure 2.1: Microprocessor

1.3.2 MICROCONTROLLER

10
Figure 2.2: Microcontroller

1.3.3 TYPES OF PROCESSORS


Based on the Processor side Embedded Systems is mainly divided into 3 types

1. Micro Processor: - are for general purpose eg: our personal computer

2. Micro Controller: - are for specific applications, because of cheaper cost we will go
for these

3. DSP (Digital Signal Processor):- are for high and sensitive application purpose

CHAPTER 2

ACCIDENT IDENTIFICATION USING GSM AND GPS


PROJECT
11
2.1. INTRODUCTION

Vehicle Tracking System (VTS) is the technology used to determine the location of a
vehicle using different methods like GPS and other radio navigation systems operating
through satellites and ground based stations. By following triangulation or tri-lateration
methods the tracking system enables to calculate easy and accurate location of the
vehicle. Vehicle information like location details, speed, distance travelled etc., can be
viewed on a digital mapping with the help of software via Internet. Even data can be
stored and downloaded to a computer from the GPS unit at a base station and that can
later be used for analysis. This system is an important tool for tracking each vehicle at a
given period of time and now it is becoming increasingly popular for people having
expensive cars and hence as a theft prevention and retrieval device.
i. The system consists of modern hardware and software components enabling one to
track their vehicle online or offline. Any vehicle tracking system consists of
mainly three parts mobile vehicle unit, fixed based station and, database and
software system.
ii. Vehicle Unit: It is the hardware component attached to the vehicle having either a
GPS/GSM modem. The unit is configured around a primary modem that functions
with the tracking software by receiving signals from GPS satellites or radio
station points with the help of antenna. The controller modem converts the data
and sends the vehicle location data to the server.
iii. Fixed Based Station: Consists of a wireless network to receive and forward the
data to the data centre. Base stations are equipped with tracking software and
geographic map useful for determining the vehicle location. Maps of every city
and landmarks are available in the based station that has an in-built Web Server..

PREVIOUS TECHNOLOGY
When an accident occurs the information only be sent through GSM but there is no
possibility to locate the spot.

12
PROPOSED TECHNOLOGY
This project presents an automatic localization system using GPS and GSM.

2.2 PROJECT
In this project AT89S52 microcontroller is used for interfacing to various hardware
peripherals. The current design is an embedded application, which will continuously
monitor a moving Vehicle and report the status of the Vehicle on demand. For doing so an
AT89S52 microcontroller is interfaced serially to a GSM Modem and GPS Receiver. A
GSM modem is used to send the position (Latitude and Longitude) of the vehicle from a
remote place. The GPS modem will continuously give the data i.e. the latitude and
longitude indicating the position of the vehicle. The GPS modem gives many parameters
as the output, but only the NMEA data coming out is read and displayed on to the LCD.
The same data is sent to the mobile at the other end from where the position of the
vehicle is demanded. An EEPROM is used to store the mobile number.

2.2.1 HARDWARE COMPONENTS

AT89S52
GPS MODULE
GSM MODULE
MAX 232
POWER SUPPLY
LCD

2.2.2 BLOCK DIAGRAM

13
LIMIT LCD
SWITCH DISPLAY

POWER
GPS AT89S52
SUPPLY
MAX 232

GSM

Figure 3.1: Block Diagram

The hardware interfaces to microcontroller are LCD display, GSM modem and GPS
Receiver. The design uses RS-232 protocol for serial communication between the
modems and the microcontroller. A serial driver IC is used for converting TTL voltage
levels to RS-232 voltage levels. When the request by user is sent to the number at the
modem, the system automatically sends a return reply to that mobile indicating the
position of the vehicle in terms of latitude and longitude.

2.2.3 WORKING

The limit switch is interfaced to port1 of the microcontroller i.e., P1.0 and LCD is
interfaced to port 2.

The GPS and GSM modules are interfaced to microcontroller using MAX232 IC
which is a level converter. It converts high level RS232 values to low level TTL
values as explained earlier

GPS receiver is used to locate the position of the object (cars, bikes, buses etc.,)
and it takes 2-5 minutes to access the location. GSM also requires 30-50 seconds
to start working
14
Firstly, there will be a display on LCD showing GSM ACCIDENT
DETECTION

As soon as limit switch which is nothing but the circuit breaker is turned on, it
indicates the occurrence of the accident and immediately GPS tracks the location
with latitude and longitude values.

It sends the information to microcontroller which displays it on LCD and also


communicates with GSM to send the message to the authorized members.

In order to send the message we require SIM card in GSM.

The Power Supply is used to provide 5V voltage supply as the GPS, GSM,
Microcontroller unit works at this voltage.

Thus, we can identify the accident detection location.

Figure 3.2: Power Supply

CHAPTER 3

15
AT89S52 (8051) MICROCONTROLLER

AT89S52 MICROCONTROLLER

The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller


with 8K bytes of in-system programmable Flash memory. The device is
manufactured using Atmels high-density nonvolatile memory technology and is
compatible with the industry-standard 80C51 instruction set and pin out. The on-
chip Flash allows the program memory to be reprogrammed in-system or by a
conventional nonvolatile memory programmer. By combining a versatile 8-bit
CPU with in-system programmable Flash on a monolithic chip, the Atmel
AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-
effective solution to many embedded control applications.

3.1.1. 8051/52 PIN DIAGRAM

Figure 4.1: Pin Diagram of 8051


AT89S52 Architecture consists of these specific features:

8 bit CPU with registers A (Accumulator) and B

16 bit Program Counter(PC) and Data Pointer (DPTR)


16
8 bit Program Status Word (PSW)

8 bit Stack Pointer (SP)

Internal ROM of 8k

Internal RAM of 128 bytes

1. Four Register banks each containing eight registers

2. Sixteen bytes, which may be addressed at the bit level

3. Eighty bytes of general purpose data memory

32 I/O pins arranged as four 8-bit ports: P0,P1,P2,P3

Two 16-bit Timers/Counters: T0 and T1

Full duplex serial data Receiver/Transmitter : SBUF

Control Registers: TCON, TMOD, SCON, SMOD, PCON, IP and IE.

Two external and three internal interrupt sources.

Oscillator and Clock circuits.

3.1.2. PIN DESCRIPTION

3.1.2.1 Pin (32 39 ) Port 0: Port 0 is an 8-bit open drain bidirectional


port. As an open drain output port, it can sink eight LS TTL loads. Port 0
pins that have 1s written to them float, and in that state will function as
high impedance inputs. Port 0 is also the multiplexed low-order address
and data bus during accesses to external memory. In this application it
uses strong internal pull ups when emitting 1s. Port 0 emits code bytes
during program verification. In this application, external pull ups are
required.

3.1.2.2 Pin ( 1- 8 ) Port 1: Port 1 is an 8-bit bidirectional I/O port with internal
pull ups. Port 1 pins that have 1s written to them are pulled high by the internal

17
pull ups, and in that state can be used as inputs. As inputs, port 1 pins that are
externally being pulled low will source current because of the internal pull ups.

Alternate Functions of Port 1 used for in system Programmable

P.5 MOSI --------- Instruction Input

P.6 MISO --------- Data Output

P.7 SCK --------- Clock in

3.1.2.3 Pin (21 28) Port 2: Port 2 is an 8-bit bidirectional I/O port with
internal pull ups. Port 2 emits the high-order address byte during accesses to
external memory that use 16-bit addresses. In this application, it uses the strong
internal pull ups when emitting 1s.
3.1.2.4 Pin (10 17) Port 3: Port 3 is an 8-bit bidirectional I/O port with internal
pull ups. It also serves the functions of various special features of the 80C51
Family as follows:

Port Pin Alternate Function

P3.0- RxD (serial input port)

P3.1 -TxD (serial output port)

P3.2 -INT0 (external interrupt 0)

P3.3- INT1 (external interrupt 1)

P3.4 -T0 (timer 0 external input)

P3.5 -T1 (timer 1 external input)

P3.6 -WR (external data memory write strobe)

P3.7 -RD (external data memory read strobe)

3.1.2.5 Pin 40 VCC: -Supply voltage


3.1.2.6 Pin 20 VSS: -Circuit ground potential

18
3.1.2.7 Pin 29 PSEN: Program Store Enable is the read strobe to external
Program Memory. When the device is executing out of external Program Memory,
PSEN is activated twice each machine cycle (except that two PSEN activations are
skipped during accesses to external Data Memory). PSEN is not activated when
the device is executing out of internal Program Memory.

3.1.2.8 Pin 30 ALE/PROG: Address Latch Enable output pulse for latching the
low byte of the address during accesses to external memory. ALE is emitted at a
constant rate of 1/6 of the oscillator frequency, for external timing or clocking
purposes, even when there are no accesses to external memory. (However, one
ALE pulse is skipped during each access to external Data Memory.) This pin is
also the program pulse input (PROG) during EPROM programming.

3.1.2.9 Pin 31 EA/VPP: When External Access is held high the CPU executes
out of internal Program Memory. Holding EA low forces the CPU to execute out
of external memory regardless of the Program Counter value. In the 80C31, EA
must be externally wired low. In the EPROM devices, this pin also receives the
programming supply voltage (VPP) during EPROM programming.

3.1.2.10 Pin 18 XTAL1: Input to the inverting oscillator amplifier.

3.1.2.11 Pin 19 XTAL2: Output from the inverting oscillator amplifier

3.2 REGISTERS

8051 is a collection of 8 and 16 bit registers and 8 bit memory locations. These registers
and memory locations can be made to operate using the software instructions. The
program instructions control the registers and digital data paths that are contained inside
the 8051, as well as memory locations that are located outside the 8051.

Register are used to store information temporarily, while the information could be a byte
of data to be processed, or an address pointing to the data to be fetched. The vast majority
of 8051 register are 8-bit registers.

19
Generally there are two types of registers. They are General purpose Registers (GPRs)
and Special Function Registers (SFRs)
General Purpose Register

The 8 bits of a register are shown from MSB D7 to the LSB D0. With an 8-bit data type,
any data larger than 8 bits must be broken into 8-bit chunks before it is processed.

Figure 4.2: Register Set

The most widely used registers


A (Accumulator)
For all arithmetic and logic instructions
B, R0, R1, R2, R3, R4, R5, R6, R7
DPTR (data pointer), and PC (program counter)

16 bit General Purpose Registers: Data Pointer (DPTR) and Program Counter (PC)

The program counter points to the address of the next instruction to be executed. DPTR.
As the name suggests, is used to point the data. It is used by a number of commands
which allows the microcontroller to access external memory. When the microcontroller
access external memory it will access at the address indicated by DPTR.

20
There are 128 bytes of RAM in the 8051

The 128 bytes are divided into three different groups as follows:
1) A total of 32 bytes from locations 00 to 1F hex are set aside for register banks and the
stack
2) A total of 16 bytes from locations 20H to 2FH are set aside for bit-addressable
read/write memory
3) A total of 80 bytes from locations 30H to 7FH are used for read and write storage,
called scratch pad

3.2.1 SPECIAL FUNCTION REGISTERS

3.2.1.1 Program status word (PSW)

PSW register, also referred to as the flag register, is an 8 bit register Only 6 bits are used
These four are CY (carry), AC (auxiliary carry), P (parity), and OV (overflow)
They are called conditional flags, meaning that they indicate some conditions that
resulted after an instruction was executed. The PSW3 and PSW4 are designed as RS0 and
RS1, and are used to change the bank. The two unused bits are user-definable

21
3.3 TIMER/COUNTERS

The Atmel 89C51 Microcontrollers implement two general purpose, 16-bit timers/
counters. They can be used either as timers to generate a time delay or as a counter to
count events happening outside the microcontroller. The microcontroller has two 16-bit
wide timers. They are identified as Timer 0 and Timer 1, and can be independently
configured to operate in a variety of modes as a timer or as an event counter. When
operating as a timer, the timer/counter runs for a programmed length of time, then issues
an interrupt request. When operating as a counter, the timer/counter counts negative
transitions on an external pin. After a preset number of counts, the counter issues an
interrupt request. Register pairs (TH0, TL0), (TH1, TL1), and (TH2, TL2) are the 16-bit
counting registers for Timer/Counters 0, 1, and 2, respectively.
Timer 0 Register
The 16-bit register of Timer 0 is accessed as low byte and high byte. The low byte
register is called TL0 (Timer 0 low byte) and high byte register is referred to as TH0
(Timer 0 high byte). These registers can be accessed like any other register, such as A, B,
R0, R1, R2, etc.
Timer 1 Register
Timer 1 is also 16-bits, and its 16-bit register is split into two bytes, referred to as TL1
( Timer 1 low byte ) and TH1 ( Timer 1 high byte ). These registers are accessible in the
same way as the registers of timer 0.

TMOD Register (timer mode)

TMOD: Timer/Counter Mode Control Register.


Not Bit Addressable.

Timer 1 Timer 0

22
GATE When TRx (in TCON) is set and GATE=1, Timer/CounterX will
run only while Into pin is high (hardware control). When GATE=0,
Timer/Counter will run only while TRx=1 (software
control).

C/T Timer or Counter selector. Cleared for Timer operation (input from
internal system clock). Set for Counter operation (input from TX
input pin).
M1 Mode selector bit.
M0 Mode selector bit.

M1 M0 Mode Operating Mode


0 0 0 13-bit Timer (8048 compatible) (TH1)
0 1 1 16-bit Timer/Counter
1 0 2 8-bit Auto-Reload Timer/Counter (TL1).
Reloaded from TH1 at overflow.

1 1 3 timer 1 halted. Retains count.


1 1 3 (Timer 1) Timer/Counter 1 stopped.

TCON: Timer/Counter Control Register


Bit Addressable.

The upper four The lower 4 bits


Bits are used to Are set aside for
Store the TF and controlling the
TR bits of both interrupt bits
timer 0 and 1

TF1 Timer1 overflow flag. Set by hardware when the Timer/Counter 1


overflows. Cleared by hardware as processor vectors to the interrupt
service routine.
TR1 Timer 1 run control bit. Set/cleared by software to turn Timer/Counter 1
ON/OFF.

23
TF0 Timer0 overflow flag. Set by hardware when the Timer/Counter 0
overflows. Cleared by hardware as processor vectors to the service
routine.
TR0 Timer 0 run control bit. Set/cleared by software to turn Timer/Counter 0
ON/OFF.
IE1 External Interrupt 1 edge flag. Set by hardware when External interrupt
edge is detected. Cleared by hardware when interrupt is processed.
IT1 Interrupt 1 type control bit. Set/cleared by software to specify falling
edge/low level triggered External Interrupt.

IE0 External Interrupt 0 edge flag. Set by hardware when External Interrupt
edge is detected. Cleared by hardware when interrupt is processed.
IT0 Interrupt 0-type control bit. Set/cleared by software to specify falling
edge/low level triggered External Interrupt.

3.4 SERIAL COMMUNICATION

The 8051 serial port is full duplex. In other words, it can transmit and receive data at the
same time. Unlike any other register in the 8051, SBUF is in fact two distinct registers - the
write-only register and the read-only register. Transmitted data is sent out from the write-only
register while received data is stored in the read-only register. There are two separate data
lines, one for transmission (TXD) and one for reception (RXD). Therefore, the serial port can
be transmitting data down the TXD line while it is at the same time receiving data on the
RXD line. The TXD line is pin 11 of the microcontroller (P3.1) while the RXD line is on
pin 10 (P3.0)

Serial data communication uses two methods, asynchronous and synchronous. The
synchronous method transfers a block of data (characters) at a time, while the asynchronous
method transfers a single byte at a time. It is possible to write software to use either of these
methods, but the programs can be tedious and long. For this reason, there are special IC chips
made by many manufacturers for serial data communications. These chips can be commonly

24
referred to as UART (Universal Asynchronous Receiver-transmitter) and USART
( Universal Synchronous Asynchronous Receiver-Transmitter). The 8051 chip has a built-in
UART.

3.4.1. ASYNCHRONOUS SERIAL COMMUNICATION AND DATA FRAMING


Start Bits and Stop Bits
In the asynchronous method is character is placed between start and stop bits, this is called
data framing. In asynchronous communication, at least two extra bits are transmitted with the
data word; a start bit and a stop bit. Therefore, if the transmitter is using an 8-bit system, the
actual number of bits transmitted per word is ten. In most protocols the start bit is a logic 0
while the stop bit is logic 1. Therefore, when no data is being sent the data line is
continuously HIGH. The receiver waits for a 1 to 0 transition. In other words, it awaits a
transition from the stop bit (no data) to the start bit (logic 0). Once this transition occurs the
receiver knows a data byte will follow. Since it knows the data rate (because it is defined in
the protocol) it uses the same clock as frequency as that used by the transmitter and reads the
correct number of bits and stores them in a register. For example, if the protocol determines
the word size as eight bits, once the receiver sees a start bit it reads the next eight bits and
places them in a buffer. Once the data word has been read the receiver checks to see if the
next bit is a stop bit, signifying the end of the data. If the next bit is not logic 1 then
something went wrong with the transmission and the receiver dumps the data. If the stop bit
was received the receiver waits for the next data word, i.e.; it waits for a 1 to 0 transition.

Goes out first

Figure 3.3: Asynchronous Date Transfer

25
SCON (Serial Control) Register

SM0 SM1 SM2 REN TB8 RB8 TI RI

Table 3.1: SCON Register

Table 3.2
SM2 Enables the multiprocessor communication feature in Modes 2 and 3. In Mode 2 or
3, if SM2 is set to 1, then Rl will not be activated if the received 9th data bit (RB8) is 0.
In Mode 1, if SM2=1 then RI will not be activated if a valid stop bit was not received. In
Mode 0, SM2 should be 0.

REN Enables serial reception. Set by software to enable reception. Clear by software to
disable reception.

TB8 The 9th data bit that will be transmitted in Modes 2 and 3. Set or clear by software
as desired.

26
RB8 In Modes 2 and 3, is the 9th data bit that was received. In Mode 1, it SM2=0, RB8 is
the stop bit that was received. In Mode 0, RB8 is not used.

TI (Transmit Interrupt)
This is an extremely important flag bit in the SCON register. When the 8051 finishes the
transfer of the 8-bit character it raises the TI flag to indicate that it is ready to transfer
another byte. The TI bit is raised at the beginning of the stop bit.

RI (Receive Interrupt)
This is an extremely important flag bit in the SCON register. When the 8051 receives
data serially via RxD, it gets rid of the start and stop bits and places the byte in the SBUF
register. Then it raises the RI flag bit to indicate that a byte has been received and could
be picked up before it is lost.

3.5 INTERRUPTS

An interrupt is a special feature which allows the 8051 to provide the illusion of "multi-
tasking," although in reality the 8051 is only doing one thing at a time. The word
"interrupt" can often be substituted with the word "event."

An interrupt is triggered whenever a corresponding event occurs. When the event occurs,
the 8051 temporarily puts "on hold" the normal execution of the program and executes a
special section of code referred to as an interrupt handler. The interrupt handler performs
whatever special functions are required to handle the event and then returns control to the
8051 at which point program execution continues as if it had never been interrupted.

3.5.1 INTERRUPT SERVICE ROUTINE

For every interrupt, there must be an interrupt service routine (ISR). Or interrupt handler.
When an interrupt is invoked, the microcontroller runs the interrupt service routine. For
every interrupt, there is a fixed location in memory that holds the address of its ISR. The
group of memory locations set aside to hold the addresses of the ISRs is called interrupt
vector table.

27
Six Interrupts in 8051

1. Reset : When the reset pin is activated, the 8051 jumps to address location 0000
2. Two interrupts are set aside for the timers: one for the Timer 0 and one for
Timer1.

3. Two interrupts are set aside for hardware external interrupts : one for INT0 and
one for INT1

4. Serial communication has a single interrupt that belongs to both receive and
transmit.

28
CHAPTER 4

LCD DISPLAY, MAX232, LIMIT SWITCH, GPS AND GSM

4.1 ALPHANUMERIC LCD


Liquid Crystal Display also called as LCD is very helpful in providing user
interface as well as for debugging purpose. The most commonly used Character based
LCDs are based on Hitachi's HD44780 controller or other which are compatible with
HD44580. The most commonly used LCDs found in the market today are 1 Line, 2 Line
or 4 Line LCDs which have only 1 controller and support at most of 80 characters,
whereas LCDs supporting more than 80 characters make use of 2 HD44780 controllers.

4.1.1 PIN DESCRIPTION

Figure 4.1: LCD Display

Pin No. Name Description

29
1 VSS Power supply (GND)
2 VCC Power supply (+5V)
3 VEE Contrast adjust
0 = Instruction input
4 RS
1 = Data input
0 = Write to LCD module
5 R/W
1 = Read from LCD module
6 EN Enable signal
7 D0 Data bus line 0 (LSB)
8 D1 Data bus line 1
9 D2 Data bus line 2
10 D3 Data bus line 3
11 D4 Data bus line 4
12 D5 Data bus line 5
13 D6 Data bus line 6
14 D7 Data bus line 7 (MSB)
15 LED+ Back Light VCC
16 LED- Back Light GND

Table 5.1: Pin Description of LCD

4.1.1.1 DDRAM - Display Data RAM

Display data RAM (DDRAM) stores display data represented in 8-bit character
codes. Its extended capacity is 80 X 8 bits, or 80 characters.

4.1.1.2 CGROM - Character Generator ROM

Now you might be thinking that when you send an ASCII value to DDRAM, how
the character is displayed on LCD? So the answer is CGROM. The character
generator ROM generates 5 x 8 dot or 5 x 10 dot character patterns from 8-bit
character codes.

30
4.1.1.3 BF - Busy Flag

Busy Flag is a status indicator flag for LCD. When we send a command or data to
the LCD for processing, this flag is set (i.e. BF =1) and as soon as the instruction
is executed successfully this flag is cleared (BF = 0). This is helpful in producing
and exact amount of delay for the LCD processing.

4.1.1.4 Instruction Register (IR) and Data Register (DR):

There are two 8-bit registers in HD44780 controller Instruction and Data register.
Instruction register corresponds to the register where you send commands to LCD
e.g. LCD shift command, LCD clear, LCD address etc. and Data register is used
for storing data which is to be displayed on LCD. When the enable signal of the
LCD is asserted, the data on the pins is latched in to the data register and data is
then moved automatically to the DDRAM and hence is displayed on the LCD.
Data Register is not only used for sending data to DDRAM but also for CGRAM.

Commands and Instruction set:

Only the instruction register (IR) and the data register (DR) of the LCD can be controlled
by the MCU. Before starting the internal operation of the LCD, control information is
temporarily stored into these registers to allow interfacing with various MCUs, which
operate at different speeds, or various peripheral control devices. The internal operation
of the LCD is determined by signals sent from the MCU. These signals, which include
register selection signal (RS), read/write signal (R/W), and the data bus (DB0 to DB7),
make up the LCD instructions.

4.2. 2x16 LCD DISPLAY

As a low power alternative to LEDs and 7-segment LED-displays, small


Liquid Crystal Displays (LCD) with only a limited number of segments are becoming

31
more and more popular. Due to complex driving waveforms, interfacing to LCDs has
traditionally been done via a hardware driver either integrated in the LCD or MCU. But
as the complexity of the waveform is dependent on the number of back planes in the
LCD, these small LCDs with few common lines are less complex and software interfaces
can be suitable. This application note describes software driving of LCDs with one
common line, using the static driving method.

5.2.1. FEATURES

Software driver for displays with one common line


Suitable for parts without on-chip hardware for LCD driving
Control up to 15 segments using 16 IO lines
Fully interrupt driven operation
Designate LCD functions, such as display format, data length, etc.
Set internal RAM addresses
Perform data transfer with internal RAM
Perform miscellaneous functions

5.2.2. SENDING COMMANDS TO LCD

To send commands we simply need to select the command register. Everything is same as
we have done in the initialization routine. But we will summarize the common steps and
put them in a single subroutine. Following are the steps:
move data to LCD port
select command register
select write operation
send enable signal
wait for LCD to process the command

5.2.3. SENDING DATA TO LCD

To send data we simply need to select the data register. Everything is same as the
command routine. Following are the steps:

move data to LCD port


select data register
select write operation
send enable signal
wait for LCD to process the data

32
Figure 5.2: LCD

LCD (Liquid Crystal Display) screen is an electronic display module and find a wide
range of applications. A 16x2 LCD display is very basic module and is very commonly
used in various devices and circuits. These modules are preferred over seven segments
and other multi segment LEDs. The reasons being: LCDs are economical; easily
programmable; have no limitation of displaying special & even custom characters (unlike
in seven segments), animations and so on.

A 16x2 LCD means it can display 16 characters per line and there are 2 such
lines. In this LCD each character is displayed in 5x7 pixel matrix. This LCD has two
registers, namely, Command and Data. The command register stores the command
instructions given to the LCD. A command is an instruction given to LCD to do a
predefined task like initializing it, clearing its screen, setting the cursor position,
controlling display etc. The data register stores the data to be displayed on the LCD. The
data is the ASCII value of the character to be displayed on the LCD.

5.3. RS 232
The most popular serial communication standard for asynchronous
communications is RS-232 (Recommended Standard 232. This specifies the rule of
how different connected devices communicate. The connected devices can either be
terminals or communication equipments commonly referred as DTE & DCE.

According to RS232 interface, it requires only 3 lines i.e. Rx, Tx & Ground when
compared to the bunch of connectors required for parallel communication. Even though

33
parallel communication is easier to establish, serial communication is preferred based on
the costs for the communication lines.

The EIA (Electronics Industry Association) RS232C Standard specifies &


suggests a maximum baud rate of 20,000bps, and RS232D is an advanced version of the
same, which allows 1.5 Mbps. The connectors specified are D-TYPE 25 pin connector
and D-TYPE 9 pin connector. Here we use DB-9 connector in our hardware

Figure 5.3: DB-9 pin connector

According to RS 232 specifications, the logic 1 and logic 0 are called as mark
& space. The signal voltage levels are specified as mark should be in the range of -3 to
-15 volts and space should be in the range of 3 to 15 volts. The modern low power
consuming CMOS devices use different logic levels than the RS 232 line specification.
The logic levels of CMOS devices are in the range of 3.3v-5.5v for 1 and -0.3v
to 0.8v for 0. Therefore when communicating with such CMOS/TTL devices, the logic
levels need to be converted

5.4. MAX 232


The integrated circuit RS-232 TTL MAX232 is an IC that converts signals from an
serial port to signals suitable for use in compatible digital logic circuits. The MAX 232 is
a dual driver/receiver and typically converts the RX, TX, CTS and RTS signals.
The drivers provide RS 232 voltage level outputs (approx. 7.5 V) from a single +
5 V supply via on-chip charge pumps power supply and external capacitors. This makes it
useful for implementing RS 232 in devices that otherwise do not need any voltages
34
outside the 0 V to + 5 V range, as design does not need to be made more complicated just
for driving the RS 232 in this case.
The receivers reduce RS 232 inputs (which may be as high as 25 V), to standard 5
V TTL hysteresis levels. These receivers have a typical threshold of 1.3 V, and a typical
of 0.5 V. The newer MAX3232 is also backwards compatible and operates at a broader
voltage range, from 3 to 5.5 V.

Figure 5.4: MAX 232

LEVEL CONVERSION

35
RS-232 TTL LOGIC

-25V to-3V +2V to+5V High

+3V to+25V 0V to 0.8V Low

Table 5.2: MAX 232 Logic Level Conversion

5.4.1. PIN CONFIGURATION

Figure 5.5: MAX 232 Pin Configuration

36
Table 5.3: Pin Description MAX 232

5.5. RS 232 INTERFACED TO MAX 232

J2
C 1
U3 1uf
9 5
16

8 4 13 12 P 3 .0 R XD
7 3 T1O U T 8 R 1 IN R 1O U T 9
VC C

6 2 R 2 IN R 2O U T
1 10 14 T1O U T
T XD P 3 .1 11 T 2 IN T1O U T 7
C 4 T 1 IN T2O U T
5V 1
3 C 1+
C0 . 51 u f 4 C 1-
5 C 2+
C6 C 2-
0 .1 u f 2
0 .1 u f V+
GN D

6
V-
C7
M A X3232
15

0 .1 u f

Figure 5.6: RS232 INTERFACED TO MAX232

37
RS 232 is 9 pin db connector, only three pins of this are used ie 2, 3, 5 the transmit pin of
RS 232 is connected to rx pin of microcontroller

5.6. MAX232 INTERFACED TO MICROCONTROLLER

Figure 5.7: MAX 232 Interfaced tFo Microcontroller

MAX 232 is connected to the microcontroller as shown in the figure above 17, 18 pins
are connected to the TX and RX pin i.e. transmit and receive pin of microcontroller

4.7 LIMIT SWITCH OR CIRCUIT BREAKER SWITCH

It is used as circuit breaker in the circuits.

Figure 5.8: Limit Switch

38
Micro-switches are a simple switch that is turned on and off via a small lever that sticks
out of the top. This switch would be placed at the end of an axes travel, and as soon as the
moving gantry slides to the end of the travel and hits the switch the computer will detect
this and stop the machine dead in its tracks.

Most micro-switches youll see have three connections or terminals. They are: Common,
NC and NO. NC and NO stand for Normally Closed and Normally Open.

Normally Closed will pass the voltage you put in to the common terminal.

Normally Open will open the circuit when the switch is untouched and its lever is in the
open position.

This switch is widely used in control system applications such as a door interlock, safety
switches in elevators, vending machines etc. Having a diverse range of engineering
applications, micro switches are available in various switch configurations, housing
materials, actuator styles etc.

4.8 GLOBAL SYSTEM FOR MOBILE COMMUNICATION (GSM)


4.8.1 DEFINITION:
Global system for mobile communication (GSM) is a globally accepted standard for
digital cellular communication. GSM is the name of a standardization group established
in 1982 to create a common European mobile telephone standard that would formulate
specifications for a pan-European mobile cellular radio system operating at 900 MHz.

A GSM modem is a wireless modem that works with a GSM wireless network. A wireless
modem behaves like a dial-up modem. The main difference between them is that a dial-
up modem sends and receives data through a fixed telephone line while a wireless
modem sends and receives data through radio waves.

Like a GSM mobile phone, a GSM modem requires a SIM card from a wireless carrier in
order to operate.
39
As mentioned in earlier sections of this SMS tutorial, computers use AT commands to
control modems. Both GSM modems and dial-up modems support a common set of
standard AT commands. You can use a GSM modem just like a dial-up modem.

In addition to the standard AT commands, GSM modems support an extended set of AT


commands. These extended AT commands are defined in the GSM standards. With the
extended AT commands, you can do things like:

Reading, writing and deleting SMS messages.


Sending SMS messages.
Monitoring the signal strength.
Monitoring the charging status and charge level of the battery.
Reading, writing and searching phone book entries.

4.8.2 COMMUNICATION WITH GSM

AT commands are required. Microcontroller sends these commands to the GSM


modem, which is then activated to perform the required operation.

Command Operation
AT+CSMS Select message service.
AT+CMGF Message format.
AT+CMGL List messages.
AT+CMGR Read message.
AT+CMGS Send message.
AT+CMGD Delete message.
ATA Answer a call.
ATD Dial a number.
ATDL Dial the last outgoing number

ATH Hang up the call.

Table 5.1: GSM AT Commands

40
The number of SMS messages that can be processed by a GSM modem per minute is
very low -- only about six to ten SMS messages per minute.

4.8.3 GSM INTERFACE WITH MICROCONTROLLER

Figure 6.1: GSM interface with Microcontroller


In this project GSM Modem is interfaced with the microcontroller through rs232
interface. Since the voltage levels of the microcontroller are different with that of the
GSM modem we use a voltage converter or the line driver such as MAX232 to make
them RS232 compatible.
GSM and GPS both communicate through UART. Since microcontroller has only one
inbuilt UART a multiplexer is used to interface GSM and GPS to the microcontroller.

41
4.9 GLOBAL POSITIONING SYSTEM (GPS)

4.9.1 INTRODUCTION OF GPS

Global Positioning System (GPS) technology is changing the way we work and play. You
can use GPS technology when you are driving, flying, fishing, sailing, hiking, running,
biking, working, or exploring. With a GPS receiver, you have an amazing amount of
information at your fingertips. Here are just a few examples of how you can use GPS
technology.

Know precisely how far you have run and at what pace while tracking your path so you

can find your way home.

Pinpoint the perfect fishing spot on the water and easily relocate it

Get the closest location of your favorite restaurant when you are out-of-town

Find the nearest airport or identify the type of airspace in which you are flying

4.9.2 WHAT IS GPS?

The Global Positioning System (GPS) is a satellite-based navigation system that sends
and receives radio signals. A GPS receiver acquires these signals and provides you with
information.

Using GPS technology, you can determine location, velocity, and time, 24 hours a day, in
any weather conditions anywhere in the worldfor free GPS, formally known as the
NAVSTAR (Navigation Satellite Timing and Ranging) Global Positioning System,
originally was developed for the military. Because of its popular navigation capabilities
and because you can access GPS technology using small inexpensive equipment, the
government made the system available for civilian use. The USA owns GPS technology
and the Department of Defense maintains it.

42
GPS technology requires the following three segments

Space segment

Control segment

User segment

4.9.2.1 Space Segment

At least 24 GPS satellites orbit the earth twice a day in a specific pattern. They
travel at approximately 7,000 miles per hour about 12,000 miles above the earths
surface. These satellites are spaced so that a GPS receiver anywhere in the world can
receive signals from at least four of them.

Each GPS satellite constantly sends coded radio signals to the earth. These GPS satellite
signals contain the following information

The particular satellite that is sending the information

Where that satellite should be at any given time (the precise location of the satellite is

called ephemeris data)

Whether or not the satellite is working properly

The date and time that the satellite sent the signal

The signals can pass through clouds, glass, and plastic. Most solid objects such as
buildings attenuate (decrease the power of) the signals. These signals cannot pass through
objects that contain a lot of metal or objects that contain water (such as underwater
locations). The GPS satellites are powered by solar energy. If solar energy is unavailable,
for example, when the satellite is in the earths shadow, the satellites use backup batteries
to continue running.

43
4.9.2.2 Control Segment

The control segment is responsible for constantly monitoring satellite health,


signal integrity, and orbital configuration from the ground. The control segment includes
the following sections.

Master control station

Monitor stations

Ground antennas

1. Monitor Stations

At least six unmanned monitor stations are located around the world. Each station
constantly monitors and receives information from the GPS satellites and then
sends the orbital and clock information to the master control station (MCS).

2. Master Control Station (MCS)

The MCS is located near Colorado Springs in Colorado. The MCS constantly
receives GPS satellite orbital and clock information from the monitor stations.
The controllers in the MCS make precise corrections to the data as necessary, and
send the information (known as ephemeris data) to the GPS satellites using the
ground antenna.

3. Ground Antennas

Ground antennas receive the corrected orbital and clock information from the
MCS, and then send the corrected information to the appropriate satellites.

44
4.9.2.3. User Segment

The GPS user segment consists of our GPS receiver. The receiver collects and
processes signals from the GPS satellites that are in view and then uses that information
to determine and display your location, speed, time, and so forth. The GPS receiver does
not transmit any information back to the satellites.

4.9.3 GPS INTERFACE WITH MICROCONTROLLER

Figure 6.2: GPS Interface with Microcontroller


In this project GPS Modem is interfaced with the microcontroller through RS232
interface. Since the voltage levels of the microcontroller are different with that of the
GPS modem we use a voltage converter or the line driver such as MAX232 to make them
RS232 compatible.

45
CHAPTER-5
RESULT

We a team of 4 members have successfully completed our Project on Tracking Down


Vehicle and Locking it remotely using GPS and GSM technologies.
We first tried to understand the working of our project through the schematic and
then we proceeded to build the circuit as per the schematic. Initially we faced few
problems with the LCD Display as we were not able to solder and tune it in proper way.
Then with GPS modem, as it wont work efficiently inside buildings. And also the
GSM modem suffered problems with the coverage area of the Mobile Service Provider.
So, we used Airtel as it has maximum coverage area.

The overall developed circuit looks as in the following figure:

Figure 8.1: Accident Identification Project Circuit

46
The final output has been obtained and it is displayed on the mobile as shown
below.

This project can further be crafted by restricting the usage of limited mobile
numbers to get access to the device. This can be made by altering the program.

47
CONCLUSION AND FUTURE SCOPE
The project titled Accident Identification using GSM and GPS is a model for
vehicle tracking unit with the help of GPS receivers and GSM modem. To improve
safety, security and efficiency of the transportation systems and enable new mobile
services and applications for the travelling public, intelligent transportation systems have
been developed, which apply rapidly emerging information technologies in vehicles and
transportation.
Thus, this project is essential in tracking the location and sending the message to its
owner. Vehicle tracking both in case of personal as well as business purpose improves
safety and security, communication medium, performance monitoring and increases
productivity. So in future, it is going to play a major role in our day-to-day living. Finally
the aim of the project i.e. to trace the vehicle is successfully achieved.

FUTURE SCOPE

We can use the EEPROM to store the previous Navigating positions up to 256
locations and we can navigate up to N number of locations by increasing its
memory.
We can reduce the size of the kit by using GPS+GSM on the same module.
We can increase the accuracy up to 3m by increasing the cost of the GPS
receivers.
We can use our kit for detection of bomb by connecting to the bomb detector.
With the help of high sensitivity vibration sensors we can detect the accident.
Whenever vehicle unexpectedly had an accident on the road with help of vibration
sensor we can detect the accident and we can send the location to the owner,
hospital and police.
We can use our kit to assist the traffic. By keeping the kits in the entire vehicles
and by knowing the locations of all the vehicles.
If anybody steals our car we can easily find our car around the globe. By keeping
vehicle positioning vehicle on the vehicle.
48
REFERENCES

1. Jorge Zaldivar, Carlos T. Calafate, Juan Carlos Cano,Pietro Manzoni Providing


Accident Detection inVehicular Networks Through OBD-II Devices and Android-
based Smartphones in 5th IEEE Workshop On User Mobility and Vehicular
Networks 2011 pp no :978-1-61284-928-7.

2. Manuel Fogue,Piedad Garrido, Francisco J. Martinez,Juan-Carlos Cano, Carlos T.


Calafate, and Pietro Manzoni Assistance Through Communication Technologies and
Vehicles IEEE Vehicular Technology Magazine 2012 pp no : 1556-6072.

3. Prabakar S, Member IEEE, Porkumaran K, SM IEEE, Samson Isaac J and Guna


Sundari J An Enhanced Accident Detection And Victim Status Indicating System:
Prototype in 2012 pp no: 978-1-4673-2272-0.

4. Md. Syedul Amin, Jubayer Jalil, M. B. I. Reaz Accident Detection and Reporting
System using GPS,GPRS and GSM Technology in IEEE/OSA/IAPR International
Conference on Informatics, Electronics & Vision in 2012 pp no : 978-1-4673-1154-
0/12.

5. C.Vidya Lakshmi, J.R.Balakrishnan Automatic Accident Detection via Embedded


GSM message interface with Sensor Technology in International Journal of
Scientific and Research Publications, Volume 2, Issue 4, April 2012 1 ISSN 2250-
3153.

6. R. Rathinakumar and D. Manivannan Wireless Accident Information System Using


GSM and GPS in Research Journal of Applied Sciences, Engineering and
Technology 4(18): 3323-3326, 2012, ISSN: 2040-7467.

49
7. http://en.wikipedia.org/wiki/Embedded_system
8. http://www.electronicshub.org/
9. http://www.researchgate.net/
10. http://ieeexplore.ieee.org/
11. The 8051 Microcontroller and Embedded Systems: Using Assembly and C
MAZIDI
12. http://www.projectsof8051.com/vehicle-accident-detection-with-gps-and-gsm-
modem/
13. International Journal of Technological Exploration and Learning (IJTEL) Volume 1
Issue 1 (August 2012)

50
APPENDIX

Program Code:
#include<reg52.h>
#include<string.h>
#define LCD P2

sbit sw=P1^0;
sbit led=P1^2;

bit flag = 0;
bit r_flag = 0;
bit sucess = 0;

int i=0;
//unsigned char LCD;

void gps(void);
void send(void);
char idata buff[150];
char idata num[15];
char idata mes[5];
void send_chr(unsigned char);
bit vl=0,li=0;

void delay_ms(unsigned int i)


{
unsigned int j;
while(i-->0)
{
for(j=0;j<500;j++);
}
}

void cmd_lcd(unsigned char c)


{
unsigned char temp;
unsigned char LCD;
temp=c>>4;
LCD=temp<<4|0x02; //logical or with 0x02 since rs(rs=0) & en(en=1) are
LCD=0; //connected to p2.0 & p2.1 respectively
//transmit low byte
LCD=c<<4|0x02;

51
LCD=0;
delay_ms(2); //delay 2 milliseconds
}

void init_lcd(void)
{
delay_ms(10); //delay 10 milliseconds
cmd_lcd(0x28); //4 bit initialize, 5x7 character font, 16x2 display
cmd_lcd(0x0c); //lcd on, cursor on
cmd_lcd(0x06); //right shift cursor automatically after each character is displayed
cmd_lcd(0x01); //clear lcd
}

void write_lcd(unsigned char c)


{
unsigned char temp;
unsigned char LCD;
temp=c>>4;
LCD=temp<<4|0x03; //logical or with 0x03 since rs(rs=1) & en(en=1) are
LCD=0;
LCD=c<<4|0x03;
LCD=0;
delay_ms(2);
}

void display_lcd(unsigned char *s)


{
while(*s)
write_lcd(*s++);
}

void transmit(unsigned char *t_data)


{
while(*t_data!='\0')
{
SBUF = *t_data;
while(!TI);
TI=0;
t_data++;
delay_ms(30);
}
}

52
void main()
{
int I;
char t=0;
P0=0XFF;
TMOD=0x21;
SCON=0x50;
TH1=0XFD;
TR1=1;
led=0;
init_lcd();
display_lcd("ACCIDENT DETCTION ");
cmd_lcd(0XC0);
display_lcd("USING GSM ");
delay_ms(1000);

while(1)
{
if(sw==1)
{
led=1;
P0=0xFF;
init_lcd();
display_lcd("ACCIDENT OCCURED ");
delay_ms(1000);
gps();
init_lcd();
display_lcd("sending sms........");
delay_ms(1500);
transmit("AT+CMGS=")
SBUF=' " ';
while(!TI);
TI=0;
transmit("7032915004");
SBUF=' " ';
while(!TI);
TI=0;
SBUF=0x0d;
while(!TI);
TI=0;
transmit("ACCIDENT OCCURRED\r\n");
SBUF=0x1a;
while(!TI);
TI=0;
delay_ms(10);

53
transmit("AT+CMGS=");
SBUF='"';
while(!TI);
TI=0;
transmit("");
SBUF='"';
while(!TI);
TI=0;
SBUF=0x0d;
while(!TI);
TI=0;
}
else
{
init_lcd();
display_lcd("ACIDENT DETCTION ");
cmd_lcd(0XC0);
display_lcd("USING GSM ");
delay_ms(1000);
}
}
}

void gps(void)
{
unsigned int i,j;
i=0,j=0;
EA=0;

init_lcd();
cmd_lcd(0x01);
display_lcd("GPS TRACKING.........");
delay_ms(1000);
while(i<1)
{
while(!RI);
RI=0;
buff[j]=SBUF;
if(SBUF==0x0d)
i++;
j++;
}
cmd_lcd(0x01);
buff[j]='\0';

54
if((buff[4]=='G')||(buff[5]=='G'))
{
cmd_lcd(0x01);
display_lcd("LONGITUDE: ");
cmd_lcd(0xc0);
//write_lcd(buff[18]);
write_lcd(buff[19]);
write_lcd(buff[20]);
write_lcd(buff[21]);
write_lcd(buff[22]);
write_lcd(buff[23]);
write_lcd(buff[24]);
write_lcd(buff[25]);
write_lcd(buff[26]);
write_lcd(buff[27]);
write_lcd(buff[28]);
write_lcd(buff[29]);
delay_ms(1000);
cmd_lcd(0x01);
display_lcd("LATITUDE:");
cmd_lcd(0xc0);
write_lcd(buff[30]);
write_lcd(buff[31]);
write_lcd(buff[32]);
write_lcd(buff[33]);
write_lcd(buff[34]);
write_lcd(buff[35]);
write_lcd(buff[36]);
write_lcd(buff[37]);
write_lcd(buff[38]);
write_lcd(buff[39]);
write_lcd(buff[40]);
write_lcd(buff[41]);
write_lcd(buff[42]);
delay_ms(1000);
}
else
{
gps();
}
}

55
void send()
{
i=19;
while(i<=45)
{
SBUF = buff[i];
while(!TI);
TI=0;
i++;
}
}

56
CHAPTER 7

SOFTWARE IMPLEMENTATION
KEIL SOFTWARE

7.1. INTRODUCTION
Many companies provide the 8051 assembler, some of them provide shareware
version of their product on the Web, Kiel is one of them. We can download them from
their Websites. However, the size of code for these shareware versions is limited and we
have to consider which assembler is suitable for our application.

7.2 KEIL UVISION2


Kiel uVision2is an IDE (Integrated Development Environment) that helps you
write, compile, and debug embedded programs. It encapsulates the following
components:
A project manager
A make facility.
Tool configuration
Editor
A powerful debugger
To help you get started, several example programs

7.2.1. CREATING YOUR OWN APPLICATION IN UVISION2


To create a new project in uVision2, you must:
Select Project - New Project
Select a directory and enter the name of the project file.
Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from
the device database.
Create source files to add to the project.
Select Project - Targets, Groups, and Files Add/Files, select Source Group1, and
add the source files to the project.

57
Select Project - Options and set the tool options. Note when you select the target
device from the Device Database all-special options are set automatically.
Typically, we need to configure the memory map of your target hardware. Default
memory model settings are optimal for most.

7.3 KEIL SOFTWARE PROGRAMMING PROCEDURE


How to write embedded C program in Keil Software?
Following steps are to be followed in order to develop code and test the equipment
with software.
7.3.1 PROCEDURE STEPS
Step-1:
Install KEIL MicroVision-2 in your PC, Then after Click on that KEIL UVision-2
icon. After opening the window go to toolbar and select Project Tab then close
previous project.

Step-2:
Next select New Project from Project Tab.
Step-3:
Then it will open Create New Project window. Select the path where you want
to save project and edit project name.

58
Step-4:
Next it opens Select Device for Target window, It shows list of companies and
here you can select the device manufacturer company.
Step-5:
For an example, for your project purpose you can select the chip as 89c51/52
from Atmel Group. Next Click OK Button, it appears empty window here you can
observe left side a small window i.e, Project Window. Next create a new file.
Step-6:
After editing the program save the file with extension as .c or .asm, if you
write a program in Assembly Language save as .asm or if you write a program
in C Language save as .c in the selected path.
Step-7:
Then after saving the file, compile the program. For compilation go to project
window select source group and right click on that and go to Add files to
Group.

59
Step-10:
Here it will ask which file has to Add. For an example here you can add test.c as
you saved before.
Step-11:
After adding the file, again go to Project Window and right click on your c file
then select Build target for compilation. If there is any Errors or Warnings in
your program you can check in Output Window that is shown bottom of the Keil
window.
Step-14:
After compilation then next go to Debug Session. In Tool Bar menu go to Debug
tab and select Start/Stop Debug Session.
Step-19: After completion of Debug Session Create an Hex file for Burning the
Processor. Here to create an Hex file go to project window and right click on Target
next select Option for Target.

60
Step-20:
It appears one window; here in target tab modify the crystal frequency as you
connected to your microcontroller.
Step-21:
Next go to Output tab. In that Output tab click on Create HEX File and then
click OK.
Step-22:
Finally Once again compile your program. The Created Hex File will appear in your
path folder.

61
7.4 APPLICATIONS OF KEIL SOFTWARE
Select Project - Rebuild all target files or Build target.

7.4.1. DEBUGGING AN APPLICATION IN UVISION2

To debug an application created using uVision2,


You must:
Select Debug - Start/Stop Debug Session.
Use the Step toolbar buttons to single-step through your program. You may enter G,
main in the Output Window to execute to the main C function.
Open the Serial Window using the Serial #1 button on the toolbar.
Debug your program using standard options like Step, Go, Break, and so on.

7.4.2. PERIPHERAL SIMULATION

The uvision2 debugger provides complete simulation for the CPU and on chip
peripherals of most embedded devices. To discover which peripherals of a device are
supported, in u vision2. Select the Simulated Peripherals item from the Help menu. You
may also use the web-based device database. We are constantly adding new devices and
simulation support for on-chip peripherals so be sure to check Device Database often.

62
63

Potrebbero piacerti anche