Zigbee Project

Post on 18-Apr-2015

83 views 1 download

transcript

Detection and Tracking using GSM and GPS technology

CHAPTER ONE

PROJECT OVERVIEW

 

   

1 | P a g e   

Detection and Tracking using GSM and GPS technology

 

 

 

CHAPTER ONE PROJECT OVERVIEW

1.1 Introduction  

For centuries, our ancestors have searched the heavens at night for a system that

would enable them to locate their position on earth. They built landmarks, detailed

maps and learned how to read the stars in the night sky, but today- by the passage of

time - things are much changed and very much easier than before, upon entering this

modern era of technology the invention of the Global Positioning System (GPS)

become more and more serviceable and needed in every day applications.

The Global Positioning Satellite (GPS) system is a network of satellites orbiting the

earth, which transmits location data back to earth ceaselessly. Using these data and

GPS tracking devices, you can pinpoint any object on the earth. For example, GPS

vehicle tracking system or GPS fleet tracking system can point out where your stolen

vehicle is? Or where your ship sails at present?

Main uses of GPS technology are as follows:

Location-The first and foremost palpable application of GPS system is the simple

determination of a position or location; Navigation-The primary design of GPS

tracking system was to provide navigation information for ships and planes; Tracking-

With the accurate data provided by the system, monitoring mobile objects or people is

not difficult task anymore; Mapping-GPS can help in creating maps and models of

everything in the planet. Mapping the earth had never been an easier task; Timing-

GPS satellites carry highly accurate atomic clocks, and GPS tracking devices here on

the ground when synchronized with those in the satellites are themselves atomic

accuracy clocks providing accurate time.

  

2 | P a g e   

Detection and Tracking using GSM and GPS technology

1.2 Previous Work GPS tracking systems are used now more than ever before, and are affordable

for nearly every budget. Here are just a few of the most popular ways to use GPS

tracking systems today.

I. Outdoor Sports: What a better way to safely enjoy the beauty of the

outdoors than with the security of a GPS tracking system? Allow family

members to track your hiking or biking excursion with GPS tracking software,

and rest assured knowing that you can be easily located in the event of an

emergency.

II. Impress Your Customers: In today’s world of e-commerce and wireless

technology, consumers have come to expect instant access to the information

they want and need. GPS tracking systems used to track your customers’

deliveries can help you provide them with better customer service, and keep

them coming back time and time again.

III. Track a Teen: Want to know if “Junior” is really “studying at the library”?

Many parents are now using GPS tracking devices to monitor the driving

speeds, and location of their teenagers.

IV. Catch a Thief: Protect your business or home by attaching GPS tracking

systems to your valuables such as heavy equipment, lawn mowers, and

automobiles.

V. Track Employees: Want to know if your drivers are effectively managing

their time, obeying the rules of the road, or abusing the use of company

vehicles? A GPS tracking system and GPS tracking software can quickly give

you the answers you need to operate your business as efficiently as possible.

VI. Protect a Child: Portable GPS tracking devices are now widely used as an

added safety measure for quickly locating children in the event of an

3 | P a g e   

Detection and Tracking using GSM and GPS technology

emergency.

VII. Reduce Insurance Costs: Did you know that many insurance companies

now offer significant discounts for those with GPS tracking systems installed

on their vehicles? Save money while increasing the safety of drivers!

VIII. Protect the Elderly: Help maintain your loved one’s independence and

safety with the use of a GPS tracking system.

IX. Plan Delivery Routes: Save time, payroll costs, and fuel by using a GPS

tracking system to cost-effectively plan deliveries, service calls, and speed up

response times!

X. Give Mom a Break: Know a mom who’s continuously worried about her

college student’s safety? Personal GPS tracking devices are increasingly

being used by college students everywhere to protect against the recent rise in

students as the target of abductors.

1.3 Defining the System This section contains a brief description of the system functionality.

1.3.1 Main System Operations  

Auto-tracking system basically is a system that tracks the vehicle location and speed

periodically, the delivered data is sent serially to a processing unit (MC PIC), the

processing unit uses this data to do the following operations:

I. To warn the driver if the speed of the vehicle exceeds the speed limits allowed

in the street where the vehicle moves.

II. To determine the vehicle exactly location using GPS coordinate.

III. The Received coordinate will compared with stored coordinate in MC PIC and

print the vehicle city location at LCD.

  

4 | P a g e   

Detection and Tracking using GSM and GPS technology

1.4 System Requirements 1.4.1 Functional Requirements

1.4.2 System Functional Requirements I. The system should be able to receive a GPS message every three seconds.

1.1 The GPS receiver receives a Radio Technical Commission for Maritime

Services (RTCM) message as an input.

1.2 The GPS receiver generate the special type of National Marine Electrical

Association (NMEA) messages which is the Recommended Minimum

Specific (RMC) output message, this message contains the time, date,

position, course, and speed data.

1.3 We’ve chosen the three seconds period; we think it’s a suitable period to

track all vehicle moves and fit.

II. The system should be able to warn the driver about his/her speed violation

within an acceptable time, so the system should be able to analyze the received

messages and filter them to get the useful ones and drop the others .

2.1 after the micro controller received NMEA string data; the processor

buffers the message into its own memory.

2.2 The processor then checks if the message is valid or corrupted this is done

by checking it with stored string in MC “PIC 16f877A”.

2.3 Then the processor partitions the message and gets the location coordinate

and the speed of the vehicle.

2.4 According to this data (location and speed ) the processor decides what to

do with this data (Alarm Message, display it on LCD), if the processor decides

to send alarm message the processor has to work on the following steps:

- If the Vehicle exceed speed limits and still in the same speed alarm message

will send for once time

- If the Vehicle speeding a second message will sent.

- If the vehicle decreases in speed no alarm message sent will vehicle not

parking yet.

III. The System should be able to display vehicle location at LCD and displays

discover if the vehicle moved out of coverage area.

IV. The System have to send clear displayed alarm SMS to the end user.

5 | P a g e   

Detection and Tracking using GSM and GPS technology

1.4.3 Non-Functional Requirements  

I. Performance

The microcontroller should be able to process the 3-seconds regular incoming

message from the GPS and be able to analysis these data and display it on

LCD

II. Accuracy

It’s important for the system to know exactly where it is so it can determine

the speed limit and any violations occurrences ,we will do our best in

determining the exact location with the error of (-3,3) meters provided by the

GPS Receiver.

III. Reliability

The system should be on and available all the time, it must endure the

different weather changes

IV. Usability

The system can be installed in the vehicle regardless of its type or

manufacturing and we tried to use readable friendly interfaces since the user is

not supposed to be a professional.

1.4.4 Major Constraints  

1. The system (product) should have a good package design so it can be installed simply in any vehicle.

2. The power consumption has to be taken into consideration. 3. The processor frequency has to be taken into consideration, such that it can

process the incoming messages, applying its algorithms, and finish the output stages in an acceptable time.

4. The algorithm that decides if the data is usable or not has to be smart enough so that no redundant or processing unwanted data.

5. The system should have to warn the driver about his speed violation within an acceptable period, hence, he can reduce his speed.

 

 

6 | P a g e   

Detection and Tracking using GSM and GPS technology

1.4.5 System Architecture

Figure (1) System Architecture 

 

GPS: The GPS receiver received a GPS message as an input and deliver it to the main

Microprocessor, the main Microprocessor performs an algorithm over this message

and the results is delivered to LCD screen.

Microprocessor (16f877A): the main microprocessor receives the GPS message and

applies the main algorithm on it, based on this algorithm; the microprocessor will do

the following tasks:

I. Parse the GPS message to extract some values (e.g. longitude, latitude and

speed) and use them as the algorithm main parameters.

II. Compare the longitude and the latitude with storage data to check on which

city the car is traveling and comparing the maximum and minimum allowed

speed with the received speed, and then display the status of the car (e.g.

Speed, longitude latitude and city location) on LCD screen.

7 | P a g e   

Detection and Tracking using GSM and GPS technology

III. Deal with one of the multiple cases that will raise corresponding to the

received data from the co-processor:

• Normal speed: the default state of the system which represent the

standard driving condition.

• Low speed: the speed of the car is lower than the minimum speed on

a specific road, and a statement will be shown on the LCD warning the

driver of his low speed.

• High speed: the speed of the car is higher than the maximum speed

on a specific road, and a statement will be shown on the LCD warning

the driver of his high speed.

MAP:it’s part of microcontroller contains a storage data for main cities of Jordan and

used as assistant part to the Microcontroller to locate the object address.

GSM Modem: it is the wireless communication tool used to transmit an alarm

messages through global system for mobile network to the transportation manager

which he/she also have a GSM modem (Mobile) to received alarm message

LEDS: it uses to indicate the system supplied with power and the flash led indicates

the microprocessor reads the data from GPS receiver.

LCD: To warn the driver about speed violation and display the vehicle location,

speed coordinate and also used to alarm the driver an alarm SMS have sent.

8 | P a g e   

Detection and Tracking using GSM and GPS technology

CHAPTER TWO

SYSTEM COMPONENTS

 

 

   

9 | P a g e   

Detection and Tracking using GSM and GPS technology

 

 

 

2.1 Microcontroller 2.1.1 PIC 16F877A Architecture  

PIC refers to Programmable Interface

Controller. This powerful (200 nanosecond

instruction execution) yet easy-to-program

(only 35 single word instructions) CMOS

FLASH-based 8-bit microcontroller packs

Microchip's powerful PIC® architecture into

an 40- or 44-pin package and is upwards

compatible with the PIC16C5X,

PIC12CXXX and PIC16C7X devices. The PIC16F877A features 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, the

synchronous serial port can be configured as either 3-wire Serial Peripheral Interface

(SPI) or the 2-wire Inter-Integrated Circuit (I²C) bus and a Universal Asynchronous

Receiver Transmitter (USART). All of these features make it ideal for more advanced

level A/D applications in automotive, industrial, appliances and consumer

applications.

CHAPTER TWO SYSTEM COMPONENTS

Figure (2) PIC 16F877A

The core feature includes interrupt capability up to 14 sources, power saving SLEEP

mode, and single 5V In-Circuit Serial Programming (ICSP) capability. The

sink/source current, which indicates a driving power from I/O port, is high with

25mA. Power consumption is less than 2mA in 5V operating condition.

 

 

10 | P a g e   

Detection and Tracking using GSM and GPS technology

2.1.2 Design & Implementation

Clock Circuit We connect the crystal which is responsible to generate

the signal to the OSC1/CLKIN pin. And we need two (22pF)

capacitors to be connected to both sides of the crystal, and then connect the other

ends of the capacitors to the

ground.

Crystal options are (4 MHz – 20 MHz) and this

affect the code, so we need to put set the configuration

register in the PIC to High Speed (HS).

The capacitors value is related to the crystal used as the

following table:

Table 1: Crystal ‐ Capacitors compinations 

Figure (3) clock 

 

In our system we have chosen 4MHz crystal, that will provide our system with the

speed needed and the serial transmission used.

11 | P a g e   

 

Res 

The

the

MC

to th

2.Liqu

high

liqu

cont

whi

cont

char

cont

LCD

40x

HD

mod

igno

Our

whe

mic

conn

set Circuit 

e reset circu

PIC 16F877

CLR* in PIC

he Vcc.

2 LCDuid Crystal

h contrast a

uid crystal

troller and

ich have low

troller is eq

racter gene

trollable by

D modules

x4. Here we

44780 com

dules withou

ore 15th and

r system wi

en the drive

crocontroller

nected to po

uit is implem

7A to +5V

C is active lo

D (2xl Display (L

nd large vie

panel cont

d all nece

w power co

quipped with

erator RAM

y instruction

are availab

e have used

mpatible mo

ut backlight

d 16th pins.

ill use the

er exceeds th

r sends th

ort D.

Det

mented by co

source usin

ow, so we c

x16) LCD) cons

ewing angle

tains a CM

essary driv

onsumption

h an interna

M and disp

ns making in

ble in a wid

d 16x2- that

odule, havin

t will have

LCD as an

he maximu

he data to

tection and T

onnecting th

ng pull-up re

connect the M

sists of

e. The

MOS

vers

. The

al character

playing dat

nterfacing p

de range lik

t means 2 r

ng 16 pins

only 14 pin

n interface f

um allowed

the LCD

Tracking usin

he MCLR*

esistor.

MCLR* pin

generator R

ta RAM. A

practical.

ke 8x1, 8x2

rows of 16

including 2

ns. If you are

for the driv

speed on a

ports in p

ng GSM and

in

n

ROM,

All display

2, 16x1, 16x

characters.

2 pins for b

e using such

ver to outpu

specific loc

parallel thro

d GPS techno

12 | P a

y functions

x2, 20x2, 2

. It is a Hit

backlight. L

h LCDs, sim

ut the warn

cation. The

ough the l

Fi

ology

a g e  

are

20x4,

tachi

LCD

mply

nings

PIC

lines

gure (4) reseet circuit 

Detection and Tracking using GSM and GPS technology

2.2.1 Implementation 

Pin Connections  

Figure (5) LCD pin connections  

The LCD contains 16 pins, the first 14 pins

will be used and the last 2 pins are not

connected as they are used to be connected

to external LEDs for testing.

The first pin is connected to the Ground. The

second is connected to the +5 voltage source

to provide power to the LCD, and the third

pin is connected to the Ground.

The fourth pin is the register select pin, and

it will be attached to pin 20 from the

PIC16F877A which is the WR enable pin.

The next pin is the Read/Write signal and it will be connected to pin 21 from the PIC.

The sixth pin is the enable pin for the LCD and it will be connected to pin 19 from the

PIC 16F877A, which is the RD enable signal.

The next 4 pins are from the data bus lines, and they will be connected to the ground.

The next 4 pins from the data bus lines are connected to RB4-RB7 respectively from

the PIC 16F877A, as they need to receive parallel data from the PIC 16F877A.

To send data to the LCD, the Read/Write signal must be low, and so it is connected to

the ground, and the enable signal must be enabled high to low, and the RS must be 1

as the data register must be selected.

13 | P a g e  

 

Detection and Tracking using GSM and GPS technology

2.3 MAX RS232

RS232 is an asynchronous serial communications

protocol, widely used on computers. Asynchronous

means it doesn’t have any separate synchronizing clock

signal, so it has to synchronous itself to the incoming

data; doing this by the use of ‘START’ and ‘STOP’

pulses.

The signal itself slightly unusual for computers, as rather than the normal (0-5) V

range, it uses (+12…-12)V this is done to improve reliability, and greatly increase

the available range it can work over; it isn’t necessary to provide this exact

voltage swing, and we can actually use PIC’S (0-5)V voltage swing with a couple

of resistors to make a simple RS232 interface which will usually work done, but

at our project we don’t guaranteed to work with all serial ports. For this reason

we use the

(MAX RS232) chip, this chip specially designedfor interfacing between 5V logic

levels and +12/-12V of RS232, it generates +12/-12V internally using capacitor

charge pumps, and includes four converters, two transmitters and two receivers.

2.3.1Implementation

Pin connections

The MAX RS232 contains 16 pins, the first and third pins is connected by (1uF

capacitor), and the fourth and fifth pins is connected by (1uF capacitor) too.

The second pin is connected with Vcc by (1uF capacitor) while the sixth pin is

connected to the Ground by (1uF capacitor).

The pin number 15 is connected to the circuit’s Ground and the pin number 16 is

connected to the Vcc.

14 | P a g e   

 

The

the

conn

(R1

the

rece

2.

Tan

to s

for o

e pin numbe

output pin

nected to th

-out) from

PIC 16F87

eiver.

4 GSM

ngo (55i) wa

specific pho

our project

Work on

Serial int

SIM card

er 11 (T1-in

n 25 from

he GSM mo

the MAX R

77A, and t

M mo

as the best

one number

and these a

n three frequ

terface RS2

d reader: Sm

Det

n) is the inp

the PIC 1

odem by R

RS232 is c

the pin 13

odem

choice for o

rs, which su

are:

uencies rang

232 for AT c

mall SIM ca

tection and T

put pin and

16F877A, t

RS232 cable

onnected to

(R1-in) is

our project

upports man

ges900/1800

commands.

ards.

Tracking usin

d it will be c

the pin 14

e, and finall

o the input

connected

to send SM

ny features

0/1900 MH

ng GSM and

connected t

(T1-out) i

ly the pin 1

pin 26 from

to the GP

MS alarm

services

Hz.

Figu

d GPS techno

15 | P a

to

is

2

m

PS

ure (6) MAX 

ology

a g e  

RS232 pin coonnections

Detection and Tracking using GSM and GPS technology

2.5 GPS Simulator

In our project we used program software installed in PC work as GPS receiver,

the program emulates the operation of a GPS receiver (position, speed of relocation,

reception quality, and satellite constellation) and gives out GPS data based on the

NMEA-0183 protocol v. 2.0, 2.1, 2.3 or 3.0.

This virtual GPS receiver can work without visible GPS satellites, thus it's much more

efficient when used indoors. Besides, purchasing the program costs less, than

purchasing a GPS receiver.

The program can be configured for getting certain NMEA protocol messages in a

certain sequence with a certain frequency. The output NMEA protocol can be written

to a file or transmitted via COM port. Any program or equipment working with the

NMEA protocol will recognize transmitted messages, created by the GPS Generator,

as data from a real receiver. A certain amount of parity errors (CRC) can be

introduced in the generated protocol.

The program supports several operation modes, and it can give out output data to a

COM port (including a virtual one) or save to a file. The saved file can also be re-

played providing an opportunity for creating repeatable work scenarios, which would

be difficult to do with an actual GPS receiver.

16 | P a g e   

 

 

 

Det

Figure(7) Th

 

tection and T

he main prog

 

Tracking usin

gram window

ng GSM and

w

d GPS techno

17 | P a

ology

a g e  

Detection and Tracking using GSM and GPS technology

Figure (8) Theschematic of the project 

 

 

 

 

 

 

 

 

 

18 | P a g e   

Detection and Tracking using GSM and GPS technology

CHAPTER THREE

SOFTWARE

 

 

 

 

 

 

   

19 | P a g e   

Detection and Tracking using GSM and GPS technology

 

 

 

 

CHAPTER THREE SOFTWARE

3.1 Introduction Software it’s the core communication language between the input/output of the

microcontroller gates and it’s also the interface language with microcontroller and

other devices.

3.2 PIC Programming As we mentioned earlier, we have used the PIC microcontroller. PICs can be programmed by:

Assembly Language: PIC assembly language is the lowest-level programming language for Microchip PIC Microcontrollers. Its assembly language contains only 35 instructions, easy to learn, easy to use.

C language: PIC microcontrollers can be programmed using C language too, because of the present of compilers such as (MikroC, PIC C) that convert the C syntax and codes to its appropriate assembly language.

Frankly, we have used the C language to program our system, because our system is large enough to be not written in the assembly language, and because of the facilities that integrated with such compilers.

20 | P a g e   

 

3.2PICWe

2.1 DeveC C Compile

have used t

Deta

Built

initia

(Uni

Debu

Adva

Code

elopmeer the “Pic C”

ailed statistic

t-in Librarie

alization of

versal Seria

ugger with m

anced code

e explorer.

Det

ent Tool

compiler w

cs about the

es that help

f the comp

al Asynchro

many advan

assistant.

Fig

tection and T

ls 

which has th

e usage of th

s reduce the

ponents us

onous Recei

nced option

gure (9) PIC C              

Tracking usin

he following

he RAM, E

e code and

ed from th

iver/Transm

ns.

C compiler 

ng GSM and

g features:

EPROM, et

simplify the

he PIC su

mitter).

d GPS techno

21 | P a

tc….

e process o

uch as USA

ology

a g e  

f the

ART

 

 

 Pr

 

Prot

man

our

 

 

Usin

with

func

 

roteus (Sim

teus is a sim

ny compone

code on the

ng “Proteus

h virtual te

ctionality.

ulation Too

mulation too

ents we hav

e simulator

s” we can si

erminal, so

Det

ol)

ol used to d

e used such

before burn

Figure(1

imply simul

o we can s

tection and T

design and b

h as (PIC), s

n it on the P

10) Proteus S

late serial d

send and re

Tracking usin

build schem

so we can si

PIC.

Simulator 

devices such

eceive to te

ng GSM and

matics, altho

imulate the

h as GPS Re

est our prog

d GPS techno

22 | P a

ough it supp

functionalit

eceiver and

gram & de

ology

a g e  

ports

ty of

 

PIC

esign

Detection and Tracking using GSM and GPS technology

3.3 Code Segments This figure shows the main code segments that represent the basic functionality of our

system. These parts are dependent and may use shared variables (global) and common

functions.

Because of the limitation provided by the PIC such as limited stack, we forced to use

structural programming approach sometimes to avoid stack overflow.

Each statement written in PIC-C may be parsed to more than ten assembly

instructions.

 

  

Figure(11) Code Segment         

    

23 | P a g e   

Detection and Tracking using GSM and GPS technology

3.3.1 PSEUDO CODES (Program Description Language – PDL) START #INITIALIZE PIC TYPE  #DEFINE baud rate #INITIALIZING RS232 CABLE #ENABLE INTERUBTS  INITIALIZING LCD(2x16) INABLE INTERRUBTS DEFINE variables  VOID MAIN() PRINT  “WELCOME MSG” #INITIALIZING GSM modem DO FOREVER WAIT UNTEL CHARACTER RECEIVED   //////‐‐‐‐‐‐MSGPARSE‐‐‐‐‐‐////// IF received character = ‘$GPRMC’ THEN   PUCH INTO THE message array 

INDEX=0 READ RECEIVED CHARACTER  SWITCH (INDEX) CASE (3): STORE longitude coordinate Break;  CASE (5): STORE latitude coordinate Break;  CASE (7): STORE speed //////‐‐‐‐‐‐speed limits‐‐‐‐‐‐////// If (speed<12km/h AND speed>120km/h) THEN PRINTLCD(“alarm message”)  CALL ALARM SMS  //////‐‐‐‐‐‐SMS Type‐‐‐‐‐‐////// Longitude= ‘var longitude’ Latitude= ‘var latitude’ Speed= ‘ var speed ‘ Country :Jordan City: ‘var City’ 

24 | P a g e   

Detection and Tracking using GSM and GPS technology

25 | P a g e   

ELSE PRINTLCD (“location, speed, coordinate”) END IF Break; END DO 

ELSE PRINT ‘loading…’   

ENDIF END DO END 

 

3.3.2 Programming Language (indirect connection) The “PIC C” compiler is designed to be compatible for compiling program code from

high level language into low level language “machine language”, it is also interfacing

language between GPS protocol language “NMEA” and GSM protocol Language

“AT-Commands” to make open communication channels through RS232 Cable

between GPS and GSM network this type of connection called indirect connection.

              

Figure(12) Indirect Interface        

GPS protocol Language The GPS Receiver Module provides standard, raw NMEA0183 (National Marine

Electronics Association) strings or specific user-requested data via the serial

command interface, tracking of up to 12 satellites, and WAAS/EGNOS (Wide Area

Augmentation System/European Geostationary Navigation Overlay Service)

functionality for more accurate positioning results.

Object Code  “C” language 

Programmed Device 

 “Pic 16f877a” 

Compiling File.hex 

GPS Receiver “Parallax module”  

RS232 GSM Modem “Tango055”  RS232 

Compiler Interfacing Device “Pic 16f877a” 

Installatio

Detection and Tracking using GSM and GPS technology

The Module provides current time, date, latitude, longitude, altitude, speed, and travel

direction/heading, among other data, and can be used in a wide variety of hobbyist

and commercial applications, including navigation, tracking systems, mapping, fleet

management, auto-pilot, and robotics.

The NMEA0183 is provided as a series of comma-delimited ASCII strings, each

preceded with an identifying header. The data is transmitted as a 4800bps string of 8-

bit ASCII characters. Thus, any microcontroller with a serial port can extract data

from a GPS module. But, modules do not produce "plain text" location information.

Instead, they create standardized "sentences," such as:

  

$GPGGA,170834,4124.8963,N,08151.6838,W,1,05,1.5,280.2,M,‐34.0,M,,,*75  $GPGSA,A,3,19,28,14,18,27,22,31,39,,,,,1.7,1.0,1.3*34  $GPGSV,3,2,11,14,25,170,00,16,57,208,39,18,67,296,40,19,40,246,00*74  $GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*70 

 

In our project the NMEA string we have recommended to use is RMC string witch

support PVT (position, velocity, Time) data which exactly looking for and it is look

similar to:

 

$GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A 

 Where: RMC  : Recommended Minimum sentence C 123519  : Fix taken at 12:35:19 UTC A  : Status A=active or V=Void. 4807.038,N  :Latitude 48 deg 07.038' N 01131.000,E  :Longitude 11 deg 31.000' E      022.4  : Speed over the ground in knots 084.4  : Track angle in degrees True 230394  : Date ‐ 23rd of March 1994 003.1,W  :Magnetic Variation *6A  : The checksum data, always begins with *  

26 | P a g e   

Detection and Tracking using GSM and GPS technology

The  Microcontroller  programmed  to  receive  RMC  string  Data  and  parsing  it  using  the example code provided as bellow:  

#include <18f452.h>      //DEFINE DEVICE TYPE #use delay(clock=20000000)    //DEFINE 20MHz CLOCK #include <lcd.c>        //DEFINE LCD LIBRARY #include <string.h> #include <stdlib.h> #use rs232(baud=9600, xmit=PINC6, rcv=PINC7,ERRORS)  //RS232 INITIALIZING #ZERORAM        //CLEAR RAM  //Variables and Arrays definition static char RX[80],s1[10],s2[12],s3[12],speed[12],string[80]; static int8 i; static int8 ff=0;  // RS232 receive data available //$GPRMC,035249.06,A,0000.018,N,00000.000,E,21.00,0.00,040610,0.0,E,A*05 #intrda//(ISR)Interrupt Service Routine Declaration void serialisr() { RX[i++]=getch();                   //Receive data from RS232 ff=1; }  ///////////////////////////‐‐‐‐‐‐‐‐‐Main‐‐‐‐‐‐‐/////////////////////////////////  void main()                                 //Main Start programe { lcdinit();                               //Initializing LCD ff=0;                                     //Return flag 0 outputhigh(pina1);                    //Red Led indicate the siystem on state lcdputc("\fAuto Tracking System\n"); lcdputc("Graduated project 2010"); delayms(1500); //$GPRMC,211230.49,A,3058.865,N,03528.388,E,25.09,54.10,040610,0.0,E,A*06 enableinterrupts(GLOBAL);            //Enable interrupts enableinterrupts(INTRDA);          //Enable RS232 interrupt while(true) { if(ff=1);                                //Interrupt subroutine { intjj,a; int k=0; int l=0; 

27 | P a g e   

Detection and Tracking using GSM and GPS technology

int e; int d=0; //printf("%s",RX); //printf("\r\n"); strcpy(string,RX);       //STORE RECEVED DATA ON STRING a=strlen(string);        //CALCULATE STRING LINGTH for(jj=0;jj<=a;jj++)      //GET “ $GPRMC”  STRIG { if (jj>18 &&jj<27)      //GET  OBJECT LATITUDE { s1[k]=RX[jj];        //STORE RESULT IN S1 ARRAY AS STRING k++; } if (jj>29 &&jj<39)      //GET OBJECT  LONGTITUDE { s2[l]=RX[jj];        //STORE  LONGTITUDE IN S2 ARRAY AS STRING l++; } if (jj>41 &&jj<47)      //GET OBJECT SPEED { speed[d]=RX[jj];        //STORE SPEED IN SPEED ARRAY AS STRING d++; } }          //END printf("%s",s1);        //PRINT ARRAY S1 printf(" | "); printf("%s",s2);        //PRINT ARRAY S2 printf(" | "); printf("%s",speed);      //PRINT ARRAY SPEED printf(" | \r\n"); delayms(3000);   ff=0; i=0;  }          //end if }          //while }          //end main 

 

The result data will be calculated and compared with stored data on PIC memory.

The Output will look like :

 0000.018 | 00000.000 | 21.00   

28 | P a g e   

Detection and Tracking using GSM and GPS technology

GSM protocol Language (Command Line) Commands always start with AT (which means Attention) and finished with <CR>

character, the AT commands responses start and ends with <CR><LF>.

The Response of GSM modem to the received command:

- If command syntax is incorrect, an ERROR string return.

- If command syntax is correct but with some incorrect parameters, the +CME

ERROR: <Err> or +CMS ERROR:<SmsErr> string are returns with different

error codes.

- If the command line has been performed successfully, an OK string is returned.

29 | P a g e   

Detection and Tracking using GSM and GPS technology

CHAPTER FOUR

GPS TECHNOLOGY  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

30 | P a g e   

Detection and Tracking using GSM and GPS technology

 

 GPS TECHNOLOGY CHAPTER

FOUR

4.1 GPS Definition

The Global Positioning System (GPS) is a worldwide radio-navigation system formed

from a constellation of 24 satellites and their ground stations.

GPS uses these as reference points to calculate positions accurate to a matter of

meters. In fact, with advanced forms of GPS you can make measurements to better

than a centimeter!

In a sense it's like giving every square meter on the planet a unique address.

GPS receivers have been miniaturized to just a few integrated circuits and so are

becoming very economical. And that makes the technology accessible to virtually

everyone.

These days GPS is finding its way into cars, boats, planes, construction equipment,

movie making gear, farm machinery, even laptop computers.

4.1.1 Advanced Forms of GPS

The quest for greater and greater accuracy has spawned an assortment of variations on

basic GPS technology. One technique, called "Differential GPS," involves the use

of two ground-based receivers. One monitors variations in the GPS signal and

communicates those variations to the other receiver. The second receiver can then

correct its calculations for better accuracy.

Another technique called "Carrier-phase GPS" takes advantage of the GPS signal's

carrier signal to improve accuracy. The carrier frequency is much higher than the GPS

signal which means it can be used for more precise timing measurements.

31 | P a g e   

Detection and Tracking using GSM and GPS technology

The aviation industry is developing a type of GPS called "Augmented GPS" which

involves the use of a geostationary satellite as a relay station for the transmission of

differential corrections and GPS satellite status information. These corrections are

necessary if GPS is to be used for instrument landings. The geostationary satellite

would provide corrections across an entire continent.

4.2 How GPS works?

Here's how GPS works in five logical steps:

1. The basis of GPS is "Trilateration*" from satellites.

2. To “Trilateration" a GPS receiver measures distance using the travel time of

radio signals.

3. To measure travel time, GPS needs very accurate timing which it achieves

with some tricks.

4. Along with distance, you need to know exactly where the satellites are in

space. High orbits and careful monitoring are the secret.

5. Finally you must correct for any delays the signal experiences as it travels

through the atmosphere.

* Trilateration is a method of determining the relative positions of objects using the geometry of

triangles.

32 | P a g e   

Detection and Tracking using GSM and GPS technology

4.2.1 Generating GPS signal

28 satellites inclined at 55° to the equator orbit the Earth every 11 hours and 58

minutes at a height of 20,180 km on 6 different orbital planes.

Figure (13) GPS satellites orbit the Earth on 6 orbital planes [1] 

Each one of these satellites has up to four atomic clocks on board. Atomic clocks are

currently the most precise instruments known, losing a maximum of one second every

30,000 to 1,000,000 years. In order to make them even more accurate, they are

regularly adjusted or synchronized from various control points on Earth. Each satellite

transmits its exact position and it’s precise on board clock time to Earth at a frequency

of 1575.42MHz.These signals are transmitted at the speed of light (300,000 km/s) and

therefore require approx. 67.3ms to reach a position on the Earth’s surface located

directly below the satellite. The signals require a further 3.33 us for each excess

kilometer of travel. If you wish to establish your position on land (or at sea or in the

air), all you require is an accurate clock. By comparing the arrival time of the satellite

signal with the on board clock time the moment the signal was emitted, it is possible

to determine the transit time of that signal.

33 | P a g e   

Detection and Tracking using GSM and GPS technology

Figure (14) Determining the transit time [1] 

The distance S to the satellite can be determined by using the known transit time τ:

Distance= travel tim  × the speed of light e

S =   × c 

Measuring signal transit time and knowing the distance to a satellite is still not enough

to calculate one’s own position in 3D space. To achieve this, four independent transit

time measurements are required. It is for this reason that signal communication with

four different satellites is needed to calculate one’s exact position.

4.2.2 Determining a position on a plane Imagine that you are wandering across a vast plateau and would like to know where

you are. Two satellites are orbiting far above you transmitting their own on board

clock times and positions. By using the signal transit time to both satellites you can

draw two circles with the radii S1 and S2 around the satellites. Each radius

corresponds to the distance calculated to the satellite. All possible distances to the

satellite are located on the circumference of the circle. If the position above the

satellites is excluded, the location of the receiver is at the exact point where the

two circles intersect beneath the satellites, Two satellites are sufficient to determine a

position on the X/Y plane.

34 | P a g e   

Detection and Tracking using GSM and GPS technology

 Figure (15) The position of the receiver at the intersection of the two circles [2] 

In reality, a position has to be determined in three-dimensional space, rather than on a

plane. As the difference between a plane and three-dimensional space consists of

an extra dimension (height Z), an additional third satellite must be available to

determine the true position. If the distance to the three satellites is known, all

possible positions are located on the surface of three spheres whose radii correspond

to the distance calculated. The position sought is at the point where all three surfaces

of the spheres intersect.

 Figure (16) The position is determined at the point where all three spheres intersect [3] 

35 | P a g e   

Detection and Tracking using GSM and GPS technology

4.3 GPS Receiver GPS receivers require different signals in order to function. These variables are

broadcast after position and time have been successfully calculated and

determined. To ensure that the different types of appliances are portable there

are either international standards for data exchange (NMEA and RTCM), or the

manufacturer provides defined (proprietary) formats and protocols.

4.3.1 Basic design of a GPS module GPS modules have to evaluate weak antenna signals from at least four satellites, in

order to determine a correct three-dimensional position. A time signal is also often

emitted in addition to longitude, latitude and height. This time signal is synchronized

with UTC (Universal Time Coordinated). From the position determined and the exact

time, additional physical variables, such as speed and acceleration can also be

calculated. The GPS module issues information on the constellation, satellite health,

and the number of visible satellites etc.

 

 

 

 

36 | P a g e   

Detection and Tracking using GSM and GPS technology

4.3.2 Data interfaces The NMEA-0183 data interface

In order to relay computed GPS variables such as position, velocity, course etc. to a

peripheral (e.g. computer, screen, and transceiver), and GPS modules have a serial

interface (TTL or RS-232 level). The most important elements of receiver information

are broadcast via this interface in a special data format. This format is standardized by

the National Marine Electronics Association (NMEA) to ensure that data exchange

takes place without any problems. Nowadays, data is relayed according to the

NMEA-0183 specification. NMEA has specified data sets for various applications e.g.

GNSS (Global Navigation Satellite System), GPS, Loran, Omega, Transit and

also for various manufacturers. The following seven data sets are widely used with

GPS modules to relay GPS information:

1. GGA (GPS Fix Data, fixed data for the Global Positioning System)

2. GLL (Geographic Position – Latitude/Longitude)

3. GSA (GNSS DOP and Active Satellites, degradation of accuracy and the

number of active satellites in the Global Satellite Navigation System)

4. GSV (GNSS Satellites in View, satellites in view in the Global Satellite

Navigation System)

5. RMC (Recommended Minimum Specific GNSS Data)

6. VTG (Course over Ground and Ground Speed, horizontal course and

horizontal velocity)

7. ZDA (Time & Date)

Structure of the NMEA protocol

In the case of NMEA, the rate at which data is transmitted is 4800 Baud using

printable 8-bit ASCII characters. Transmission begins with a start bit (logical zero),

followed by eight data bits and a stop bit (logical one) added at the end. No parity bits

are used.

37 | P a g e   

Detection and Tracking using GSM and GPS technology

Figure (17) NMEA format (TTL and RS‐232 level) [6] 

The different levels must be taken into consideration depending on whether the GPS

receiver used has a TTL or RS-232 interface.

• In the case of a TTL level interface, a logical zero corresponds to approx. 0V and a

logical one roughly to the operating voltage of the system (+3.3V ... +5V)

• In the case of an RS-232 interface a logical zero corresponds to a positive voltage

(+3V ... +15V) and a logical one a negative voltage (-3V ... –15V).

If a GPS module with a TTL level interface is connected to an appliance with

an

RS-232 interface, a level conversion must be effected.

A few GPS modules allow the baud rate to be increased (up to 38400 bits per second).

RMC data set

The RMC data set (Recommended Minimum Specific GNSS) contains information on

time, latitude, longitude and height, system status, speed, course and date. This data

set is relayed by all GPS receivers.

An example of an RMC data set:

$GPRMC,130304.0,A,4717.115,N,00833.912,E,000.04,205.5,200601,01.3,W*7C<CR><LF>

38 | P a g e   

Detection and Tracking using GSM and GPS technology

The function of the individual characters or character sets is explained in the Table

below.

 

Description of the individual RMC data set blocks

 

   

39 | P a g e   

Detection and Tracking using GSM and GPS technology

CHAPTER FIVE

GSM TECHNOLOGY  

   

40 | P a g e   

Detection and Tracking using GSM and GPS technology

 

 

 

GSM TECHNOLOGY CHAPTER FIVE

5.1 What is GSM?

Global System for Mobile Communications (GSM) is a digital cellular radio network

operating in over 200 countries world-wide. It provides almost complete coverage in

Western Europe, and growing coverage in the Americas, Asia and elsewhere. Of special interest is the capability of the GSM network to be used for data

computing. Most people think of voice calls when they think of cellular phones. But

because GSM is digital, GSM-enabled phone can be connected to a computer and

send or receive e-mail, faxes, browse the Internet, and use other digital data features

including Short Messaging Service. The unique roaming features of GSM allow

cellular subscribers to use their services in any GSM service area in the world in

which their provider has a roaming agreement that means the phone used in Jordan

could work in Germany, Australia, Finland and even China, depending on the

provider’s roaming agreements.

GSM-enabled phones have a "smart card" inside called the Subscriber Identity

Module (SIM). The SIM card is personalized to the person alone. It identifies the

account to the network and provides authentication.

Short Message Service (SMS) is an integrated paging service that lets GSM cellular

subscribers send and receive data right on their cellular phone's light emitter

diode(LED)display up to a maximum of 160 characters. The structure of an SMS

message includes the mobile number the message is originating from, time, date,

country code, length and the actual message.

41 | P a g e  

 

Detection and Tracking using GSM and GPS technology

5.2 GSM modem

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.

A GSM modem can be an external device or a PC Card / PCMCIA Card. Typically,

an external GSM modem is connected to a computer through a serial cable or a USB

cable. A GSM modem in the form of a PC Card / PCMCIA Card is designed for use

with a laptop computer. It should be inserted into one of the PC Card / PCMCIA Card

slots of a laptop computer.

Like a GSM mobile phone, a GSM modem requires a SIM card from a wireless

carrier in order to operate.

Computers use AT commands to control modems. Both GSM modems and dial-up

modems support a common set of standard AT commands.

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.

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.

42 | P a g e   

Detection and Tracking using GSM and GPS technology

5.3 SMS messaging

SMS stands for Short Message Service. It is a technology that enables the sending and

receiving of messages between mobile phones. SMS first appeared in Europe in 1992.

It was included in the GSM (Global System for Mobile Communications) standards

right at the beginning. Later it was ported to wireless technologies like CDMA and

TDMA. The GSM and SMS standards were originally developed by ETSI. ETSI is

the abbreviation for European Telecommunications Standards Institute. Now the

3GPP (Third Generation Partnership Project) is responsible for the development and

maintenance of the GSM and SMS standards.

As suggested by the name "Short Message Service", the data that can be held by an

SMS message is very limited. One SMS message can contain at most 140 bytes (1120

bits) of data, so one SMS message can contain up to:

• 160 characters if 7-bit character encoding is used. (7-bit character encoding is

suitable for encoding Latin characters like English alphabets.)

• 70 characters if 16-bit Unicode UCS2 character encoding is used. (SMS text

messages containing non-Latin characters like Chinese characters should use

16-bit character encoding.)

SMS text messaging supports languages internationally. It works fine with all

languages supported by Unicode, including Arabic, Chinese, Japanese and Korean.

Besides text, SMS messages can also carry binary data. It is possible to send

ringtones, pictures, operator logos, wallpapers, animations, business cards (e.g.

VCards) and WAP configurations to a mobile phone with SMS messages.

One major advantage of SMS is that it is supported by 100% GSM mobile phones.

Almost all subscription plans provided by wireless carriers include inexpensive SMS

messaging service. Unlike SMS, mobile technologies such as WAP and mobile Java

are not supported on many old mobile phone models.

43 | P a g e  

 

Detection and Tracking using GSM and GPS technology

44 | P a g e   

References: [1] GPS Basics Introduction to the system Application overview Zuercherstrasse68 CH-8800Thalwil Switzerland [2] Global Positioning System, Standard Positioning System Service, Signal Specification, 2nd Edition, 1995, [3] GPS Standard Positioning Service Signal Specification, 2nd Edition, June 2, 1995 [4] Jan A. Audestad. Network aspects of the GSM system. In EUROCON 88, June 1988 [5] DavidCheeseman. The pan-European cellular mobile radio system. In R.C.V. Macario, editor, Personal and Mobile Radio Systems. Peter Peregrinus, London, 1991. [6] http:// www.trimble.com/gps/howgps-timing.shtml [7] C. Watson. Radio equipment for GSM. In D. M. Balston and R.C.V. Macario, editors, Cellular Radio Systems. Artech House, Boston, 1993. [8] http:// www.labcenter.co.uk [9] http://www.proteuslite.com/register/ipmbundle.htm. [10] Programming 8bit microcontroller in C with interactive hardware simulation.Martin.P.Bates