The Development of Embedded GPS-GSM Based Real Time Vehicle Tracking System

The project is an integrated system which is placed inside a vehicle for the purpose of tracking it to determine its current GPS location in the real time, the system use Global System for Mobile communication (GSM) network as a medium to send the information to a monitoring station in two way: the first way by using Short Messaging Service (SMS) while the second way use General Packet Radio Service (GPRS).The tracking system consist of two general units, the first unit is Vehicle unit and the second is the Monitoring unit. The main components in vehicle unit is the microcontroller (PIC18F452) which is the main part to control all operation in the vehicle starting with read GPS information and the vehicle status ending with sending the collected information to the monitoring unit through the wireless GSM, the second important component is the IC (GM862-GPS) which is a GSM modem, the PIC interfaced to GM862-GPS serially via RS232 interface protocol, so the PIC inquire GPS information from GM and command the GM to send the information to the monitor. The monitoring unit is a Laptop with a Universal Serial Bus (USB) GSM modem connected to it in order to send and receive information to/from GSM network. The information received from the vehicle will be displayed on a Graphic user interface (GUI) designed by Visual Basic (VB), the GPS of the car will be displayed on a Google earth map.


INTRODUCTION
ith the rapid development of technology the need arises to develop an information system which can be used in constructing a system works on a wide geographical area depends mainly on GPS, such systems can be useful for many application such as tracking systems ,chasing systems, anti theft systems, and traffic monitoring systems.Imagine if all vehicles in the world provided with GPS-GSM system and all of applications mentioned above c integrated in one huge system what will be the benefits that can be obtained from such systems?Of course there are a lot of useful information can be collected and transmitted via a wide wireless medium .The only wide geographical one already installed infrastructure in Iraq is the mobile networks therefore we can use it in our proposed system.Tracking system is so important application for governmental organizations and large private companies such as the ministry of Oil to track the path of the tankers of petroleum products and the ministry of health to track the ambulance vehicles.

RELATED WORK
Several researches had been done depend on GPS to predict the objects location but the difference between them is the way the GPS information collected and transmitted to the monitor/control unit.Most of researchers had gone toward the use of embedded system that can operate stand alone, this embedded system is mainly depends on a microcontroller as system core such as AT8951 from Atmel [1], LPC21x8 from ARM [2]-[9], ATMEGA-16 from AVR [5], and PIC18fxxxx from Microchip [6]- [8].
our research based on PIC18f452microcontroller due to its low cost and the PIC is a famous, known, easy to programmed and build with another devices directly such as LCD, it's a reliable controller even its accessories is available such as its programmer, compiler (Micro C),and simulator such as protus (ISIS).One of the important thing is taking the decision about the GPS receiver and GSM modem, choosing the GPS circuit separated from the GSM circuit leads to a real problems such as power consumption and the necessity to build a microcontroller that has two serial ports for each GPS and GSM this will waste time and money, the best choice is using the IC (GM862-GPS) [7]-[11] which will overcome the problems mentioned above.There are two ways to send the information's that is collected from the vehicle unit to the monitoring unit, the first is by SMS

TRACKING SYSTEM OVERVIEW
The tracking system is consisting of two main units; the first is the vehicle unit this unit composes of: PIC18f452 microcontroller circuit board, GM862-GPS board which is manufactured by Microelectronica factory, GM862-GPS IC from Telit manufactory.The unit designed to be connected to the car's battery but when the car is turned off the system will go to power down mode to save the battery although the unit is provided with power switch on/off.The microcontroller connected to GM serially since the GM expect command from its serial port, the microcontroller command the GM to read the GPS information (Latitude,Longitude,speed) then the microcontroller read car status(door status, engine status) after that it command the GM to download a text file called (control.txt)from ftp server, the data stored on this file help the microcontroller to decide the way to send GPS information(SMS,GPRS) and the time to send the next GPS readings (10,15,20,25,30) seconds.After the microcontroller made its decision it will send all data together to the monitoring unit and the data will be separated, processed, and displayed in a suitable way at the monitoring laptop.The second unit is the monitoring unit which is consists of GSM modem which is connected to a laptop via USB port, it is important to know that the data which received from the vehicle should be displayed on GUI designed by using V.B.net and the car coordination will be displaced as a point on Google earth map so in order to get a good response the laptop should provided with fast Internet link, Figure (2) shows both vehicle and monitor unites.The GM862-GPS board is built by MikroElectronika manufacture its operating voltage from 7-32 volts so the board is directly connected to car's battery.The board contain two antenna holders one for GSM network the other for GPS receiver, figure (4) shows the diagram of the board from mikroElektronika [13].

Figure (4) Smart GM862-GPS Circuit Board.
The IC GM862-GPS from Telit is provided with the following interfaces: GSM antenna connector.Board to Board Interface connector .SIM Card Reader .GPS antenna connector .
PDF created with pdfFactory Pro trial version www.pdffactory.com

FIGURE (5) GM862-GPS CONNECTIONS
The Telit GM862-GPS includes two 50 Ohm MMCX coaxial female RF connectors, the first is for GSM antenna with gain < 3dBi, 2 W peak power, and bandwidth 80 MHz in EGSM 900, 70 MHz if GSM 850, 170 MHz in DCS, 140 MHz PCS band.The second connector is for GPS antenna with frequency range 1575.42MHz (GPS L1), bandwidth (+ -1.023 MHz), 1.5 dBi < gain < 4.5 dBi, and typical amplification 25dB (max 27dB).The GM862-GPS module is equipped with a SiRFStar III GPS receiver that is controllable by the GSM modem using a set of AT commands or dedicated NMEA sentences, the GPS navigation data is in NMEA 0183 format [15].The Telit GM862 board to board connector is a CSTP 50 pin vertical SMD Molex 52991-0508 (male).

b) Monitoring Unit
The monitor unit is simply consist of a GSM modem connected to a laptop via USB connector, the modem is released by Zain company in Iraq called (Zain e-GO) as shown in figure (6) and can be provided with SIM card.The modem includes SMS, calling, GPRS services.PDF created with pdfFactory Pro trial version www.pdffactory.com

SOFTWARE SPECIFICATIONS
The software is consisting of two software parts, the first is the monitoring software side and the other is the vehicle software side.The monitoring software side is build with VB.net; it represents the GUI for the user as shown in Figure (7).The GUI consists of two parts the upper part is for controlling issues and the lower is for Google earth browsing.The control part composed from the following: A-Mode Control:the user should choose the mode of operation either SMS or GPRS, also the user should choose the time between readings.B-Date and time now:which is responsible of displaying the current date and time.C-Car status: This is responsible of displaying the status of the engine and the door.D-GPS navigation: this is responsible of displaying the latitude, longitude, car speed, and the time and date as time stamp of the readings.E-GPS control: the user must click start GPS when there is a need for real time tracking and press stop when finish in order to save money.
After the user runs the software it will display default latitude, longitude on the map, then the user chooses the mode of operation.When the user press send control bottom the VB program will write the mode in special file control.txtand the file will uploaded automatically to a FTP server named (www.gps_tracking.zxq.net) by using FTP protocol.When the user press starts GPS the VB try to read the GPS data which received from the vehicle unite according to the mode, if SMS mode it will read the data from special SMS file which contains the messages from the car, and if GPRS mode it will download a special file GPS.txt from the FTP mentioned above.When the VB complete the reading phase it will browse the Google map to mark the new GPS location of PDF created with pdfFactory Pro trial version www.pdffactory.comthe car on the map.Before the data can be displayed it should be rearranged so that to fit in a way can be understood by the user, the data received on monitor unit is ($GPSACP: 080220, 3542.82691N,04444.26820E,259.07, 3, 2.1, 20.2, on, close, 270412,09),the(($GPSACP) represents the GPS data format,(080220) it represents the time of GPS reading and it rearranged to be (08:02:20), (3542.82691N)represents the latitude and it will be divided into two three parts the first (35) the main line and it will remain same the second (42.82691) the friction and it will be divided by 60 so the result of division will be added to the first part, finally the third part(N) will be displayed as it so the final format will displayed as (35.7137818N), (04444.26820E)represents the longitude with the same way as latitude it will rearranged to be as (044,7378033),(20.2) it represents the car speed and it will displayed as it,(on, close) represents the engine and door statues respectively and will displayed as it,( 070412) it represents the date and it will rearranged to be as (07/04/2012),and (09) represents the number of GPS satellites discovered.
The vehicle side software is responsible of drive both the PIC and the GM.The PIC program should be written in hex code (assembly) and programmed inside the PIC EEPROM, the MicroC compiler software is used to make PIC programming easy.After the PIC program had been written EasyPIC6 development in circuit programmer/debugger kit used to burn the program inside PIC.
The IC GM862-GPS is fully controlled by PIC via serial communication which means that the PIC send AT command (Attention) to GM and the GM respond with either the correct response or an error codes depends on the cases.AT command line is a string of characters sent from a DTE to the modem (DCE) while the modem is in a command state.A command line has a prefix, a body, and a terminator.Each command line (with the exception of the A/ command) must begin with the character sequence AT and must be terminated by a carriage return.Commands entered in upper case or lower case is accepted, but both the A and T must be of the same case, i.e., "AT or "at.The default terminator is the ENTER key <CR> character.Characters that precede the AT prefix are ignored.The command line interpretation begins upon receipt of the ENTER key character.Characters within the command line are parsed as commands with associated parameter values.Thebasic commands consist of single ASCII characters, or single characters proceeded by a prefixcharacter (e.g., "&" or "+"), followed by a decimal parameter.Missing decimal parameters areevaluated as 0 [16].
The vehicle side software is fragmented into several subroutines software as shown in Figure ( 8).
PDF created with pdfFactory Pro trial version www.pdffactory.comA-Vehicle Unit Main Program: the main program takes the responsibility to employee all subroutines together tocomplete the entire function, in addition the main program do all the necessary initialization configuration needed for PIC and GM.The PIC initialization includes identifying the direction of port B (,B1,B2,B3) to be inputs, (B4,B5,B6,B7) to be outputs, and enable the INT0 on (B0) as non makeable interrupt which is allocated for emergency SMS response see figure (3).Also the UART baud rate are set to (115200) b/s during the PIC initialization phase.The GM initialization includes three phases, phase one to ensure that the GM is available, the serial link is good, the SIM card is presence, and the modem is registered to a predefined mobile network.After phase one pass phase two (SMS configuration) will take effect which includes check were the modem received SMS crevice center number if not the number should be configured manually and to set the message format as text.Phase three is GPRS configuration which includes define GPRS context, setup quality of service , and configure TCP/IP stack figure (9) shows the flowchart of vehicle software main program.PDF created with pdfFactory Pro trial version www.pdffactory.comB-Download FileSubroutine:thissubroutine is used to download a certain file stored in FTP server this file contains information about the mode of operation (SMS, GPRS) and the time between successive GPS information sending, the download file flowchart is shown in figure (10).The ftp setting time out is the time counter after that count if the ftp server not responds the connection considered to be failed, the number (1000) equal one second.There are two types of ftp file, binary and ASCII, if the file downloaded is (.txt) the ftp type should be 0.

C-Upload File Subroutine:
This subroutine is the same as the previous subroutinedownloadfileexcept(downloadcontrol.txt)should replaced with (upload GPS.txt using the command AT#FTPPUT="GPS.txt"/r).The GPS.txt file contains all GPS information and status of door and engine as mentioned previously.

D-Read GPS Subroutine:
This subroutine is responsible of read GPS data from the GPS receiver serial connection.The GPS receiver is turned on by default when the modem powered on so as shown in figure (11) at first the GPS receiver should be checked on before try to read the information.

TESTING AND RESULTS
The PIC circuit was built as shown in Figure ( 13) 13) PIC Circuit.
The PIC programmed using microC compiler as shown in Figure ( 14), the output from the compiler is hex file and this file burned inside the PIC using easyPIC6 as shown in the Figure (15).The PIC circuit connected to the smartGM862-GPS board shown in Figure (16).The accuracy of GPS receiver is significant, because the tracking system is depends on one GPS receiver the longitude and latitude may deviates from the true value according to several causes such as frequency interference and how close the device from ground.The error also accord in marking the GPS information on Google map in meters.
The SMS mode is sometimes considered to be faster than GPRS mode since the modem have to open FTP connection before send any information while in SMS mode the modem send the information without the need to open connection but if the mobile network working in full traffic load the SMS mode may be not the perfect choice, in another hand the GPRS is cost effective compared to SMS mode which means that the user should always choose the PDF created with pdfFactory Pro trial version www.pdffactory.comright mode of operation depending on several environmental readings to balance the system bill.

CONCLUSIONS
The implemented tracking system GPS readings are not accurate so as the Google map therefore there is a deviation from reality about few meters due to the accuracy of the GPS receiver and the Google earth coordination falling errors .Mixing the two mode SMS and GPRS will contribute to increase system reliability and availability, hence, using the GPRS protocol will increase reliability in transmission between both units because its depend on the TCP protocol and as we know this protocol use an acknowledgment feedbackthat ask for retransmission if there is an error in the transmitted packet.The implemented system achieved the availability by using a control commend to be sent to the vehicle unit in order to switch the way of connection between GPRS and SMS even the control command can modify the interval between each transmission, so if GPRS not available or the Internet connection is not good the user can switch to SMS and vice versa.The system is compact and can easily installed in any vehicle without noticing it but the location of GPS and GSM antennas should be chosen carefully in order to achieve a good signal.The GM862-GPS is a good example of compacting more than one device in one IC.
Our research contribution was building a two way of connection between the monitoring unit and vehicle unit, the operator set many parameters and send it PDF created with pdfFactory Pro trial version www.pdffactory.comto the vehicle unit as control command before starting the system.Another contributionThat our tracking system has the ability to send SMS message to a specified mobile number ask for help and the message contains the current GPS coordination of the vehicle if the driver feel any danger, these contributions did not mentioned in all researches mentioned in related work section.Finally the implemented system can be considered as cost effective since its costdid not acceded 200$ comparing to such commercial systems even the cost can be reduced more if this system advertised by a manufacture companies.

FUTURE WORK
The system could be modified to a universal computerized system includes mobile system, antitheft system, Chasing system, etc…So the user can call phones and send SMS beside the other facilities on the device and it can be mounted in the vehicle by the vehicle manufactures.
The error in GPS reading can be decreased if we use a good accuracy GPS receiver or use more than one receiver to take the most accurate reading.
The vehicle unit can be modified by adding LCD and keypad to set the parameters directly to the device without the need to computer and RS232 interfacing.
and the second is by GPRS/GSM[3]-[7]-[10]-[11].he best way to display the GPS information on the W PDF created with pdfFactory Pro trial version www.pdffactory.commonitoring unit is by using Google earth map [4]-[6]-[7]-[8] for free which contribute to reduce the cost of project since the GIS maps is so expensive.Figure (1) shows The Proposed Block Diagram of Tracking System.

Figure ( 1 )
Figure (1) shows the proposed system to use both SMS and GPRS.
pdfFactory Pro trial version www.pdffactory.com

Figure ( 17
Figure (17) shows the marker placed on the Google map at Al-Karada Street in Baghdad city which represent the current GPS position of the tracked vehicle.The accuracy of GPS receiver is significant, because the tracking system is depends on one GPS receiver the longitude and latitude may deviates from the true value according to several causes such as frequency interference and how close the device from ground.The error also accord in marking the GPS information on Google map in meters.The SMS mode is sometimes considered to be faster than GPRS mode since the modem have to open FTP connection before send any information while in SMS mode the modem send the information without the need to open connection but if the mobile network working in full traffic load the SMS mode may be not the perfect choice, in another hand the GPRS is cost effective compared to SMS mode which means that the user should always choose the