Sunday, June 26, 2011

MTK NMEA checksum calculation

The MTK NMEA checksum can be calculated by using the following procedure:

The NMEA Checksum is calculated on a character by character basis using an XOR operator. Each character is fed into an XOR with the current checksum value. The checksum is initialized to all zeros. The characters that exist between the "$" and "*" are the only characters to be used in the calculation. These values are in ASCII, thus each character is represented as an 8-bit value. The resulting checksum is an 8-bit HEX value which is represented as 2 ASCII characters. Below is an example of this procedure:


0000 0000 <==Checksum
0101 0000 <==P

0101 0000 <==Checksum
0100 1101 <==M

0001 1101 <==Checksum
0101 0100 <==T

0100 1001 <==Checksum
0100 1011 <==K

0000 0010 <==Checksum
0011 0000 <==0

0011 0010 <==Checksum
0011 0000 <==0

0000 0010 <==Checksum
0011 0000 <==0

0011 0010 <==Checksum

This results in a checksum of 32 which matches what was shown above.

And for those folks that use MATLAB, HERE is a very basic program that I wrote up that does this for you.


No comments:

Post a Comment