GPS positioning and communication protocol analysis

1 Introduction

The picture above shows the GPS positioning module of a certain company. I share with you the knowledge I have learned in the process of using it for GPS positioning.

The main parameters are as follows

◆Half-duplex UART (3.3V_TTL level)/RS232/IIC/CAN interface output, faster application;

◆Adopt KDS 0.5PPM high-precision TCXO;

◆Rich data output rate: 115200bps (default) [optional: 9600/38400];

◆Output sentence: NMEA 0183 V3.0/UBX protocol;

◆Support adjustable data refresh rate: 1Hz-10Hz;

◆Independent research and development and design of the antenna vibrator, to ensure that the phase center coincides with the geometric center, and minimize the impact of the antenna on measurement errors; ◆Support optional A-GPS service, geomagnetic sensor, pressure sensor;

◆GPS, BD, GLONASS mixed engine optional;

◆Manufactured with lead-free technology and complies with RoHS standards.

It supports two protocols:

NMEA 0183 common protocol and UBX communication protocol

 

2. NMEA 0183 protocol

NMEA 0183 is a standard format for marine electronics developed by the National Marine Electronics Association. At present, it has become a unified RTCM (Radio Technical Commission for Maritime services) standard protocol for GPS navigation equipment. The NMEA0183 protocol uses ASCII codes to transmit GPS positioning information, which we call frames. The frame format is as follows:

$aaccc,ddd,ddd,„,ddd*hh(CR)(LF)

1. "$": frame command start bit

2. "aaccc": address field, the first two digits are the identifier (aa), and the last three digits are the statement name (ccc)

3. "ddd,ddd": data content

4. "*": checksum prefix (can also be used as a sign of the end of statement data)

5. "hh": checksum (checksum), the checksum of all ASCII codes between $ and * (each byte is XORed, and after the checksum is obtained, it is converted to ASCII in hexadecimal format character)

6. "(CR)(LF)": end of frame, carriage return and line feed

Main command:

Sequence number command description Maximum frame length (Byte)

1 $GPRMC recommended positioning information 70

2 $GPGGA GPS positioning information 72

3 $GPVTG Ground speed information 34

4 $RHXZ geomagnetic information 24

5 $GPGSA current satellite information 65

6 $GPGSV The number of visible satellites is 210

7 $GPGLL Geodetic coordinate information

Instruction analysis:

1. $GPRMC (Recommended Minimum Specific GPS/Transit Data) The basic format of the $GPRMC statement is as follows: $GPRMC,(1),(2),(3),(4),(5),(6), (7),(8),(9),(10),(11),(12)*hh(CR)(LF)

(1) UTC time, hhmmss (hour, minute and second)

(2) Positioning state, A=valid positioning, V=invalid positioning

(3) Latitude ddmm.mmmmm degrees and minutes)

(4) Latitude hemisphere N (Northern Hemisphere) or S (Southern Hemisphere)

(5) Longitude dddmm.mmmmm degrees and minutes)

(6) Longitude hemisphere E (East longitude) or W (West longitude)

(7) Ground speed (000.0~999.9 knots)

(8) Ground heading (000.0~359.9 degrees, with true north as the reference)

(9) UTC date, ddmmyy (day month year)

(10) Magnetic declination (000.0~180.0 degrees, fill in 0 if the number of leading digits is insufficient)

(11) Magnetic declination direction, E (East) or W (West) (12) Mode indication (A=autonomous positioning, D=differential, R=RTK, E=estimation, N=data invalid) Examples are as follows: $GPRMC ,084103.00,A,2233.395441,N,11356.556656,E,0.035,,220618,,,A*7A

 

2. $GPGGA (GPS positioning information, Global Positioning System Fix Data) The basic format of the $GPGGA statement is as follows (where M refers to the unit M, the same below): $GPGGA,(1),(2),(3),(4), (5),(6),(7),(8),(9),M,(10),M,(11),(12)*hh(CR)(LF)

(1) UTC time, the format is hhmmss.ss;

(2) Latitude, the format is ddmm.mmmmmm degree-minute format);

(3) Latitude hemisphere, N or S (Northern or Southern latitude);

(4) Longitude, the format is dddmm.mmmmmm degree-minute format);

(5) Longitude hemisphere, E or W (east or west longitude);

(6) GPS status, 0=no positioning, 1=non-differential positioning, 2=differential positioning;

(7) The number of satellites being used for positioning (00~12)

(8) HDOP level accuracy factor (0.5~99.9)

(9) Altitude (-9999.9 to 9999.9 meters)

(10) Geoid height (-9999.9 to 9999.9 meters)

(11) Differential time (the number of seconds since the latest differential signal was received, non-differential positioning, this item is empty)

(12) Differential reference base station number (0000 to 1023, the first 0 will also be transmitted, non-differential positioning, this item is empty) For example: $GPGGA,070343.90,2236.360900,N,11352.021690,E,1,04,68.82,- 72.83,M,- 1.00,M,,*68

3. $GPVTG (ground speed information, Track Made Good and Ground Speed) The basic format of the $GPVTG statement is as follows: $GPVTG,(1),T,(2),M,(3),N,(4),K,( 5)*hh(CR)(LF)

(1) Ground heading based on true north (000~359 degrees, the leading 0 will also be transmitted)

(2) Ground heading based on magnetic north (000~359 degrees, the leading 0 will also be transmitted)

(3) Ground speed (000.0~999.9 knots, the leading 0 will also be transmitted)

(4) Ground speed (0000.0~1851.8 km/h, the leading 0 will also be transmitted)

(5) Mode indication (A=autonomous positioning, D=difference, E=estimation, N=invalid data) Examples are as follows: $GPVTG,,T,,M,0.106,N,0.196,K,A*2A

 

4. $RHXZ (geomagnetic sensor information) The basic format of the $RHXZ statement is as follows: $RHXZ,(1),(2),(3) *hh(CR)(LF)

(1) The hexadecimal value of the X-axis of the geomagnetic sensor (the high bit is first, such as 0057 means 0x0057, the range is 0000~FFFF, and the front 0 will also be transmitted)

(2) The hexadecimal value of the Y-axis of the geomagnetic sensor (the high bit is first, such as FE6E means 0xFE6E, the range is 0000~FFFF, and the front 0 will also be transmitted)

(3) The hexadecimal value of the Z axis of the geomagnetic sensor (the high bit is in front, such as 0210 means 0x0210, the range is 0000~FFFF, and the front 0 will also be transmitted) For example: $RHXZ,0057,FE6E,0210*45

 

5. $GPGSA (current satellite information) The basic format of the $GPGSA statement is as follows: $GPGSA,(1),(2),(3),(3),(3),(3),(3),(3), (3),(3),(3),(3),(3),(3),(4),(5),(6)*hh(CR)(LF)

(1) Mode, M = manual, A = automatic.

(2) Positioning type, 1=no positioning, 2=2D positioning, 3=3D positioning.

(3) Satellite number being used for positioning (01~32)

(4) PDOP comprehensive position precision factor (0.5-99.9)

(5) HDOP horizontal precision factor 1 (0.5-99.9)

(6) VDOP vertical precision factor (0.5-99.9) For example: $GPGSA,A,3,26,02,05,29,15,21,,,,,,,2.45,1.49,1.94*0E

 

6. $GPGSV (number of visible satellites, GPS Satellites in View) The basic format of the $GPGSV statement is as follows: $GPGSV,(1),(2),(3),(4),(5),(6),(7) ,...,(4),(5),(6),(7)*hh(CR)(LF)

(1) Total number of GSV statements.

(2) The number of the GSV in this sentence.

(3) The total number of visible satellites (00~12, the preceding 0 will also be transmitted).

(4) Satellite number (01~32, the preceding 0 will also be transmitted).

(5) Satellite elevation angle (00~90 degrees, the preceding 0 will also be transmitted).

(6) Satellite azimuth (000~359 degrees, the previous 0 will also be transmitted)

(7) Signal-to-noise ratio (00~99dB, empty when no satellite is tracked).

Note: Each GSV statement includes the information of four satellites at most, and the information of other satellites will be output in the next $GPGSV statement.

For example: $GPGSV,3,1,12,02,39,117,25,04,02,127,,05,40,036,24,08,10,052,*7E $GPGSV,3,2,12,09,35,133,,10 ,01,073,,15,72,240,22,18,05,274,*7B $GPGSV,3,3,12,21,10,316,31,24,16,176,,26,65,035,42,29,46,277,18*7A

 

7. $GPGLL (Geographic Position) The basic format of the $GPGLL statement is as follows: $GPGLL,(1),(2),(3),(4),(5),(6),(7)*hh (CR)(LF)

(1) Latitude ddmm.mmmmm (degrees and minutes)

(2) Latitude hemisphere N (Northern Hemisphere) or S (Southern Hemisphere)

(3) Longitude dddmm.mmmmm (degrees and minutes)

(4) Longitude hemisphere E (East longitude) or W (West longitude)

(5) UTC time: hhmmss (hour, minute, second

(6) Positioning state, A=valid positioning, V=invalid positioning

(7) Mode indication (A=autonomous positioning, D=difference, E=estimation, N=data invalid)

For example: $GPGLL,2308.28715,N,11322.09875,E,023543.00,A,A*6A

 

3. NMEA0183 protocol verification reference program

unsigned char Calc_GPS_Sum( const char* Buffer )
{
unsigned char i, j, k, sum;
sum = 0;
for ( i = 1; i < 255; i++ ) //i 从 1 开始是闪过$开始符
{
if ( ( Buffer[i] != '*' ) && ( Buffer[i] != 0x00 ) ) //判断结束符
{
sum ^= Buffer[i];//GPS 校验和算法为 XOR
}
else
{
break;
}
}
j = Buffer[i + 1];//取结束符后两位字符
k = Buffer[i + 2];
if ( isalpha( j ) ) //判断字符是否为英文字母,为英文字母时返回非零值,否则返回零
{
if ( isupper( j ) ) //判断字符为大写英文字母时,返回非零值,否则返回零
{
j -= 0x37;//强制转换为 16 进制
}
else
{
j -= 0x57;//强制转换为 16 进制
}
}
else
{
if ( ( j >= 0x30 ) && ( j <= 0x39 ) )
{
j -= 0x30;//强制转换为 16 进制
}
}
if ( isalpha( k ) ) //判断字符是否为英文字母,为英文字母时返回非零值,否则返回零
{
if ( isupper( k ) ) //判断字符为大写英文字母时,返回非零值,否则返回零
{
k -= 0x37;//强制转换为 16 进制
}
else
{
k -= 0x57;//强制转换为 16 进制
}
}
else
{
if ( ( k >= 0x30 ) && ( k <= 0x39 ) )
{
k -= 0x30;//强制转换为 16 进制
} }
j = ( j << 4 ) + k; //强制合并为 16 进制
// gps_sum = j;
if ( sum == j )
{
return Valid; //校验和正常
}
else
{
return Invalid; //校验和错误
} }

 

4. GPS module test software

The gps module can be tested with u-center test software, which can support serial port and network port.

You can also use the SSCOM serial port to collect GPS data and save it to a file for use

5. Related software download

Digital Earth software download address: https://download.csdn.net/download/xipengbozai/19774250

GPS test software download address: https://download.csdn.net/download/xipengbozai/19774233

GPS data conversion tool: https://download.csdn.net/download/xipengbozai/19774213

 

Attached picture (screenshot of digital earth screenshot software)

Guess you like

Origin blog.csdn.net/xipengbozai/article/details/118103147