Contents
I II Introduction Client Side 4 4
4 4 4 5 5 6 6 7 7 7 8 8 8 8 9 10 10 10 11
1 Hardware used 1.1 OLIMEX PIC32 Pinguino Micro . . . . . . . . . . . . . . . . . . 1.1.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Telit GM862-GPS Module . . . . . . . . . . . . . . . . . . . . . . 1.2.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 Support S1 for Telit GM862-GPS . . . . . . . . . . . . . . . . . . 1.3.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4 Neris GSM/DCS/PCS 900/1800/1900MHz GSM antenna with MMCX connector . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5 Active GPS antenna with MMCX connector . . . . . . . . . . . . 1.5.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.6 FLEX Multibus RS232 Module . . . . . . . . . . . . . . . . . . . 1.7 Hamlet XURS232 . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.7.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.8 MPLAB ICD 3 In-Circuit Debugger . . . . . . . . . . . . . . . . 1.8.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.9 ICSP 3-way Connector . . . . . . . . . . . . . . . . . . . . . . . . 1.9.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.10 Olimex LCD Nokia 3310 Module with UEXT Connector . . . . . 1.10.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2 Software used 12 2.1 Mplab IDE v8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 2.2 MPLAB C Compiler for PIC32 MCUs . . . . . . . . . . . . . . . 12 2.3 HTerm 0.81 beta . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3 Development details 3.1 Oscillator Setting . . . . . . . . . . . . . . . . . . 3.1.1 Primary Oscillator System Clock calculate 3.2 Timer Setting . . . . . . . . . . . . . . . . . . . . 3.2.1 Timer ISR . . . . . . . . . . . . . . . . . . 3.2.2 Timer Initialization . . . . . . . . . . . . 3.2.3 Timer Start . . . . . . . . . . . . . . . . . 3.2.4 Timer Stop . . . . . . . . . . . . . . . . . 3.2.5 Delay Aux Func . . . . . . . . . . . . . . 3.3 UART Setting . . . . . . . . . . . . . . . . . . . 3.3.1 UART ISR . . . . . . . . . . . . . . . . . 3.3.2 UART Baudrate Calculation . . . . . . . . . . with . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PLL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 13 13 14 14 14 15 15 15 16 16 16
3.4 3.5
3.3.3 UART Initialization . . . . . . . External Interrupt Setting . . . . . . . . 3.4.1 External Interrupt ISR . . . . . . 3.4.2 External Interrupt Initialization SPI Setting . . . . . . . . . . . . . . . . 3.5.1 SPI Initialization . . . . . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
17 18 18 18 18 18 19 20 21 21
4 Software Diagram 5 Hardware scheme 6 Prototype Board 7 Console Log Output Example
III
7.1
Server Side
7.2
GPS data acquisition and processing 7.1.1 GPS data acquisition . . . . . 7.1.2 GPS Data convert . . . . . . 7.1.3 Get GPS Data from le . . . Location on a map . . . . . . . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
23
24 24 24 25 26
Part I
Introduction
The intent of the project is to create a GPS tracking system able to view on map the location of a device (the subject of this project). The system works properly if the device is in an area covered by GSM (Global System for Mobile Communications), if the network supports GPRS (General Packet Radio Service) and if the GPS (Global Positioning System) can reach the device. The device consists of two parts: client side, the device that captures and sends its location, and the server side, the part that resides in the web server and provides the service of visualization on map.
Part II
Client Side
1
1.1
Hardware used
OLIMEX PIC32 Pinguino Micro1
1.1.1
Features
PIC32MX440F256H 80 Mhz microcontroller 256KB Flash 32KB RAM microSD card for data logging uext connector which allow many existing modules like RF, ZIGBEE, GSM, GPS to be connected two LEDs one generic button
1 http://www.olimex.com
reset button mini USB connector is used which is common and used in most cell phones, so you do not have to buy other cables all PIC ports available on 0.1" connectors miniICSP connector 0.05"
1.2
The new GM862-GPS module is at the cutting edge of the Telit product line. It combines superior performance in quad-band GSM/GPRS modem functionality with the latest 20-channel high sensitivity SiRFstarIII single-chip GPS receiver. The new GPS receiver features low power consumption with position resolution accuracy of less than 2.5m, SBAS (WAAS and EGNOS) as well as high sensitivity for indoor xes. These features combined with the available Python application development environment translate into a very cost eective and feature rich platform quite capable of becoming the total solution for the complete customer application. Additional features including jamming detection, integrated TCP/IP protocol stack, and Easy Scan oer unmatched benets to the application developer without adding cost.
1.2.1
Features
High sensitivity for indoor reception, up to -159dBm (with active antenna) Extremely fast TTFFs at low signal levels Hot starts < 3 seconds 200,000+ eective correlators
Supports 20-Channel GPS L1 1575.42 MHz Accuracy < 2.5m Extremely fast TTFFs at low signal levels GPS NMEA 0183 output format Date WGS-84 Dedicated GPS AT commands Low power consumption
1.3
1.3.1
Features
Pin connector strips in pitch 2.54 male 30-pin (2 x 15) Dimensions 57 mm x 51 mm - 11 mm maximum height Mounting holes 51mm x 45 mm
1.4
1.5
1.5.1
Features
Frequency: 1575.42 MHz Voltage: 3.0-5.0V waterproof magnetic base autopower when connect to GPS / PDA low power consumption
1.6
1.7
Hamlet XURS232
The USB-RS232 serial adapter is an external serial port for your computer to connect serial device like modem, ISDN TA, console port and other serial devices. The installation is true Plug&Play. It is also compatible with notebook computer without native serial port. Usb interface with computer. Bus powered.
1.7.1
Features
Standard Serial Rs232 Port 9 Pin USB 1.1 interface Compatible with notebook No IRQs required Full compliance with the USB specication revision 1.1
1.8
MPLAB ICD 3 In-Circuit Debugger System is Microchips most cost eective high-speed hardware debugger/programmer for Microchip Flash Digital Signal Controller (DSC) and microcontroller (MCU) devices. It debugs and programs PIC Flash microcontrollers and dsPIC DSCs with the powerful, yet easyto-use graphical user interface of MPLAB Integrated Development Environment (IDE). The MPLAB ICD 3 In-Circuit Debugger probe is connected to the design engineers PC using a high-speed USB 2.0 interface and is connected to the target with a connector compatible with the MPLAB ICD 2 or MPLAB REAL ICE systems (RJ-11). MPLAB ICD 3 supports all Emulation headers.
1.8.1
Features
Real-time Debugging - MPLAB ICD 3 In-Circuit Debugger is designed to support high-speed processors running at maximum speeds, allowing embedded engineers to debug applications on their own hardware in real time. Ruggedized Probe Interface - Protection circuitries are added to the probe drivers to guard the probe kit from power surges from the target. Vdd and Vpp voltage monitors protect against over-voltage conditions, and all lines have over-current protection. The unit can provide power to a target (up to 100 ma). Microchip Standard Connectivity - MPLAB ICD 3 In-Circuit Debugger employs a standard Microchip debugging connector (RJ-11). Portable, USB-powered and RoHS-Compliant - Housed in a small (3.7" x.8") and attractive enclosure, the MPLAB ICD 3 In-Circuit Debugger is powered by the USB port, so an external power adapter is not required. MPLAB ICD 3 In-Circuit Debugger is CE and RoHS-compliant. High Speed Programming - Fast programming allows both quick rmware reload for fast debugging and for in-circuit re-programming. Programming times are improved up to 15x over MPLAB ICD 2. Low Voltage Emulation - MPLAB ICD 3 supports target supply voltages from 2.0 to 5.5 volts. Test Interface Module - Included with every MPLAB ICD 3 is a test module to test I/O lines to conrm the unit is working properly. Ease of Maintenance and Feature Upgrade - Adding new device support and advanced features to MPLAB ICD 3 In-Circuit Debugger is as simple as installing later versions of the MPLAB IDE, downloadable free. MPLAB ICD 3 In-Circuit Debugger is eld upgradeable through a rmware download from MPLAB IDE.
Low Cost - MPLAB ICD 3 In-Circuit Debugger breaks the price barrier for a complete and advanced in-circuit debugger, oering new ways to interact with and debug applications at a fraction of the cost of traditional emulator systems. Powerful Debugging - High powered debugging with MPLAB IDE, supporting multiple breakpoints, stopwatch, source code le debugging in MPLABs editor for quick program modication/debug.
1.9
Allmost all Olimex boards are with simple 0.1" ICSP connector. Microchip decided to use phone jack cable for their tools and boards which is huge. The new mini boards where space is critical cant use both of these so we introduced the new ICSP-mini connector with 0.05" step. PIC-ICSP is 3-way connector which allow bridging between the development tools which use dierent connectors.
1.9.1
Features
3 way connector: OLIMEX-ICSP, OLIMEX-ICSP-mini and MICROCHIPRJ11 0.1" step ICSP connector 0.05" step ICSP-mini connector Phone jack connector
1.10
MOD-LCD3310 is development board with UEXT universal connector and can be attached and add LCD functionality to all other development boards with this connector. 10
This graphical LCD is Philips PCD8544 controller based LCD that can be interfaced via SPI connection. So this is ideal for interfacing with microcontrollers like PIC32MX LCD pinout is as follows: 1. VDD ==> Input voltage. 2. SCK ==> Serial Clock. 3. SDI ==> Serial Data Input. 4. D/C ==> Data/Command Input. 5. SCE ==> Chip Select. 6. GND ==> Ground. 7. VOUT ==> VLCD. 8. RES ==> Reset.
1.10.1
Features
NOKIA3310 B/W LCD, 84x48 Wlack/White UEXT to connect to host microcontroller (standard connector on our ARM development boards) 0.1" step connectors for plug-in on top of other PCB Dimensions: 39x35 mm (1.53x1.38")
11
2
2.1
Software used
Mplab IDE v8
MPLAB Integrated Development Environment (IDE) is a free, integrated toolset for the development of embedded applications employing Microchips PIC and dsPIC microcontrollers. MPLAB IDE runs as a 32-bit application on MS Windows, is easy to use and includes a host of free software components for fast application development and super-charged debugging. MPLAB IDE also serves as a single, unied graphical user interface for additional Microchip and third party software and hardware development tools. Moving between tools is a snap, and upgrading from the free software simulator to hardware debug and programming tools is done in a ash because MPLAB IDE has the same user interface for all tools.
2.2
The MPLAB C Compiler for PIC32 is a full-featured ANSI compliant C compiler for Microchips PIC32 family of 32-bit microcontrollers.
2.3
12
3
3.1
Development details
Oscillator Setting
External primary oscillator (POSC- Primary OSCillator) is designed for highspeed operation with accurate (quartz-based) operation. Up to 20 MHz crystals can be connected directly to the OSCI, OSCO pins (8 Mhz crystal is recommended) while two gain settings are available: XT for typical quartzes below 10 MHz and HS for quartzes at or above the 10 MHz frequency. Its also possible enable a PLL (Phase-Locked Loop) circuit that allows to multiply by a costant the frequency of the oscillator connected to the OSCI, OSCO pins (if we use this option we need to allow it time to stabilize or lock before we attempt to execute code and synchronize with it). 3.1.1 Primary Oscillator System Clock calculate with PLL
4 5 6 7
x t a l , t i c k s = 8/2 20 /1 = 80MHz c o n f i g FPLLIDIV=DIV_2 , FPLLMUL=MUL_20, FPLLODIV=DIV_1 80/8 =10MHz, w_dog d i s a b l e d , CP d i s a b l e d , b o o t p r o t e c t d i s a b l e d c o n f i g FPBDIV=DIV_8 , FWDTEN =OFF, CP=OFF, BWP =OFF
When the PLL (Phase-Locked Loop) circuit is active, you should wait until it arrives at steady state before continuing program execution. For this reason it is recommended to put at the beginning of the main, these instructions:
1 2
3.2
3.2.1
Timer Setting
Timer ISR
An interrupt handler, also known as an interrupt service routine (ISR), is a callback subroutine in microcontroller rmware, operating system or device driver whose execution is triggered by the reception of an interrupt. Interrupt handlers have a multitude of functions, which vary based on the reason the interrupt was generated and the speed at which the interrupt handler completes its task.
1 2 3 4
void __ISR(_TIMER_1_VECTOR, i p l 7 ) Timer1Handler ( void ) { delay_spended_tmr1 ; // used by Delay Aux Func I F S 0 b i t s . T1IF = 0b0 ; // r e s e t i n t e r r u p t f l a g } 3.2.2 Timer Initialization
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
void init16bitTIMER ( unsigned short int P B c l o c k P r e s c a l e r , unsigned short int p e r i o d , unsigned short int p r i o r i t y , unsigned short int s u b p r i o r i t y ) { T1CON = 0 ; // r e s e t c o n t r o l r e g i s t e r T1CONbits .ON = 0b0 ; // d i s a b l e Timer T1CONbits . TCS = 0b0 ; // i n t e r n a l p e r i p h e r a l c l o c k r e f e r e n c e i f ( P B c l o c k P r e s c a l e r ==1) T1CONbits .TCKPS = 0 b00 ; i f ( P B c l o c k P r e s c a l e r ==8) T1CONbits .TCKPS = 0 b01 ; i f ( P B c l o c k P r e s c a l e r ==64) T1CONbits .TCKPS = 0 b10 ; i f ( P B c l o c k P r e s c a l e r ==256) T1CONbits .TCKPS = 0 b11 ; TMR1 = 0 x0000 ; // Timer i n i t i a l v a l u e 14
18 19 20 21 22 23
= = = =
3.2.3
1 2 3
1 2 3
// d i s a b l e Timer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
void delay_us ( unsigned short int TIMERindex , double PBclock , double P B c l o c k P r e s c a l e r , unsigned short int p r i o r i t y , unsigned short int s u b p r i o r i t y , unsigned int us ) { delay_spended_tmr1 = 0 ; double c l k = 0 ; c l k = 1 / ( PBclock / P B c l o c k P r e s c a l e r ) ; int p e r i o d = us / ( c l k 1 0 1 0 1 0 1 0 1 0 1 0 ) ; while ( p e r i o d >65535) { delay_spended_tmr1+=10; period = period /10; } init16bitTIMER ( P B c l o c k P r e s c a l e r , p e r i o d , p r i o r i t y , s u b p r i o r i t y ) ; startTIMER ( ) ; while ( delay_spended_tmr1 != 0 ) ; stopTIMER ( ) ;
15
Algorithm 1 Baudrate Calculation (ex. 9600) UxBRG = ((FPB/Desired Baud Rate)/16) - 1 = = ((4000000/9600)/16) - 1 UxBRG = [25.042] = 25 Calculated Baud Rate = 4000000/(16 (25 + 1)) = 9615 Error = (Calculated Baud Rate - Desired Baud Rate) Desired Baud Rate = (9615 - 9600)/9600 = = 0.16% [good range = +-2%]
3.3
3.3.1
UART Setting
UART ISR
This Interrupt Service Routine (ISR) is invoked every time a character is received by the UART if this interface is congured in rx interruption mode.
1 2 3 4 5 6
void __ISR(_UART1_VECTOR, i p l 7 ) UART1InterruptHandler ( void ) { // . . . UART1_callback_interrupt_function ( ) ; // . . . I F S 0 b i t s . U1RXIF = 0 ; // c l e a r i n t e r r u p t f l a g } 3.3.2 UART Baudrate Calculation
The algorithm for calculating the value is the following (in this example the desired baudrate is 9600) and it is implemented by the following function:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// f p b = f r e q u e n c y p e r i p h e r a l bus [ Hz ] short int b a u d r a t e C a l c ( double fpb , int b a u d r at e ) { double c a l B a u d r a t e ; short int e r r o r 1 ; short int e r r o r 2 ; short int uxbrg1 ; short int uxbrg2 ; double uxbrg = ( ( fpb / b a u d r a t e )/16) 1; uxbrg1 = ( int ) uxbrg ; uxbrg2 = ( int ) ( uxbrg +1); c a l B a u d r a t e = fpb / ( 1 6 ( uxbrg1 + 1 ) ) ; error1 = calBaudrate b a u d r at e ; c a l B a u d r a t e = fpb / ( 1 6 ( uxbrg2 + 1 ) ) ; error2 = calBaudrate b a u d r at e ; i f ( e r r o r 1 >e r r o r 2 ) return uxbrg2 ; 16
17 18 19
3.3.3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
UART Initialization
void initUART (UARTid id , double fpb , short int baudrate , short int rx_int_en , short int i n t _ p r i o r i t y , short int i n t _ s u b p r i o r i t y ) { i f ( i d == 1 ) { //U1BRG = b a u d r a t e ; U1BRG = b a u d r a t e C a l c ( fpb , b au d r a t e ) ; U1STA = 0 ; i f ( rx_int_en == 1 ) { I P C 6 b i t s . U1IP = i n t _ p r i o r i t y ; // i n t e r r u p t // p r i o r i t y l e v e l I P C 6 b i t s . U1IS = i n t _ s u b p r i o r i t y ; // s u b p r i o r i t y l e v e l I E C 0 b i t s . U1RXIE = 1 ; // e n a b l e r x i n t e r r u p t } U1MODE = 0 b1000000000000000 ; // Enable UART f o r 8 b i t d a t a // no p a r i t y // 1 Stop b i t U1STASET = 0 b0001010000000000 ; // Enable Transmit and R e c e i v e // I n t e r r u p t when a // c h a r a c t e r i s r e c e i v e d } i f ( i d == 2 ) { U2BRG = b a u d r a t e C a l c ( fpb , b au d r a t e ) ; U2STA = 0 ; i f ( rx_int_en == 1 ) { I P C 8 b i t s . U2IP = i n t _ p r i o r i t y ; // l o w e r i n t e r r u p t // p r i o r i t y l e v e l I P C 8 b i t s . U2IS = i n t _ s u b p r i o r i t y ; // s u b p r i o r i t y l e v e l I E C 1 b i t s . U2RXIE = 1 ; // e n a b l e r x i n t e r r u p t } U2MODE = 0 b1000000000000000 ; // Enable UART f o r 8 b i t d a t a // no p a r i t y // 1 Stop b i t U2STASET = 0 b0001010000000000 ; // Enable Transmit and R e c e i v e // I n t e r r u p t when a // c h a r a c t e r i s r e c e i v e d } 17
40
3.4
3.4.1
1 2 3 4
void __ISR(_EXTERNAL_0_VECTOR, i p l 7 ) __INT0interrupt ( void ) { // . . . I F S 0 b i t s . INT0IF = 0b0 ; // r e s e t i n t e r r u p t f l a g } 3.4.2 External Interrupt Initialization INT0 pin intialization. For the other pin the initialization mode is similar.
1 2 3 4 5 6 7 8 9 10 11 12 13
//mode = 0 f o r F a l l i n g Edge [ 1 t o 0 ] // 1 f o r R i s i n g Edge [ 0 t o 1 ] // i n t _ p r i o r i t y = i n t e r r u p t p r i o r i t y (0 max , 7 min ) void s e t E x t e r n a l I n t e r r u p t ( unsigned char mode , unsigned char i n t _ p r i o r i t y ) { I E C 0 b i t s . INT0IE = 0b0 ; // d i s a b l e i n t e r r u p t TRISDbits . TRISD0 = 0b1 ; // t r i s t a t e p o r t t o i n p u t INTCONbits . INT0EP = mode ; // f a l l i n g e d g e [ 1 t o 0 ] I F S 0 b i t s . INT0IF = 0b0 ; I P C 0 b i t s . INT0IP = i n t _ p r i o r i t y ; // S e t E x t e r n a l I n t e r r u p t 0 P r i o r i t y t o 4 I E C 0 b i t s . INT0IE = 0b1 ; }
3.5
3.5.1
1 2 3 4 5 6 7 8 9 10 11 12 13 14
SPI Setting
SPI Initialization
The SPI interface is used for communication with the LCD Display. void S p i I n i t D e v i c e ( int chn , int i s M a s t e r , int frmEn , int frmMaster ) { unsigned int c o n f i g = SPI_CON_CKP | SPI_CON_ON; // SPI c o n f i g u r a t i o n word i f ( isMaster ) { c o n f i g |=SPI_CON_MSTEN; } i f ( frmEn ) { c o n f i g |=SPI_CON_FRMEN; i f ( ! frmMaster ) { c o n f i g |=SPI_CON_FRMSYNC; } } SpiChnOpen ( chn , c o n f i g , 4 ) ; // d i v i d e f p b by 4 , c o n f i g u r e t h e I /O p o r t s . // Not u s i n g SS i n t h i s example }
18
Software Diagram
19
Hardware scheme
20
Prototype Board
The following listing is a typical example of output from the log console normal operating functions:
1 2 3 4 5 6 7 8 9 10 11 12
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
OK AT+ CMEE=1 OK AT+ CGDCONT=1," IP " , " i n t e r n e t . wind " , " 0 . 0 . 0 . 0 " , 0 , 0 OK AT#USERID="" OK AT# PASSW="" OK AT#GPRS? #GPRS: 0 OK AT#GPRS=1 +IP : 1 5 1 . 3 1 . 2 1 1 . 5 OK AT$GPSR=2 OK AT$GPSACP $GPSACP : 1 9 2 3 1 0 . 8 7 9 , , , , , 0 , , , , 1 1 0 1 1 2 , 0 0 OK AT$GPSACP $GPSACP : 1 9 2 3 1 6 . 8 7 9 , , , , , 0 , , , , 1 1 0 1 1 2 , 0 0 OK AT$GPSACP $GPSACP : 1 9 2 3 2 2 . 8 8 0 , , , , , 0 , , , , 1 1 0 1 1 2 , 0 0 OK AT$GPSACP $GPSACP : 1 9 2 3 2 8 . 8 8 0 , , , , , 0 , , , , 1 1 0 1 1 2 , 0 0 OK AT$GPSACP $GPSACP : 1 9 2 3 3 4 . 8 7 9 , 4 3 4 3 . 3 5 5 5N, 0 1 0 2 4 . 6 1 3 0 E , 3 . 0 , 7 . 5 , 3 , 86.46 ,0.14 ,0.07 ,110112 ,04 OK
22
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
AT#SKTD=0 ,80 ,"www. a g o s t i n o p o l i z z a n o . i n f o " , 0 , 0 CONNECT GET /home/ s i t e s / a l l / aux /gm862_2/ data . php? c o o r d =+4343.3555 ,+01024.6130 HTTP/ 1 . 1 Host : www. a g o s t i n o p o l i z z a n o . i n f o Connection : c l o s e HTTP/ 1 . 1 200 OK Date : Wed, 11 Jan 2012 1 9 : 2 3 : 5 3 GMT S e r v e r : Apache / 2 . 2 Content Length : 0 Connection : c l o s e Content Type : t e x t / html NO CARRIER
AT$GPSACP $GPSACP : 1 9 2 4 0 5 . 8 7 9 , 4 3 4 3 . 3 6 4 8N, 0 1 0 2 4 . 6 1 3 1 E , 1 . 4 , 7 . 2 , 3 , 103.14 ,0.18 ,0.09 ,110112 ,06 OK AT#SKTD=0 ,80 ,"www. a g o s t i n o p o l i z z a n o . i n f o " , 0 , 0 CONNECT GET /home/ s i t e s / a l l / aux /gm862_2/ data . php? 76 c o o r d =+4343.3648 ,+01024.6131 77 HTTP/ 1 . 1 Host : www. a g o s t i n o p o l i z z a n o . i n f o Connection : c l o s e
78 79 80 81 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
HTTP/ 1 . 1 200 OK Date : Wed, 11 Jan 2012 1 9 : 2 4 : 2 7 GMT S e r v e r : Apache / 2 . 2 Content Length : 0 Connection : c l o s e Content Type : t e x t / html 82 NO CARRIER AT$GPSACP $GPSACP : 1 9 2 4 3 9 . 0 0 0 , 4 3 4 3 . 3 6 7 8N, 0 1 0 2 4 . 6 1 5 6 E , 1 . 0 , 4 . 8 , 3 , 131.65 ,0.28 ,0.15 ,110112 ,07 OK AT#SKTD=0 ,80 ,"www. a g o s t i n o p o l i z z a n o . i n f o " , 0 , 0 CONNECT GET /home/ s i t e s / a l l / aux /gm862_2/ data . php? c o o r d =+4343.3678 ,+01024.6156 HTTP/ 1 . 1 Host : www. a g o s t i n o p o l i z z a n o . i n f o Connection : c l o s e HTTP/ 1 . 1 200 OK Date : Wed, 11 Jan 2012 1 9 : 2 4 : 5 0 GMT S e r v e r : Apache / 2 . 2 Content Length : 0 Connection : c l o s e Content Type : t e x t / html NO CARRIER
23
Part III
Server Side
We will refer to the techniques and languages used to develop server-side application that processes data received from the Telit GM862-GPS to show the location on the map.
7.1
7.1.1
On the web server has been implemented a script PHP2 (Hypertext Preprocessor) that is periodically invoked by the GPS module to sending data via HTTP requests and GET method. The following script converts acquire GPS data and writes the data in a le:
1 2 3 4 5 6 7 8 9 10
<?php $ c o o r d = $_GET[ c o o r d ] ; $ g p s _ d a t a _ f i l e = " . / gps_data . t x t " ; // open f i l e i n w r i t e mode w i t h p o i n t e r a l w a y s a t t h e b e g i n n i n g o f t h e f i l e $ f h = fopen ( $ g p s _ d a t a _ f i l e , w+ ) ; f w r i t e ( $fh , $ c o o r d ) ; fclose ( $fh ) ; ?> 7.1.2 GPS Data convert
The GPS data producted by Telit module are The GPS data producted by the Telit module products are in the form: <latitude>: ddmm.mmmmN/S (referred to GGA sentence) Values: dd (degrees) 00 to 90 mm.mmmm (minutes) 00,0000 to 59.9999 N/S: North / South <longitude>: dddmm.mmmmE/W (referred to GGA sentence) Values: ddd (degrees) 00 to 180
2 PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages. It is among one of the rst developed server-side scripting languages that is embedded into a HTML source document, rather than calling an external le to process data. Ultimately, the code is interpreted by a web server with a PHP processor module which generates the resulting web page.
24
mm.mmmm (minutes) 00,0000 to 59.9999 E/W: East / West a function performs a conversion to decimal format consistent with the Google Maps JavaScript API V3 : +/-ddd.ddddd The following script converts GPS data from DDMM.mmmm format to DD.dddddd format:
1 2 3 4 5 6 7 8 9 10 11 12
var mydegrees ; f u n c t i o n convertdm2d ( d e g r e e s , minutes ) { i f ( ( d e g r e e s == "" ) | | ( minutes == "" ) ) { mydegrees = " " ; return mydegrees ; } else { mydegrees = d e g r e e s 1 . 0 + ( minutes / 6 0 . 0 ) ; mydegrees = Math . round ( mydegrees 1 0 0 0 0 0 0 . 0 ) / 1 0 0 0 0 0 0 . 0 ; return mydegrees ; } } 7.1.3 Get GPS Data from le
The following script get the GPS data from le and updata elds of the main page that display the numerical data (input type):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
$ f i l e _ e x i s t = f i l e _ e x i s t s ( " . / gps_data . t x t " ) ; i f ( $ f i l e _ e x i s t==true ) { $aux = "1" ; $ g p s _ d a t a _ f i l e = " . / gps_data . t x t " ; $ f h = fopen ( $ g p s _ d a t a _ f i l e , r ) ; $data = f g e t s ( $ f h ) ; $ l a t = substr ( $data , 0 , strpos ( $data , " , " ) ) ; $DDlat = substr ( $ l a t , 0 , 3 ) ; //DD $MMmmlat = substr ( $data , 3 , strpos ( $data , " , " ) 3); //MM.mm $ l o n g = substr ( $data , strpos ( $data , " , ")+1 , s t r l e n ( $data ) 1); $DDlong = substr ( $long , 0 , 4 ) ; //DDD $MMmmlong = substr ( $long , 4 , s t r l e n ( $ l o n g ) 1 3); //MM.mm fclose ( $fh ) ; echo "<h3> Coord DDMM.mmmm Format</h3>" ; echo "<i n p u t name=\"DDlat \" i d =\"DDlat \" v a l u e =\"" . $DDlat . " \" r e a d o n l y =\" r e a d o n l y \" s t y l e =\" t e x t a l i g n : c e n t e r ; \ " />" ; echo "<i n p u t name=\"MMmmlat\" i d =\"MMmmlat\" v a l u e =\"" . $MMmmlat . " \" r e a d o n l y =\" r e a d o n l y \" s t y l e =\" t e x t a l i g n : c e n t e r ; \ " />" ; 25
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
echo "<br />" ; echo "<i n p u t name=\"DDlong \" i d =\"DDlong \" v a l u e =\"" . $DDlong . " \" r e a d o n l y =\" r e a d o n l y \" s t y l e =\" t e x t a l i g n : c e n t e r ; \ " />" ; echo "<i n p u t name=\"MMmmlong\" i d =\"MMmmlong\" v a l u e =\"" . $MMmmlong . " \" r e a d o n l y =\" r e a d o n l y \" s t y l e =\" t e x t a l i g n : c e n t e r ; \ " />" ; } else { $DDlat = "0" ; $MMmmlat = "0" ; $DDlong = "0" ; $MMmmlong = "0" ; echo "<h3> Coord : </h3>" ; echo "<i n p u t name=\"DDlat \" i d =\" l a t \" v a l u e =\"" . $DDlat . " \" r e a d o n l y =\" r e a d o n l y \" s t y l e =\" t e x t a l i g n : c e n t e r ; \ " />" ; echo "<i n p u t name=\"MMmmlat\" i d =\" l o n g \" v a l u e =\"" . $MMmmlat . " \" r e a d o n l y =\" r e a d o n l y \" s t y l e =\" t e x t a l i g n : c e n t e r ; \ " />" ; echo "<br />" ; echo "<i n p u t name=\"DDlong \" i d =\" l a t \" v a l u e =\"" . $DDlong . " \" r e a d o n l y =\" r e a d o n l y \" s t y l e =\" t e x t a l i g n : c e n t e r ; \ " />" ; echo "<i n p u t name=\"MMmmlong\" i d =\" l o n g \" v a l u e =\"" . $MMmmlong . " \" r e a d o n l y =\" r e a d o n l y \" s t y l e =\" t e x t a l i g n : c e n t e r ; \ " />" ; }
7.2
Location on a map
To locate the position of the device we have used the map of Google Maps and Google Maps JavaScript API V3. The device is shown by a blue circular marker. To update the position of the marker was used AJAX (Asynchronous JavaScript and XML), which is a development technique for creating interactive web applications (Rich Internet Application). The development of HTML applications with AJAX is based on an exchange of data between web browsers and servers backgrounds, which allows dynamic update of a web page without reloading explicitly by the user. AJAX is asynchronous in the sense that the extra data is requested from your server and loaded in the background without interfering with the behavior of the existing page. Normally called functions are written in JavaScript.
26
27