Let's Make Robots!

GPS failed checksum

Well first of all Hi everyone, although i've been visiting the site for a while this is my first post on LMR so here goes.

After seeing patrickmccabe's "Fundamentals of a GPS guided vehicle" tutorial i decided to give it a go. I got the code supplied in the tutorial to work without any trouble but when i started making some changes and adding to the code i ran into a few problems.

Im using the Arduino Mega, EM-406 GPS module, I2C compass, TEXTSTAR serial lcd and a few pushbuttons. I was trying to add a sort of menu to the start of the code so that i could save waypoints. The menu seems to work ok except that now im getting a lot of failed checksums, about 10 or 12 while im saving the waypoints and when the loop starts running within a minute or so the failed checksums get up to 10s of thousands' and the arduino seems to reset and the menu in void setup starts again.

Its think it must be something that i've added to the code but im not great at coding so i dont know what. I've tried using separate power for the gps, buttons and lcd in case that was causing the arduino to reset. I also tried disconnecting the lcd to see if that was it. I've tried removing bits of the menu code and adding delays here and there but i don't really know what I'm doing so it could easily be something fairly simple. Anyway i thought i'd post the code and see anyone could see what the problem might be or give me some ideas of things to try to solve the problem. Any help would be much appreciated.

James 

 

AttachmentSize
RoverGPSCompass_aug20d.pde11.21 KB
AGV_editing (patrick's new code).pde9.71 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Sorry for the delay replying, ive been having internet issues. Im going to make a new robot entry so you can see my progress so far. :)

Hoi James,

Best way to go forward is to go backwards.........

  1. Test the GPS by its self and monitor the raw data
  2. Test the Compass by its self and monitor the raw data
  3. Test the TextStar LCD by itsself

If each module works fine then try adding 2 together ,Biggest problem with arduinos is that timers can clash and mess each other up, libraries have the habit of using the same timers.. ie in the background (because the code is hidden in the library module)

If you list the Libraries you are using then maybe we can point you in the right direction.

 

Ok lets start with something simple. Like just getting GPS points from the GPS. I am sure you have done this. If you can get GPS points from your GPS, take your waypoints and your current latitude and longitude and calculate bearing and distance to your waypoint, then your pretty well there. I would like you to start with that. I have written new code with the help from other members. There is a lot of content in the new code which doesnt need to be discussed right now. That old code that i wrote, and you are building on, is not very good. I still need to update the tutorial with the new code and explaining it. But here is something that might help you.

 

this code was given to me by Bill Porter who helped me a lot. Not only is this PD control but it outputs a value that can be mapped to the servo steering and it outputs the direction to turn (ie., left or right. -50 being all the way one way and 50 all the way the other, with values in between). This should work for you well if your using a servo or can be used to determine delays for differential drive vehicles. 

void execute(){

error=(heading-headingcompass);

//handle wrap-around  

if (error < -180){ 

error = error + 360;  

}

if (error > 180){

  error = error - 360;

}

//Serial.println(error);

float HEADING_KP=.8;   //gains. 

float HEADING_KD=.2; 

int derror = ((error - last_error) / 2); 

int ierror = ((error + last_error) / 2);   

float diff = (HEADING_KP * error) + (HEADING_KD * derror);

int PD_output=diff;

last_error=error;

servo.write(map(PD_output, -50, 50, 110, 70));  // here is the output of the PD control being mapped and written to the servo

 

Getting to your problem. I have seen this restarting happening in my old code too. So do not worry if its happened to you, and me, then its the crappy old code. If you would like to talk more, feel free to contact me on skype (my name is patrick.mccabe75), where i can explain better what is going on. Basically i suggest switching to the new code ASAP. If your using a cheap toy car, i can still help you because there are better ways to do what the code does. 

Since i cant attach my new code file on this comment, i will attach it to your blog post since i have that power :). So check this exact post for my new code.

Thanks Patrick, i butchered your new code and used some of it and it seems to be doing what it supposed to do now, no errors and no restarts! :)

Thanks rik!

Welcome James. As I do not know anything about "Arduino Mega, EM-406 GPS module, I2C compass, TEXTSTAR serial lcd", I will reduce my advice to: "sounds like you've got those pushbuttons under control, don't change anywhing about that".

But really, I just wanted extend you a belated Welcome James.

Where DID you learn that English, rik?

Oh, and Welcome James!

PS: James, you can reply by selecting "Reply" - instead of posting a new comment :)

Unless you're a carpenter. Then the reply button will just spit you in the face.