
<b>
REM 	02/08/2007
REM 	generate checksum of a NEMA 0183 GPS string

REM 	Q. How is the checksum calculated in NMEA 0183? 

REM 	A. The checksum is the 8-bit exclusive OR (no start or stop bits) of all characters in the 
REM 	sentence, including the "," delimiters, between but not including the "$" and "*" 
REM 	delimiters. The hexadecimal value of the most significant and least significant 4 bits of 
REM	the result are converted to two ASCII characters (0-9, A-F) for transmission. The most 
REM	significant character is transmitted first. 

CLS
NEMA$ = "$GPRMC,000004,V,3714.6284,N,12146.9181,W,0.000,0.0,290697,15.4,E*4C"
PRINT " " + NEMA$
chksum = ASC(MID$(NEMA$, 2, 1))
PRINT " 1. Hex Checksum value " + HEX$(chksum), "ASCII (HEX) NEMA DATA " + (MID$(NEMA$, 2, 1)), HEX$(ASC(MID$(NEMA$, 2, 1)))

FOR x = 3 TO LEN(NEMA$) - 3
chksum = ASC(MID$(NEMA$, x, 1)) XOR chksum
PRINT STR$(x) + ". Hex Checksum value " + HEX$(chksum), "ASCII (HEX) NEMA DATA " + (MID$(NEMA$, x, 1)), HEX$(ASC(MID$(NEMA$, x, 1)))
NEXT x

PRINT " " + NEMA$
PRINT " NEMA Checksum is " + HEX$(chksum)</b>
