Documente Academic
Documente Profesional
Documente Cultură
1.1
1.2
void GPSLatitudeShow(Data * val) { char i=0; char buffer[20]; int ipart,fpart; ipart=val->latlong.m/10000; fpart=val->latlong.m%10000; sprintf(buffer,"%2d*%2d.%3d'",val>latlong.d,ipart,fpart); while(buffer[i] != 0) { if(buffer[i]==32) buffer[i]=48; i++; } }
1.3
void GPSLongitudeShow(Data * val) { char i=0; char buffer[20]; int ipart,fpart; ipart=val->latlong.m/10000; fpart=val->latlong.m%10000; sprintf(buffer,"%3d*%2d.%3d'",val>latlong.d,ipart,fpart); while(buffer[i] != 0) {
65
66
1.4
format is ddmm.mmmm or dddmm.mmmm * depending if it's latitude or longitude (d=degrees, m=minutes). We store the * minutes in fixed-point. */ char GPSLatLongCnv(char * dest,char * buffer) { GPSField * d; char i=0; long n=100000; d = (GPSField *) dest; if(d->length==9) d->data.latlong.d=(buffer[i++]-48)*10 + (buffer[i++] - 48); else d->data.latlong.d=(buffer[i++]-48)*100 + (buffer[i++] - 48)*10 + (buffer[i++] - 48); d->data.latlong.m=0; while(i < d->length) { if(buffer[i]=='.') { i++; continue; } d->data.latlong.m+=(buffer[i++] - 48)*n; n=n/10; } return 0; } interrupt [USART1_RXC] void uart_rec(void) { state -1 char return2start=0; serprintchar(UDR1);
67
switch (gps_rx_state) { case -1: if (gps_rx_buffer_len==3 && gps_rx_buffer[0]=='$' && gps_rx_buffer[1]=='G' && gps_rx_buffer[2]=='P') { gps_rx_buffer_len=0; gps_rx_state=0; } else if (gps_rx_buffer_len >= 3) return2start=1; break; case 0: // Figure out what type of output string this is if(gps_rx_buffer_len==4 && gps_rx_buffer[0]=='R' && gps_rx_buffer[1]=='M' && gps_rx_buffer[2]=='C' && gps_rx_buffer[3]==',') { gps_rx_state=1; gps_rx_buffer_len=0; } else if(gps_rx_buffer_len >= 4) return2start=1; break; default: if(gps_rx_state > 11) { return2start=1; break; } if((gps_fields[gps_rx_state1].length==gps_rx_buffer_len) && (UDR1==',')) { gps_fields[gps_rx_state1].convert(&(gps_fields[gps_rx_state-1]), gps_rx_buffer); gps_fields[gps_rx_state1].gotonce=1; gps_fields[gps_rx_state-1].dirty=1; gps_rx_state++; gps_rx_buffer_len=0; return;
68
2. Program GSM
2.1
Ambil Nomer void get_number(void) { i_read_sms = 3; for(j_read_sms=0;j_read_sms<i_read_sms;j_read_s ms++) { tempchar_read_sms = *thepdu_read_sms++; *theptr_read_sms++ = *thepdu_read_sms++; *theptr_read_sms++ = tempchar_read_sms; } *theptr_read_sms = 0; }
2.2
Read SMS unsigned char read_sms(unsigned char the_sms_counter) { unsigned char vp_length; char *ptr; unsigned short end; sprintf(gsm_command,"at+cmgr=%u",the_sms_counte r); if(!send_command(gsm_command,1,10,0)) return(0); ptr = strchr(temp_str300,' '); ptr++; ptr = strchr(ptr,0x0D); ptr++; ptr = strchr(ptr,0x0A); ptr++; end = strpos(ptr,0x0D);
2.3
69
3. UART INIT // USART1 initialization // Communication Parameters: 8 Data, 1 Stop, No Parity // USART1 Receiver: On // USART1 Transmitter: On // USART1 Mode: Asynchronous // USART1 Baud Rate: 9600 UCSR1A=0x00; UCSR1B=0x98; UCSR1C=0x06; UBRR1H=0x00; UBRR1L=0x67; // USART0 initialization // Communication Parameters: 8 Data, 1 Stop, No Parity // USART0 Receiver: On // USART0 Transmitter: On // USART0 Mode: Asynchronous // USART0 Baud Rate: 19200 UCSR0A=0x00; UCSR0B=0x18; UCSR0C=0x06; UBRR0H=0x00; UBRR0L=0x33;
70
71
7. Antena GPS
8. Antena GSM
72
9. NMEA Output Messages Message GGA GLL GSA GSV MSS RMC VTG ZDA 150 151 152 154 Description Time, position and fix type data Latitude, longitude, UTC time of position fix and status GPS receiver operating mode, satellites used in the position solution, and DOP values Number of GPS satellites in view satellite ID numbers, elevation, azimuth, & SNR values Signal-to-noise ratio, signal strength, frequency, and bit rate from a radio-beacon receiver Time, date, position, course and speed data Course and speed information relative to the ground PPS timing message (synchronized to PPS) OK to send message GPS Data and Extended Ephemeris Mask Extended Ephemeris Integrity Extended Ephemeris ACK
9.1 GGA Data Format Name Message ID UTC Time Latitude N/S Indicator Longitude E/W Indicator Position Fix Indicator Sattelite Used HDOP Example $GPGAA 002153.000 3342.6618 N 11751.3858 W 1 10 1.2 Unit Description GGA Protocol Header hhmmss.sss ddmm.mmmm N=North, S=South dddmm.mmm E=East, W=West See table Position Fix Indicator Rang 0 to 12 Horizontal Dilution of Precision
Units M Age of Diff. Corr. Diff. Ref. Station 0000 ID Checksum *5E <CR> <LF>
Meters Meters Meters Geoid-to-ellipsoid separation. Ellipsoid altitude = MSL Altitude + Geoid Separation Meters Sec. Null fields when DGPS is not used
73
Table Position Fix Indicator Value 0 1 2 3-5 6 Description Fix not available or invalid GPS SPS Mode, fix valid Differential GPS, SPS Mode, fix valid Not supported Dead Reckoning Mode, fix valid
9.2 GLL Data Format Name Message ID Latitude N/S Indicator Longitude E/W Indicator UTC Time Status Mode Checksum <CR> <LF> Example Unit Description $GPGLL GLL Protocol Header 3342.6618 ddmm.mmmm N N=North, S=South 11751.3858 dddmm.mmm W E=East, W=West 002153.000 hhmmss.sss A A=data valid or V=data not valid A A=Autonomous, D=DGPS, E=DR (Only present in NMEA v3.00) *41 End of message termination
9.3 GSA Data Format Name Message ID Mode 1 Mode 1 Satellite Used1 Satellite Used1 Satellite Used1 PDOP HDOP VDOP Checksum <CR> <LF> Example $GPGSA A 3 07 02 Unit Description GSA Protocol Header See Tabel Mode 1 See Tabel Mode 2 SV on Chanel 1 SV on Chanel 2 SV on Chanel 12 Position Dilution of Precision Horizontal Dilution of Precision Vertical Dilution of Precision End of message termination
74
Mode 1 Value M A Mode 2 Value 1 2 3 Description Fix not available 2D (<4 SVs used) 3D (>3 SVs used) Description Manualforced to operate in 2D or 3D mode 2D Automaticallowed to automatically switch 2D/3D
9.4 GSV Data Format Name Message ID Number Of Messages Messages Number Satellite in View Satellite ID Elevation Azimuth SNR (C/N0) Satellite ID Elevation Azimuth SNR (C/N0) Checksum <CR> <LF> Example $GPGSV 2 1 07 07 79 048 42 Unit Description GSV Protocol Header Range 1 to 3 Range 1 to 3
27 27 138 42 *71
Chanel 1 (Rang 1 to 32) Chanel 1 (Maksimum 90) Chanel 1 (True, Range 0 to 359) Range 0 to 99, null when not tracking Chanel 4 (Rang 1 to 32) Chanel 4 (Maksimum 90) Chanel 4 (True, Range 0 to 359) Range 0 to 99, null when not tracking End of message termination
9.5 MSS Data Format Name Message ID Signal Strength Signal to noise ratio Beacon Frequency Example $GPMSS 55 27 318.0 Unit dB dB kHz Description mss Protocol Header SS of tracked frequency SNR of tracked frequency Currently tracked frequency
75
Beacon Bit Rate 100 Channel 1 Number Checksum <CR> <LF> *57
Bit per second The channel of the beacon being used if a multi-channel beacon receiver is used End of message termination
9.6 RMC Data Format Name Message ID UTC Time Status Latitude N/S Indicator Longitude E/W Indicator Speed Over Ground Course Over Ground Date Magnetic Variation East/West Indicator Mode Checksum <CR> <LF> Example $GPRMC 002153.000 A Unit Description RMC Protocol Header hhmmss.sss A=data valid or V=data not valid ddmm.mmmm N=North, S=South dddmm.mmm E=East, W=West
True ddmmyy E=East, W=West E=East A=Autonomous, D=DGPS, E=DR End of message termination
9.7 VTG Data Format Name Message ID Course Reference Course Reference Speed Unit Speed Unit Mode Example $GPVTG 309.62 T M 0.13 N 0.2 K A Description VTG Protocol Header degres Measured Heading True Degres Measured Heading Magnetic Knots Measured Horizontal Speed knots Km/hr Measured Horizontal Speed Kilometer per hour A=Autonomous, D=DGPS, Unit
76
9.8 ZDA Data Format Name Message ID UTC Time Example $GPZDA 181813 Description ZDA Protocol Header hhmmss The UTC time units are as follows: hh = UTC hours from 00 to 23 mm = UTC minutes from 00 to 59 ss = UTC seconds from 00 to 59 Either using valid IONO/UTC or estimated from default leap seconds 01 to 31 01 to 12 Hour Minute Offset from UTC (set to 00 Offset from UTC (set to 00 Unit
Day Month Year Local Zone Hour Local Zone Minute Checksum <CR> <LF> 9.9
14 10 2009 00 00 *4F
150 OkToSend Name Message ID OkToSend Checksum <CR> <LF> Example $PSRF150 1 *3F Unit Description PSRF150 protocol header 1=OK to send, 0=not OK to send End of message termination
9.10 151 GPS Data and Extended Ephemeris Mask Name Message ID GPS_TIME _VALID_ FLAG Example Unit $PSRF151 0, 1, 2, or N/A 3 Description PSRF151 protocol header LSB bit 0 = 1, GPS week is valid LSB bit 0 = 0, GPS week is not valid LSB bit 1 = 1, GPS TOW is valid LSB bit 1 = 0, GPS TOW is not valid week Extended week number (variable number length field)
GPS Week
1324
77
<CR> <LF>
GPS Time Of Week (variable length field) Mask to indicate the satellites for which new ephemeris is needed. Eight characters preceded by the following characters, 0x, are used to show this 32-bit mask (in hex). The leading bit is for satellite PRN 32, and the last bit is for satellite PRN 1. End of message termination
9.11 152 Extended Ephemeris Integrity Name Message ID SAT_POS_ VALIDITY _FLAG Example Unit Description $PSRF152 PSRF152 protocol header 0x100000 N/A This is a 10 character field 41 representing the debug flag in hex with lead-in 0x. (e.g., 0x00F00000). 1 = invalid position found, 0 = valid position. SVID 1 validity flag will be in LSB, and subsequent bits have validity flags for SVIDs in increasing order up to SVID 32 whose validity flag will be in MSB. SAT_CLK_ 0x100000 N/A This is a 10 character field VALIDITY 41 representing the debug flag in hex _FLAG with lead-in 0x. (e.g., 0x00F00000). 1 = invalid clock found, 0 = valid clock. SVID 1 validity flag is in LSB and subsequent bits will have validity flags for SVIDs in increasing order up to SVID 32 whose validity flag will be in MSB. SAT_HEAL 0x100000 N/A This is a 10 character field TH_FLAG 41 representing the debug flag in hex with lead-in 0x. (e.g., 0x00F00000). 1 = unhealthy satellite, 0 = healthy satellite. SVID 1 health flag is in the LSB and subsequent bits will have health flags
78
for SVIDs in increasing order up to SVID 32 whose validity flag will be in MSB. <CR> <LF> End of message termination
9.12 154 Extended Ephemeris ACK Name Message ID ACK ID <CR> <LF> Example Unit $PSRF154 110 N/A Description PSRF154 protocol header Message ID of the message to ACK (107, 108, 110) End of message termination