Vehicular Security System

37
ADVANCED VEHICLE SECURITY SYSTEM CHAPTER 1 INTRODUCTION The rapid development of electronics provides secured environment to the human. As a part of this ‘ADVANCED VEHICLE SECURITY SYSTEM WITH THEFT CONTROL AND ACCIDENT NOTIFICATION’ is designed to reduce the risk involved in losing the vehicle and providing accident notification which will reduce the rate of deaths. This tracking system is composed of a GPS receiver, Microcontroller and a GSM Modem. GPS Receiver gets the location information from satellites in the form of latitude and longitude This is an inexpensive device which reduces the problem associated with accident notification and antitheft control.

description

Vehicle Security System

Transcript of Vehicular Security System

Page 1: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

CHAPTER 1

INTRODUCTION

The rapid development of electronics provides secured environment to the human. As a part of

this ‘ADVANCED VEHICLE SECURITY SYSTEM WITH THEFT CONTROL AND ACCIDENT

NOTIFICATION’ is designed to reduce the risk involved in losing the vehicle and providing accident

notification which will reduce the rate of deaths.

This tracking system is composed of a GPS receiver, Microcontroller and a GSM Modem. GPS

Receiver gets the location information from satellites in the form of latitude and longitude

This is an inexpensive device which reduces the problem associated with accident notification

and antitheft control.

Page 2: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

CHAPTER 2

DESCRIPTION OF THE PROJECT

Fig 2.1 Block diagram of the project.

Explanation:

In this project the GPS is used to provide the exact position of the vehicle. The information that is

collected by the GPS modem is passed to the microcontroller on its request. The information provided by the

GPS system contains longitudinal and latitude positions .It also provide the speed and time of the vehicle.

Here we use PIC17f877A microcontroller. It mainly controls the all function of the project. It gets the

information fro the GPS modem and passed it to the GSM modem. It controls the ignition sensor and accident

sensor.

GSM modem is used to send messages to the predefined numbers stored in the microcontroller. This GSM

modem uses AT commands in order to send messages to the predefined number.

Page 3: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

Fig.2.2 Schematic Diagram of the project.

Page 4: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

CHAPTER 3

HARDWARE ANALYSIS

3.1. Power supply Power supply is the major concern for every electronic device .Since the controller and other devices used are

low power devices there is a need to step down the voltage and as well as rectify the output to convert the

output to a constant dc.

3.1.1 Transformer Transformer is a device used to increment or decrement the input voltage given as per the requirement. The

transformers are classified into two types depending upon there functionality.

· Step up transformer · Step down transformer

Here we use a step down transformer for stepping down the house hold ac power supply i.e. the 230-240v

power supply to 5 v .We use a 5-0-5 v center tapped step down transformer.

3.1.2 Rectifier The output of the transformer is an ac and should be rectified to a constant dc for this it is necessary to feed the

output of the transformer to a rectifier.

The rectifier is employed to convert the alternating ac to a constant dc. There are many rectifiers available

in the market some of them are:-

· Half wave rectifier

· Full wave rectifier

· Bridge rectifier

The rectification is done by using one or more diodes connected in series or parallel.

If only one diode is used then only first half cycle is rectified and it is termed as half wave rectification

and the rectifier used is termed as Half wave rectifier. If two diodes are employed in parallel then both

Page 5: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

positive and negative half cycles are rectified and this is full wave rectification and the rectifier is termed as

Full wave rectifier.

If the diodes are arranged in the form of bridge then it is termed as Bridge rectifier, it acts as a full wave

rectifier.

These rectifiers are available in the market in the form of integrated chips (I.Cs)

3.1.3 Voltage regulator The voltage regulator is used for the voltage regulation purpose. We use IC 7805 voltage regulator.

The IC number has a specific significance. The number 78 represents the series while 05 represent the

output voltage generated by the IC.

3.1.4 Light emitting diode We employ a light emitting diode for testing the functionality of the power supply circuit. Here we use a 5 volts

LED which is connected in series with the power supply circuit it verifies the functioning of the power supply.

LED’s are also employed in other areas for many purposes. The fallowing are the advantages of using

LED’s.

· It helps us while troubleshooting the device i.e. when the device is malfunctioning it would be

easy to detect where the actual problem araised

· LED employed with microcontroller verifies whether data is being transmitted

· It verifies the functionality of the power supply.

3.2 Microcontroller PIC16F877A

3.2.1. Introduction

The PIC16F877A CMOS FLASH-based 8-bit microcontroller is upward compatible with the PIC16C5x,

PIC12Cxxx and PIC16C7x devices. It features 200 ns instruction execution, 256 bytes of EEPROM data

memory, self programming, an ICD, 2 Comparators, 8 channels of 10-bit Analog-to-Digital (A/D) converter, 2

capture/compare/PWM functions, a synchronous serial port that can be configured as either 3-wire SPI or 2-

wire I2C bus, a USART, and a Parallel Slave Port.

Page 6: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

3.2.3. High-Performance RISC CPU

Ø Lead-free; RoHS-compliant

Ø Operating speed: 20 MHz, 200 ns instruction cycle

Ø Operating voltage: 4.0-5.5V

Ø Industrial temperature range (-40° to +85°C)

Ø 15 Interrupt Sources

Ø 35 single-word instructions

Ø All single-cycle instructions except for program branches (two-cycle)

3.2.4 Special Microcontroller Features

Ø Flash Memory: 14.3 Kbytes (8192 words)

Ø Data SRAM: 368 bytes

Ø Data EEPROM: 256 bytes

Ø Self-reprogrammable under software control

Ø In-Circuit Serial Programming via two pins (5V)

Ø Watchdog Timer with on-chip RC oscillator

Ø Programmable code protection

Ø Power-saving Sleep mode

Ø Selectable oscillator options

Ø In-Circuit Debug via two pins

3.2.5Peripheral Features

Ø 33 I/O pins; 5 I/O ports

Ø Timer0: 8-bit timer/counter with 8-bit prescaler

Ø Timer1: 16-bit timer/counter with prescaler

Ø Can be incremented during Sleep via external crystal/clock

Ø Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler

Ø Two Capture, Compare, PWM modules

Ø 16-bit Capture input; max resolution 12.5 ns

Ø 16-bit Compare; max resolution 200 ns

Ø 10-bit PWM

Ø Synchronous Serial Port with two modes:

Ø SPI Master

Ø I2C Master and Slave

Page 7: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

Ø USART/SCI with 9-bit address detection

Ø Parallel Slave Port (PSP)

Ø 8 bits wide with external RD, WR and CS controls

Ø Brown-out detection circuitry for Brown-Out Reset

Ø Analog Features

Ø 10-bit, 8-channel A/D Converter

Ø Brown-Out Reset

3.2.6 Analog Comparator module

Ø 2 analog comparators

Ø Programmable on-chip voltage reference module

Ø Programmable input multiplexing from device inputs and internal VREF

Ø Comparator outputs are externally accessible

Program memory (FLASH) is used for storing a written program.

Since memory made in FLASH technology can be programmed and cleared more than once, it makes this

microcontroller suitable for device development.

EEPROM - data memory that needs to be saved when there is no supply.

It is usually used for storing important data that must not be lost if power supply suddenly stops. For instance,

one such data is an assigned temperature in temperature regulators. If during a loss of power supply this data

was lost, we would have to make the adjustment once again upon return of supply. Thus our device looses on

self-reliance.

RAM - Data memory used by a program during its execution.

In RAM are stored all inter-results or temporary data during run-time.

PORTS are physical connections between the microcontroller and the outside world. PIC16F877A has five I/O

Ports and 33 pins in all 5 ports.

FREE-RUN TIMER is an 8-bit register inside a microcontroller that works independently of the program.

On every fourth clock of the oscillator it increments its value until it reaches the maximum (255), and then it

starts counting over again from zero. As we know the exact timing between each two increments of the timer

contents, timer can be used for measuring time which is very useful with some devices.

Page 8: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

CENTRAL PROCESSING UNIT has a role of connective element between other blocks in the

microcontroller. It coordinates the work of other blocks and executes the user program.

Fig.3.1 Architectures of the System.

CISC, RISC

It has already been said that PIC16F877A has a RISC architecture. This term is often found in computer

literature, and it needs to be explained here in more detail. Harvard architecture is a newer concept than von-

Neumann's. It rose out of the need to speed up the work of a microcontroller. In Harvard architecture, data bus

and address bus are separate. Thus a greater flow of data is possible through the central processing unit, and of

course, a greater speed of work. Separating a program from data memory makes it further possible for

instructions not to have to be 8-bit words. PIC16F877A uses 14 bits for instructions which allows for all

instructions to be one word instructions. It is also typical for Harvard architecture to have fewer instructions

than von-Neumann's, and to have instructions usually executed in one cycle.

Microcontrollers with Harvard architecture are also called "RISC microcontrollers". RISC stands for

Reduced Instruction Set Computer. Microcontrollers with von-Neumann's architecture are called 'CISC

microcontrollers'. Title CISC stands for Complex Instruction Set Computer.

Since PIC16F877A is a RISC microcontroller, that means that it has a reduced set of instructions, more

precisely 35 instructions. (Ex. Intel's and Motorola's microcontrollers have over hundred instructions) All of

these instructions are executed in one cycle except for jump and branch instructions. According to what its

maker says, PIC16F877A usually reaches results of 2:1 in code compression and 4:1 in speed in relation to

other 8-bit microcontrollers in its class.

Page 9: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

3.2 Applications

PIC16F877A perfectly fits many uses, from automotive industries and controlling home appliances to

industrial instruments, remote sensors, electrical door locks and safety devices. It is also ideal for smart cards as

well as for battery supplied devices because of its low consumption.

EEPROM memory makes it easier to apply microcontrollers to devices where permanent storage of

various parameters is needed (codes for transmitters, motor speed, receiver frequencies, etc.). Low cost, low

consumption, easy handling and flexibility make PIC16F877A applicable even in areas where microcontrollers

had not previously been considered (example: timer functions, interface replacement in larger systems,

coprocessor applications, etc.).

System Programmability of this chip (along with using only two pins in data transfer) makes possible

the flexibility of a product, after assembling and testing have been completed. This capability can be used to

create assembly-line production, to store calibration data available only after final testing, or it can be used to

improve programs on finished products.

3.3 Ports

Term "port" refers to a group of pins on a microcontroller which can be accessed simultaneously, or on which

we can set the desired combination of zeros and ones, or read from them an existing status. Physically, port is a

register inside a microcontroller which is connected by wires to the pins of a microcontroller. Microcontroller

uses them in order to monitor or control other components or devices. Due to functionality, some pins have

twofold roles like PA4/TOCKI for instance, which is in the same time the fourth bit of port A and an external

input for free-run counter. Selection of one of these two pin functions is done in one of the configuration

registers. An illustration of this is the fifth bit T0CS in OPTION register. By selecting one of the functions the

other one is disabled.

All port pins can be designated as input or output, according to the needs of a device that's being developed. In

order to define a pin as input or output pin, the right combination of zeros and ones must be written in TRIS

register. If the appropriate bit of TRIS register contains logical "1", then that pin is an input pin, and if the

opposite is true, it's an output pin. Every port has its proper TRIS register. Thus, port A has TRISA, and port B

has TRISB. Pin direction can be changed during the course of work which is particularly fitting for one-line

Page 10: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

communication where data flow constantly changes direction. PORTA and PORTB state registers are located in

bank 0, while TRISA and TRISB pin direction registers are located in bank 1.

Memory organization

PIC16F877A has two separate memory blocks, one for data and the other for program. EEPROM memory with

GPR and SFR registers in RAM memory make up the data block, while FLASH memory makes up the program

block.

Program memory

Program memory has been carried out in FLASH technology which makes it possible to program a

microcontroller many times before it's installed into a device, and even after its installment if eventual changes

in program or process parameters should occur. The size of program memory is 1024 locations with 14 bits

width where locations zero and four are reserved for reset and interrupt vector.

Data memory

Data memory consists of EEPROM and RAM memories. EEPROM memory consists of 256 eight bit locations

whose contents is not lost during loosing of power supply. EEPROM is not directly addressable, but is accessed

indirectly through EEADR and EEDATA registers. As EEPROM memory usually serves for storing important

parameters (for example, of a given temperature in temperature regulators) , there is a strict procedure for

writing in EEPROM which must be followed in order to avoid accidental writing. RAM memory for data

occupies space on a memory map from location 0x0C to 0x4F which comes to 68 locations. Locations of RAM

memory are also called GPR registers which is an abbreviation for General Purpose Registers. GPR registers

can be accessed regardless of which bank is selected at the moment.

Memory Banks

Beside this 'length' division to SFR and GPR registers, memory map is also divided in 'width' (see preceding

map) to two areas called 'banks'. Selecting one of the banks is done via RP0 bit in STATUS register.

Page 11: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

Example:

bcf STATUS, RP0

Instruction BCF clears bit RP0 (RP0=0) in STATUS register and thus sets up bank 0.

bsf STATUS, RP0

Instruction BSF sets the bit RP0 (RP0=1) in STATUS register and thus sets up bank1.

It is useful to consider what would happen if the wrong bank was selected. Let's assume that we have selected

bank 0 at the beginning of the program, and that we now want to write to certain register located in bank 1, say

TRISB. Although we specified the name of the register TRISB, data will be actually stored to a bank 0 register

at the appropriate address, which is PORTB in our example.

BANK0 macro

Bcf STATUS, RP0 ;Select memory bank 0

endm

BANK1 macro

Bsf STATUS, RP0 ;Select memory bank 1

endm

Bank selection can be also made via directive banksel after which name of the register to be accessed is

specified. In this manner, there is no need to memorize which register is in which bank.

Program Counter

Program counter (PC) is a 13-bit register that contains the address of the instruction being executed. It is

physically carried out as a combination of a 5-bit register PCLATH for the five higher bits of the address, and

the 8-bit register PCL for the lower 8 bits of the address.

By its incrementing or change (i.e. in case of jumps) microcontroller executes program instructions step-by-

step.

Stack

PIC16F877A has a 13-bit stack with 8 levels, or in other words, a group of 8 memory locations, 13 bits wide,

with special purpose. Its basic role is to keep the value of program counter after a jump from the main program

to an address of a subprogram . In order for a program to know how to go back to the point where it started

Page 12: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

from, it has to return the value of a program counter from a stack. When moving from a program to a

subprogram, program counter is being pushed onto a stack (example of this is CALL instruction). When

executing instructions such as RETURN, RETLW or RETFIE which were executed at the end of a subprogram,

program counter was taken from a stack so that program could continue where was stopped before it was

interrupted. These operations of placing on and taking off from a program counter stack are called PUSH and

POP, and are named according to similar instructions on some bigger microcontrollers.

In System Programming

In order to program a program memory, microcontroller must be set to special working mode by bringing up

MCLR pin to 13.5V, and supply voltage Vdd has to be stabilized between 4.5V to 5.5V. Program memory can

be programmed serially using two 'data/clock' pins which must previously be separated from device lines, so

that errors wouldn't come up during programming.

Fig 3.8 Direct addressing format

Page 13: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

Indirect Addressing

Indirect unlike direct addressing does not take an address from an instruction but derives it from IRP bit

of STATUS and FSR registers. Addressed location is accessed via INDF register which in fact holds the address

indicated by a FSR. In other words, any instruction which uses INDF as its register in reality accesses data

indicated by a FSR register. Let's say, for instance, that one general purpose register (GPR) at address 0Fh

contains a value of 20. By writing a value of 0Fh in FSR register we will get a register indicator at address 0Fh,

and by reading from INDF register, we will get a value of 20, which means that we have read from the first

register its value without accessing it directly (but via FSR and INDF). It appears that this type of addressing

does not have any advantages over direct addressing, but certain needs do exist during programming which can

be solved smoothly only through indirect addressing.

Indirect addressing is very convenient for manipulating data arrays located in GPR registers. In this case, it is

necessary to initialize FSR register with a starting address of the array, and the rest of the data can be accessed

by incrementing the FSR register.

Fig 3.9 Indirect addressing format

Such examples include sending a set of data via serial communication, working with buffers and indicators

(which will be discussed further in a chapter with examples), or erasing a part of RAM memory (16 locations)

as in the following instance.

Page 14: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

Reading data from INDF register when the contents of FSR register is equal to zero returns the value of zero,

and writing to it results in NOP operation (no operation).

3.3 G.S.M Modem/Moblile

3.3.1 GSM History

During the early 1980s, analog cellular telephone systems were experiencing rapid growth in Europe,

particularly in Scandinavia and the United Kingdom, but also in France and Germany. Each country developed

its own system, which was incompatible with everyone else's in equipment and operation. This was an

undesirable situation, because not only was the mobile equipment limited to operation within national

boundaries, which in a unified Europe were increasingly unimportant, but there was also a very limited market

for each type of equipment, so economies of scale and the subsequent savings could not be realized.

The Europeans realized this early on, and in 1982 the Conference of European Posts and Telegraphs

(CEPT) formed a study group called the Groupe Special Mobile (GSM) to study and develop a pan-European

public land mobile system. The proposed system had to meet certain criteria:

· Good subjective speech quality

· Low terminal and service cost

· Low terminal and service cost

· Ability to support handheld terminals

· Support for range of new services and facilities

· Spectral efficiency

· ISDN compatibility

Pan-European means European-wide. ISDN throughput at 64Kbs was never envisioned, indeed, the highest rate

a normal GSM network can achieve is 9.6kbs.

Europe saw cellular service introduced in 1981, when the Nordic Mobile Telephone System or NMT450

began operating in Denmark, Sweden, Finland, and Norway in the 450 MHz range. It was the first multinational

cellular system. In 1985 Great Britain started using the Total Access Communications System or TACS at 900

MHz. Later, the West German C-Netz, the French Radio COM 2000, and the Italian RTMI/RTMS helped make

up Europe's nine analog incompatible radio telephone systems. Plans were afoot during the early 1980s,

however, to create a single European wide digital mobile service with advanced features and easy roaming.

While North American groups concentrated on

Page 15: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

building out their robust but increasingly fraud plagued and featureless analog network, Europe planned for a

digital future.

In 1989, GSM responsibility was transferred to the European Telecommunication Standards Institute

(ETSI), and phase I of the GSM specifications were published in 1990. Commercial service was started in mid-

1991, and by 1993 there were 36 GSM networks in 22 countries. Although standardized in Europe, GSM is not

only a European standard. Over 200 GSM networks (including DCS1800 and PCS1900) are operational in 110

countries around the world. In the beginning of 1994, there were 1.3 million subscribers worldwide, which had

grown to more than 55 million by October 1997. With North America making a delayed entry into the GSM

field with a derivative of GSM called PCS1900, GSM systems exist on every continent, and the acronym GSM

now aptly stands for Global System for Mobile communications.

The developers of GSM chose an unproven (at the time) digital system, as opposed to the then-standard

analog cellular systems like AMPS in the United States and TACS in the United Kingdom. They had faith that

advancements in compression algorithms and digital signal processors would allow the fulfillment of the

original criteria and the continual improvement of the system in terms of quality and cost. The over 8000 pages

of GSM recommendations try to allow flexibility and competitive innovation among suppliers, but provide

enough standardization to guarantee proper networking between the components of the system. This is done by

providing functional and interface descriptions for each of the functional entities defined in the system.

3.3.2 Services provided by GSM

From the beginning, the planners of GSM wanted ISDN compatibility in terms of the services offered and the

control signaling used. However, radio transmission limitations, in terms of bandwidth and cost, do not allow

the standard ISDN B-channel bit rate of 64 kbps to be practically achieved.

Telecommunication services can be divided into bearer services, teleservices, and supplementary services.

The most basic tele service supported by GSM is telephony. As with all other communications, speech is

digitally encoded and transmitted through the GSM network as a digital stream. There is also an emergency

service, where the nearest emergency-service provider is notified by dialing three digits.

Bearer services: Typically data transmission instead of voice. Fax and SMS are examples. Teleservices: Voice oriented traffic. Supplementary services: Call forwarding, caller ID, call waiting and the like.

A variety of data services is offered. GSM users can send and receive data, at rates up to 9600 bps, to

users on POTS (Plain Old Telephone Service), ISDN, Packet Switched Public Data Networks, and Circuit

Page 16: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

Switched Public Data Networks using a variety of access methods and protocols, such as X.25 or X.32. Since

GSM is a digital network, a modem is not required between the user and GSM network, although an audio

modem is required inside the GSM network to interwork with POTS.

Other data services include Group 3 facsimile, as described in ITU-T recommendation T.30, which is

supported by use of an appropriate fax adaptor. A unique feature of GSM, not found in older analog systems, is

the Short Message Service (SMS). SMS is a bidirectional service for short alphanumeric (up to 160 bytes)

messages. Messages are transported in a store-and-forward fashion. For point-to-point SMS, a message can be

sent to another subscriber to the service, and an acknowledgement of receipt is provided to the sender. SMS can

also be used in a cell-broadcast mode, for sending messages such as traffic updates or news updates. Messages

can also be stored in the SIM card for later retrieval.

Supplementary services are provided on top of tele services or bearer services. In the current (Phase I)

specifications, they include several forms of call forward (such as call forwarding when the mobile subscriber is

unreachable by the network), and call barring of outgoing or incoming calls, for example when roaming in

another country. Many additional supplementary services will be provided in the Phase 2 specifications, such as

caller identification, call waiting, multi-party conversations.

3.3.3 Mobile Station

The mobile station (MS) consists of the mobile equipment (the terminal) and a smart card called the Subscriber

Identity Module (SIM). The SIM provides personal mobility, so that the user can have access to subscribed

services irrespective of a specific terminal. By inserting the SIM card into another GSM terminal, the user is

able to receive calls at that terminal, make calls from that terminal, and receive other subscribed services.

The mobile equipment is uniquely identified by the International Mobile Equipment Identity (IMEI). The

SIM card contains the International Mobile Subscriber Identity (IMSI) used to identify the subscriber to the

system, a secret key for authentication, and other information. The IMEI and the IMSI are independent, thereby

allowing personal mobility. The SIM card may be protected against unauthorized use by a password or personal

identity number.

GSM phones use SIM cards, or Subscriber information or identity modules. They're the biggest difference

a user sees between a GSM phone or handset and a conventional cellular telephone. With the SIM card and its

memory the GSM handset is a smart phone, doing many things a conventional cellular telephone cannot. Like

keeping a built in phone book or allowing different ring tones to be downloaded and then stored. Conventional

Page 17: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

cellular telephones either lack the features GSM phones have built in, or they must rely on resources from the

cellular system itself to provide them. Let me make another, important point.

With a SIM card your account can be shared from mobile to mobile, at least in theory. Want to try out

your neighbor's brand new mobile? You should be able to put your SIM card into that GSM handset and have it

work. The GSM network cares only that a valid account exists, not that you are using a different device. You

get billed, not the neighbor who loaned you the phone.

This flexibility is completely different than AMPS technology, which enables one device per account. No

switching around. Conventional cellular telephones have their electronic serial number burned into a chipset

which is permanently attached to the phone. No way to change out that chipset or trade with another phone.

SIM card technology, by comparison, is meant to make sharing phones and other GSM devices quick and easy.

Fig.3.12 Mobile station SIM port

On the left above: Front of a Pacific Bell GSM phone. In the middle above: Same phone, showing the back. The

SIM card is the white plastic square. It fits into the grey colored holder next to it. On the right above. A new and

different idea, a holder for two SIM cards, allowing one phone to access either of two wireless carriers.

Provided you have an account with both. :-) The Sim card is to the left of the body.

3.3.9 Discontinuous reception

Another method used to conserve power at the mobile station is discontinuous reception. The paging channel,

used by the base station to signal an incoming call, is structured into sub-channels. Each mobile station needs to

Page 18: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

listen only to its own sub-channel. In the time between successive paging sub-channels, the mobile can go into

sleep mode, when almost no power is used.

3.3.10 Power control

There are five classes of mobile stations defined, according to their peak transmitter power, rated at 20, 8, 5, 2,

and 0.8 watts. To minimize co-channel interference and to conserve power, both the mobiles and the Base

Transceiver Stations operate at the lowest power level that will maintain an acceptable signal quality. Power

levels can be stepped up or down in steps of 2 dB from the peak power for the class down to a minimum of 13

dBm (20 milliwatts).

We need only enough power to make a connection. Any more is superfluous. If you can't make a

connection using one watt then two watts won't help at these near microwave frequencies. Using less power

means less interference or congestion among all the mobiles in a cell.

The mobile station measures the signal strength or signal quality (based on the Bit Error Ratio), and passes

the information to the Base Station Controller, which ultimately decides if and when the power level should be

changed. Power control should be handled carefully, since there is the possibility of instability. This arises from

having mobiles in co-channel cells alternating increase their power in response to increased co-channel

interference caused by the other mobile increasing its power. This in unlikely to occur in practice but it is (or

was as of 1991) under study.

Two points. The first is that the base station can reach out to the mobile and turn down the transmitting

power the handset is using. Very cool. The second point is that a digital signal will drop a call much more

quickly than an analog signal. With an analog radio you can hear through static and fading. But with a digital

radio the connection will be dropped, just like your landline modem, when too many 0s and 1s go missing. You

need more base stations, consequently, to provide the same coverage as analog

3.3.11 Network aspects

Ensuring the transmission of voice or data of a given quality over the radio link is only part of the function of a

cellular mobile network. A GSM mobile can seamlessly roam nationally and internationally, which requires that

registration, authentication, call routing and location updating functions exist and are standardized in GSM

networks. In addition, the fact that the geographical area covered by the network is divided into cells

necessitates the implementation of a handover mechanism. These functions are performed by the Network

Page 19: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

Subsystem, mainly using the Mobile Application Part (MAP) built on top of the Signaling System No. 7

protocol.

The signaling protocol in GSM is structured into three general layers [1], [19], depending on the interface,

as shown in Figure 3. Layer 1 is the physical layer, which uses the channel structures discussed above over the

air interface. Layer 2 is the data link layer. Across the Um interface, the data link layer is a modified version of

the LAPD protocol used in ISDN (external link), called LAPDm. Across the A interface, the Message Transfer

Part layer 2 of Signaling System Number 7 is used. Layer 3 of the GSM signaling protocol is itself divided into

3 sub layers.

· Radio Resources Management

· Controls the setup, maintenance, and termination of radio and fixed channels,

· Including handovers.

· Mobility Management

· Manages the location updating and registration procedures, as well as security and authentication.

· Connection Management

· Handles general call control, similar to CCITT Recommendation Q.931, and manages Supplementary Services and the Short Message Service.

Figure 3.16 Signaling protocol structure in GSM

3.3.12 Radio resources management

The radio resources management (RR) layer oversees the establishment of a link, both radio and fixed, between

the mobile station and the MSC. The main functional components involved are the mobile station, and the Base

Station Subsystem, as well as the MSC. The RR layer is concerned with the management of an RR-session [16],

which is the time that a mobile is in dedicated mode, as well as the configuration of radio channels including the

allocation of dedicated channels.

Page 20: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

An RR-session is always initiated by a mobile station through the access procedure, either for an outgoing

call, or in response to a paging message. The details of the access and paging procedures, such as when a

dedicated channel is actually assigned to the mobile, and the paging sub-channel structure, are handled in the

RR layer. In addition, it handles the management of radio features such as power control, discontinuous

transmission and reception, and timing advance.

3.3.13 Handover

In a cellular network, the radio and fixed links required are not permanently allocated for the duration of a call.

Handover, or handoff as it is called in North America, is the switching of an on-going call to a different channel

or cell. The execution and measurements required for handover form one of basic functions of the RR layer.

There are four different types of handover in the GSM system, which involve transferring a call between:

· Channels (time slots) in the same cell

· Cells (Base Transceiver Stations) under the control of the same Base Station Controller (BSC),

· Cells under the control of different BSCs, but belonging to the same Mobile services Switching Center

(MSC), and

· Cells under the control of different MSCs.

The first two types of handover, called internal handovers, involve only one Base Station Controller

(BSC). To save signaling bandwidth, they are managed by the BSC without involving the Mobile services

Switching Center (MSC), except to notify it at the completion of the handover. The last two types of handover,

called external handovers, are handled by the MSCs involved. An important aspect of GSM is that the original

MSC, the anchor MSC, remains responsible for most call-related functions, with the exception of subsequent

inter-BSC handovers under the control of the new MSC, called the relay MSC.

Handovers can be initiated by either the mobile or the MSC (as a means of traffic load balancing). During

its idle time slots, the mobile scans the Broadcast Control Channel of up to 16 neighboring cells, and forms a

Page 21: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

list of the six best candidates for possible handover, based on the received signal strength. This information is

passed to the BSC and MSC, at least once per second, and is used by the handover algorithm.

The algorithm for when a hand over decision should be taken is not specified in the GSM

recommendations. There are two basic algorithms used, both closely tied in with power control. This is because

the BSC usually does not know whether the poor signal quality is due to multipath fading or to the mobile

having moved to another cell. This is especially true in small urban cells.

The 'minimum acceptable performance' algorithm [3] gives precedence to power control over handover, so

that when the signal degrades beyond a certain point, the power level of the mobile is increased. If further

power increases do not improve the signal, then a handover is considered. This is the simpler and more common

method, but it creates 'smeared' cell boundaries when a mobile transmitting at peak power goes some distance

beyond its original cell boundaries into another cell.

The 'power budget' method [3] uses handover to try to maintain or improve a certain level of signal quality

at the same or lower power level. It thus gives precedence to handover over power control. It avoids the

'smeared' cell boundary problem and reduces co-channel interference, but it is quite complicated.

3.3.14 Mobility management

The Mobility Management layer (MM) is built on top of the RR layer (radio resources), and handles the

functions that arise from the mobility of the subscriber, as well as the authentication and security aspects.

Location management is concerned with the procedures that enable the system to know the current location of a

powered-on mobile station so that incoming call routing can be completed.

3.3.15 Location updating

A powered-on mobile is informed of an incoming call by a paging message sent over the PAGCH channel of a

cell. One extreme would be to page every cell in the network for each call, which is obviously a waste of radio

bandwidth. The other extreme would be for the mobile to notify the system, via location updating messages, of

its current location at the individual cell level. This would require paging messages to be sent to exactly one

cell, but would be very wasteful due to the large number of location updating messages. A compromise solution

used in GSM is to group cells into location areas. Updating messages are required when moving between

location areas, and mobile stations are paged in the cells of their current location area.

In conventional cellular location messages are sent to the exact cell a mobile is in.

To review, the VLR Data Base, or Visited or Visitor Location Register, contains all the data needed to

communicate with the mobile switch. Levine says this data includes:

Page 22: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

· Equipment identity and authentication-related data

· Last known Location Area (LA)

· Power Class and other physical attributes of the mobile or handset

· List of special services available to this subscriber

· More data entered while engaged in a Call

· Current cell

· Encryption keys

The location updating procedures, and subsequent call routing, use the MSC and two location registers: the

Home Location Register (HLR) and the Visitor Location Register (VLR). When a mobile station is switched on

in a new location area, or it moves to a new location area or different operator's PLMN, it must register with the

network to indicate its current location. In the normal case, a location update message is sent to the new

MSC/VLR, which records the location area information, and then sends the location information to the

subscriber's HLR. The information sent to the HLR is normally the SS7 address of the new VLR, although it

may be a routing number. The reason a routing number is not normally assigned, even though it would reduce

signaling, is that there is only a limited number of routing numbers available in the new MSC/VLR and they are

allocated on demand for incoming calls. If the subscriber is entitled to service, the HLR sends a subset of the

subscriber information, needed for call control, to the new MSC/VLR, and sends a message to the old

MSC/VLR to cancel the old registration.

A procedure related to location updating is the IMSI (International Mobile Subscriber Identity) attach and

detach. A detach lets the network know that the mobile station is unreachable, and avoids having to needlessly

allocate channels and send paging messages. An attach is similar to a location update, and informs the system

that the mobile is reachable again. The activation of IMSI attach/detach is up to the operator on an individual

cell basis.

3.3.16 Authentication and security

Since the radio medium can be accessed by anyone, authentication of users to prove that they are who they

claim to be, is a very important element of a mobile network. Authentication involves two functional entities,

the SIM card in the mobile, and the Authentication Center (AUC). Each subscriber is given a secret key, one

copy of which is stored in the SIM card and the other in the AUC. During authentication, the AUC generates a

random number that it sends to the mobile. Both the mobile and the AUC then use the random number, in

conjunction with the subscriber's secret key and a ciphering algorithm called A3, to generate a signed response

(SRES) that is sent back to the AUC. If the number sent by the mobile is the same as the one calculated by the

AUC, the subscriber is authenticated.

Page 23: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

The same initial random number and subscriber key are also used to compute the ciphering key using an

algorithm called A8. This ciphering key, together with the TDMA frame number, use the A5 algorithm to create

a 114 bit sequence that is XORed with the 114 bits of a burst (the two 57 bit blocks). Enciphering is an option

for the fairly paranoid, since the signal is already coded, interleaved, and transmitted in a TDMA manner, thus

providing protection from all but the most persistent and dedicated eavesdroppers.

Another level of security is performed on the mobile equipment itself, as opposed to the mobile

subscriber. As mentioned earlier, each GSM terminal is identified by a unique International Mobile Equipment

Identity (IMEI) number. A list of IMEIs in the network is stored in the Equipment Identity Register (EIR). The

status returned in response to an IMEI query to the EIR is one of the following:

White-listed: The terminal is allowed to connect to the network.

Grey-listed: The terminal is under observation from the network for possible problems.

Black-listed: The terminal has either been reported stolen, or is not type approved (the correct type of terminal

for a GSM network). The terminal is not allowed to connect to the network.

3.3.17 Communication management

The Communication Management layer (CM) is responsible for Call Control (CC), supplementary service

management, and short message service management. Each of these may be considered as a separate sub layer

within the CM layer. Call control attempts to follow the ISDN procedures specified in Q.931, although routing

to a roaming mobile subscriber is obviously unique to GSM. Other functions of the CC sub layer include call

establishment, selection of the type of service (including alternating between services during a call), and call

release.

3.4.2 Working and Operation of G.P.S

When people talk about "a GPS," they usually mean a GPS receiver. The Global Positioning System (GPS) is

actually a constellation of 27 Earth-orbiting satellites (24 in operation and three extras in case one fails). The

U.S. military developed and implemented this satellite network as a military navigation system, but soon

opened it up to everybody else.

Each of these 3,000- to 4,000-pound solar-powered satellites circles the globe at about 12,000 miles

(19,300 km), making two complete rotations every day. The orbits are arranged so that at any time, anywhere

on Earth, there are at least four satellites "visible" in the sky.

Page 24: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

A GPS receiver's job is to locate four or more of these satellites, figure out the distance to each, and use this

information to deduce its own location. This operation is based on a simple mathematical principle called

trilateration.GPS receiver calculates its position on earth based on the information it receives from four located

satellites. This system works pretty well, but inaccuracies do pop up. For one thing, this method assumes the

radio signals will make their way through the atmosphere at a consistent speed (the speed of light). In fact, the

Earth's atmosphere slows the electromagnetic energy down somewhat, particularly as it goes through the

ionosphere and troposphere. The delay varies depending on where you are on Earth, which means it's difficult

to accurately factor this into the distance calculations. Problems can also occur when radio signals bounce off

large objects, such as skyscrapers, giving a receiver the impression that a satellite is farther away than it actually

is. On top of all that, satellites sometimes just send out bad almanac data, misreporting their own position.

Differential GPS (DGPS) helps correct these errors. The basic idea is to gauge GPS inaccuracy at a stationary

receiver station with a known location. Since the DGPS hardware at the station already knows its own position,

it can easily calculate its receiver's inaccuracy. The station then broadcasts a radio signal to all DGPS-equipped

receivers in the area, providing signal correction information for that area. In general, access to this correction

information makes DGPS receivers much more accurate than ordinary receivers.

3.18 G.P.S receiver communicating with the satellite and sending information through the wireless

mobile phone

Page 25: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

3.4.5 G.P.S data decoding

G.P.S receiver continuously sends data and the microcontroller receives the data when ever it requires. The data

sent by the G.P.S is a string of characters which should be decoded to the standard format. This is done by the

program which we implement in the controller.

3.5. Accident sensor

Accident sensor is a simple switch which uses the air bag mechanism which was readily available in

the car. The air bag was built such that when ever an accident occurs it senses it and comes out. Our switch is

attached to the air bag circuit and made to switch on when ever the air bag turns on allowing the controller to

know the information regarding the occurrence of accident and the controller immediately sends the accident

information and location where it occurred to the concerned persons.

Page 26: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

Fig 3.19 Snap of the project.

Page 27: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

CHAPTER 4

COMMUNICATION PROTOCOLS ANS COMMANDS

4.1. AT commands

AT commands are instructions used to control a modem. AT is the abbreviation of Attention. Every command

line starts with "AT" or "at". That's why modem commands are called AT commands. Many of the commands

that are used to control wired dial-up modems. These are also supported by GSM/GPRS modems and mobile

phones. Besides this common AT command set, GSM/GPRS modems and mobile phones support an AT

command set that is specific to the GSM technology, which includes SMS-related commands.

4.1.1 Basic Commands and Extended Commands

There are two types of AT commands: basic commands and extended commands.

Basic commands are AT commands that do not start with "+". For example, D (Dial), A (Answer), H (Hook

control) and O (Return to online data state) are basic commands.

Extended commands are AT commands that start with "+". All GSM AT commands are extended commands.

For example, +CMGS (Send SMS message), +CMSS (Send SMS message from storage), +CMGL (List SMS

messages) and +CMGR (Read SMS messages) are extended commands.

Here are some of the tasks that can be done using AT commands with a GSM/GPRS modem or mobile phone:

Page 28: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

4.1.2 List of commands

AT Command Functionality AT+CGMI Name of the manufacture AT+CGMM Model number AT+CGSN International mobile subscriber identity AT+CGMR Software version AT+CIMI International mobile subscriber identity AT+CSQ Radio signal strength AT+CBC Charging status AT+CMGS Send message AT+CMGR Read message AT+CMGW Write message AT+CMGD Delete message AT+CNMI Notifications of received messages AT+CPBR Read phone book AT+CPBW Write to phone book AT+CPBF Search phone book AT+CLCK Checking whether a facility is locked AT+CPWD Change password ATO Return to online data state ATH Hook control ATA Answer call ATD Dial call

Page 29: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

CHAPTER 5

IMPLEMENTATION AND CODING

5.1 COMPILER AND TOOL KIT :

5.1.1 CCS COMPILER

The compiler used in the “ADVANCED VEHICLE SECUIRTY SYSTEM USING GPS AND GSM “is

Microchip PIC Micro C Compiler. CCS provides a complete, integrated tool suite for developing and

debugging embedded applications running on Microchip PIC® MCUs. The heart of this development tool suite

is the CCS intelligent code optimizing C compiler, which frees developers to concentrate on design

functionality instead of having to become an MCU architecture expert.

· Maximize code reuse by easily porting from one MCU to another.

· Minimize lines of new code with CCS provided peripheral drivers, built-in functions and standard C

operators.

· Built in libraries are specific to PIC® MCU registers, allowing access to hardware features directly from

C.

5.1.2 PIC TOOL KIT:

We use PIC KIT 2 to dump the code in to the microcontroller. The hex file generated by the

CCS compiler after debugging and compilation is used by the PIC KIT 2.

Importing a Hex file:

To import a hex file to be programmed in to the target device, select

File>Import Hex

Page 30: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

Loading hex file to controller

After a device family has been selected and a hex file has been imported, the target device can be programmed

by clicking write. The device will be erased and programmed with the hex code previously imported.

The status of Write operation is displayed in the status bar located under the Device configuration window. Of

the write is successful, the status bar turns green and displays "Programming Successful", as shown in fig

below.

.

Page 31: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

5.2 EMBEDDED C SOURCE CODE:

#include <16F877A.h>

#include <gsm.c>

#include <gps.c>

#use delay (clock=20M) //Crystal Oscillator speed 20MHz

#use rs232 (baud = 9600, xmit=PIN_B0,rcv=PIN_B1,stream=GSM) //For GSM Modem

#use rs232 (baud = 4800, xmit=PIN_A1,rcv=PIN_A0,stream=GPS) //For GPS Receiver

byte ch = 0;

int count = 0;

byte data[150]; //For SMS storage

byte wru[] = { "wru" };

byte about[] = {"about"};

byte help[] = {"help"};

byte lock[] = {"lock"};

byte unlock[] = {"unlock"};

byte num[12]; //for storing phone number

char lat[12]; //for storing latitude

char lngtd[12]; //for storing lngtd

char speed[12]; //for storing speed

char tdata[12]; //for temprary data

void main()

{

int i = 0;

int j = 0;

Page 32: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

int flag = 0;

output_high(PIN_D1);

delay_ms(1000);

output_low(PIN_D1);

delay_ms(1000);

output_high(PIN_D1);

delay_ms(1000);

output_low(PIN_D1);

init_phone();

while(1)

{

output_toggle(PIN_D1); //GSM Indicator LED

delay_ms(500);

count = 0; //reset data buffer

data[count] = 0;

if(!input(PIN_C4)) //Accident Sensor switch.

{

//Crash Message Handling

output_high(PIN_D0); //LED Indicator

get_GPS_data(lat,lngtd); //Read GPS data for lat and lngtd

fprintf(GSM,"AT+CMGS=\"%s\"\r\n",mynum); //Send SMS message to pre-defined number

fprintf(GSM,"ALERT: Vehicle No.9999 Crashed at Latitude: %s Longitude: %s \r\n",lat,lngtd); //Send SMS data

fputc(0x1A,GSM); //^Z to send sms

Page 33: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

output_low(PIN_D0); //LED Indicator

continue;

}

}

fgets(data,GSM); //Read sms data into data buffer

if(strlen(data) < 14) //No message in string. returns OK or ERROR. Depends on Modem type

{

continue;

}

//Delete the message

fprintf(GSM,"AT+CMGD=1\r\n"); //delete message from SIM card

delay_ms(2000);

//Read the available message content

//extract the phone number from SMS Message

get_phone_number(data,num); //extract phone number into num variable

if(strstr(data,wru)) //If the message contains "wru"

{

get_GPS_data(lat,lngtd);

output_high(PIN_D1);

fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num);

Page 34: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

fprintf(GSM,"Hello, I am located at ");

fprintf(GSM,"Latitude: %s Longitude: %s ",lat,lngtd);

fprintf(GSM,"Speed: %s kmph. ",speed);

fprintf(GSM,"Please use Google Earth to see my location.\r\n");

fputc(0x1A,GSM);

}

else if(strstr(data,about)) //If the message contains "about"

{

output_high(PIN_D1);

fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num);

fprintf(GSM,"B.Tech Final Year(2009-2010) Project \r\n");

fprintf(GSM,"GPS & GSM Based Vehicle Theft Control System. \r\n");

fprintf(GSM,"Engineering Final Year Project.\r\n");

fputc(0x1A,GSM);

}

else if(strstr(data,unlock))

{

output_high(PIN_D1);

output_low(PIN_D7);

fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num);

fprintf(GSM,"Vehicle got unlocked");

fputc(0x1A,GSM);

}

else if(strstr(data,lock))

{

Page 35: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

get_GPS_data(lat,lngtd);

output_high(PIN_D1);

output_high(PIN_D7);

fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num);

fprintf(GSM,"Vehicle got locked out at location ");

fprintf(GSM,"Latitude: %s Longitude: %s ",lat,lngtd);

fprintf(GSM,"Please use Google Earth to see my location.\r\n");

fputc(0x1A,GSM); //^Z

}

else if(strstr(data,help))

{

output_high(PIN_D1);

fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num);

fprintf(GSM,"Send \"wru\" to get my location \r\n");

fprintf(GSM,"Send \"about\" to know about me\r\n");

fprintf(GSM,"Send \"lock\" to Lock the Vehicle Ignition.\r\n");

fprintf(GSM,"Send \"unlock\" to Unlock.\r\n");

fputc(0x1A,GSM);

}

}

}

Page 36: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

CHAPTER 6

APPLICATIONS

— VIP vehicle tracking.

— Child and animal tracking.

— Accident Notification of Vehicle.

— Ambulance tracking.

· Vehicle Theft Control

LIMITATIONS

For the location of the vehicle, the GPS provides the information in the form of latitude and longitude which further requires software such as Google Map to know the name of the area and the nearest landmark. However by attaching an external Memory card to the project consisting of respective information can make the limitation to overcome

Page 37: Vehicular Security System

ADVANCED VEHICLE SECURITY SYSTEM

CHAPTER 7

CONCLUSION

The project has been successfully designed and implemented for the “ADVANCED VEHICLE

SECURITY SYSTEM WITH THEFT CONTROL AND ACCIDENT NOTIFICATION”.

It has been developed by integrating features of all the hardware components used. Presence of every

module has been reasoned out and placed carefully thus contributing to the best working of the unit.

Secondly, using highly advanced IC’s and with the help of growing technology the project has been

successfully implemented and tested.

Finally we conclude that GPS and GSM based Security System add a huge for the rapid growth of

Technology.