I'm working with a group that is equipping an RC airplane to fly autonomously. It is our first attempt, so there are a few things we do not have a good concept of yet.
At the moment, we are focusing on integrating our GPS component and enabling communication with our microcontroller. We have found some good pieces of code to read the NMEA sentences, but we do not understand Checksum.
Why is checksum necessary, and what is the checksum number (i.e. "*28") telling us? Any other advice on getting started with NMEA 0183 would also be appreciated

Holt

Tags: GPS, NMEA, checksum

Views: 153

Reply to This

Replies to This Discussion

The checksum means the vAlues have been read correctly from your GPS. The modual sums them and you sum them and then you compare the sum. A bad gps value could cause an error in your nav equations sending your plane into the ground.
Think of all the conditioning in the autopilot code you would need to make sure that the GPS data is valid. If your GPS had a bad value (which happens) your code may react in a way that was not intended since you probably weren't expecting it to happen during development. The checksum is a simple way to avoid all the conditions in your code. Like Jason said, its just a simple sum to determine if the output is the same on both sides.
Thanks guys,
If I could ask one more question to clarify. There is the checksum value at the end of an NMEA sentence (i.e. *68). And there is a checksum value that I should have my code determine. These checksums should be compared to ensure that the microcontroller will be reacting to the proper information. My question is, what are the values that are summed and indicated by the NMEA sentence's checksum?
From another website I grabbed some examples of the particular NMEA sentence that I am going to be trying to parse.

eg2. $GPRMC,225446,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68

My initial thought was that the 68 (the checksum value) was the number of digits and characters in the $GPRMC sentence. But I counted them up and this was not so. I appreciate you helping me to understand this one.

Holt
Do you have Jordi's code from Ardupilot? I would just use that. The checksum should just be part of the blackbox that is the GPS parser. Parsing those strings in C is kind of an ugly mess because strtok_r is not the most intuitive function.

From Google:
An NMEA checksum is calculated as the XOR of bytes between (but not including) the dollar sign and asterisk.
That means 68 is your sum (NOT *68). The XOR of all the bytes in your example should = 68 or B01000100


This line from Jordi's code sums it up:

for(int x=0; x<100; x++)
{
if(gps_buffer[x]=='*')
{
checksum_received = strtol(&gps_buffer[x+1],NULL,16);//Parsing received checksum...
break;
}
else
{
checksum^=gps_buffer[x]; //XOR the received data...
}
}
If your GPS module has a binary mode you can avoid NMEA entirely and make your life a lot easier, as we do with ArduPilot and the EM406 and uBlox binary modes. BTW, what features in the existing open source (or commercial) autopilots were missing for you, such that you decided to roll your own? It's a non-trivial task, as you've already found....

RSS

Social Networking

Contests

Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.

A list of all T3 contests is here

Groups

Advertisement

© 2013   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service