Pages: 1 [2] 3   Go Down
Author Topic: GPS varying Output  (Read 1966 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27372
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This is probably too technical for you, but it discusses all the things that lead up to the small variation you are seeing.

http://en.wikipedia.org/wiki/Error_analysis_for_the_Global_Positioning_System
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 642
Posts: 50423
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Assuming the device is outside in an open sky, how much variation (in meters) would be acceptable for your design?
And how much are you seeing?

Show some serial output, not another out of focus, poorly lit, often blocked, view of an LCD.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 196
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sir we are designing an autonomous Robot based on GPS and our steering will move according to the direction and distance of the waypoints but our GPS is showing Varied output in terms of direction Hence the Steering will get confuse too
Logged

Worcester, MA
Offline Offline
God Member
*****
Karma: 3
Posts: 623
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sir we are designing an autonomous Robot based on GPS and our steering will move according to the direction and distance of the waypoints but our GPS is showing Varied output in terms of direction Hence the Steering will get confuse too
We need to see some numbers
Logged

I2C GPS Shield

Checkout my Open Source GPS Tracker on Kickstarter

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27372
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So you need to manipulate the #s then.
Try averaging 10 samples to smooth out the result.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27372
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Another option:
x = 23.123456
x = x * 1000, now x = 23123.456
x = int x, now x = 12123
x = x/10, now x = 12.123

See it that helps. Maybe it's too simplistic an approach, makes sense in my mind anyway.
Data-wise, maybe you lose too much position detail that way, and it will put you 1000 feet from where you want to be or something.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Full Member
***
Karma: 0
Posts: 196
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i was trying how to get the average of 10 samples of the GPS reading but i think it i dont know how to convert it into code can you make out a code for me that takes 10 samples of GPS reading and compute me the direction 
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27372
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

??
Code:
float gps_data = 0;
for (int x = 0; x<10; x=x+1){
gps_data = gps_data + new_reading_value;
}
float gps_avg =  gps_data/10;
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Full Member
***
Karma: 0
Posts: 196
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

can i get a good heading using this code with the GPS
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27372
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I was providing the example, you'll have to take the approach and adapt it to your specific code.
You may have to average in both Lat, Long, and Altitude for example.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27372
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I would think you'd need to perform the averaging here:
Code:
   if (myGPS.decode(mygps.read())) {
      // if so, set status led on
      digitalWrite(13, HIGH);
        
      // calculate direction to destination, relative to my own direction of movement
      float lat = myGPS.gprmc_latitude();
      float longi = myGPS.gprmc_longitude();
so make that section do 10 readings with the averaging as discussed:
Code:
float lat = 0;
float longi = 0;
for (int x = 0; x<10; x=x+1){
    if (myGPS.decode(mygps.read())) {
      // if so, set status led on
      digitalWrite(13, HIGH);
        
      // calculate direction to destination, relative to my own direction of movement
      lat = lat+ myGPS.gprmc_latitude();
      longi = longi + myGPS.gprmc_longitude();
}
lat = lat/10;
longi = longi/10;
}
// continue to the display code
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Full Member
***
Karma: 0
Posts: 196
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is this ok
Code:

#include <math.h>
#include <nmea.h>
#include <LiquidCrystal.h>
#include <NewSoftSerial.h>
NewSoftSerial mygps(7, 8);
NMEA myGPS(GPRMC);
LiquidCrystal myLCD = LiquidCrystal(12, 11, 5, 4, 3, 2);
float dest_latitude =  25.37106;
float dest_longitude = 68.355681; 
void setup() {
  myLCD.begin(16,2);
  mygps.begin(4800);
  pinMode(13, OUTPUT);  // diagnostic led on Wiring-board
  pinMode(6, OUTPUT);
  myLCD.clear();
  myLCD.home();
  myLCD.print(":) :)");
  delay(1000);
}
void loop() {
  if (mygps.available() > 0 ) {
    float lat = 0;
    float longi = 0;
    for (int x = 0; x<10; x=x+1){
      if (myGPS.decode(mygps.read())) {
        // if so, set status led on
        digitalWrite(13, HIGH); 
        // calculate direction to destination, relative to my own direction of movement
        lat = lat+ myGPS.gprmc_latitude();
        longi = longi + myGPS.gprmc_longitude();
      }
      lat = lat/10;
      longi = longi/10;
    }
    // continue to the display code
    myLCD.setCursor(0,0);
    myLCD.print("D:");
    float d=(round(myGPS.gprmc_distance_to(dest_latitude, dest_longitude, MTR)));
    myLCD.print(d);
    myLCD.print("m");
    float mydir=0;
    for (int y=0;y<10;y++)
    {
      if (myGPS.gprmc_status() == 'A') {
        // calculate relative direction to destination
        d = myGPS.gprmc_course_to(dest_latitude, dest_longitude) - myGPS.gprmc_course();
        mydir=mydir+d; 
        if (d < 0) {
          d += 360;
        }
        if (d > 180) {
          d -= 360;
        }
      }
      mydir=mydir/10;
      myLCD.setCursor(1,1);
      myLCD.print(mydir);
      if(d<5)
      {
        digitalWrite(5,HIGH);
      }
      else {
        digitalWrite(5,LOW);
      }
      if(d>-5){
        digitalWrite(13,HIGH);
      }
      else {
        digitalWrite(13,LOW);
      }
    }
  }
}


« Last Edit: February 25, 2012, 02:28:52 am by cutebuddy6 » Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27372
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't see it doing anything with the new averaged values that are calculated.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Full Member
***
Karma: 0
Posts: 196
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

it still does not gives me good direction why?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 642
Posts: 50423
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
it still does not gives me good direction why?
Grow up. Learn to use capital letters and punctuation. Learn to read all replies before blurting "it doesn't work".

Do you have any idea how much, distance-wise, the variation of actual location that you are getting corresponds to?
Logged

Pages: 1 [2] 3   Go Up
Jump to: