I am designing an autonomous Robot based on GPS but as i am displaying THE GPS data on LCD its showing me varying Latitude and Longitude tell me how can i fix it
// This is my first very simple GPS navigation tool, that
// was written for my Wiring board. It connects to a GPS
// module via port Serial1 (4800bps) and shows some very
// basic navigation information on a character-based LCD.
// The information shown is:
// - direction to destination, relative to own movement
// - distance to destination in meters (it is really
// easy to do kilometers, miles, etc.)
// - my current speed in kilometers per hour
// - GPS status identifier
//
// I tried it in my car, and it works perfectly, although
// it's quite useless. The code below uses the Wiring
// board diagnostic LED on pin 48, which does not exist
// on Arduino's -- be aware.
#include <math.h>
#include <nmea.h>
#include <LiquidCrystal.h>
#include <NewSoftSerial.h>
NewSoftSerial mygps(7, 8);
// create connection to GPRMC sentences from my GPS
NMEA myGPS(GPRMC);
// create LCD object (I use a 2x16 character display)
LiquidCrystal myLCD = LiquidCrystal(12, 11, 5, 4, 3, 2);
// my destination coordinates in signed degrees-decimal
float dest_latitude = 25.362023;
float dest_longitude = 68.355542;
//25.362023, 68.355542?
void setup() {
myLCD.begin(16,2);
mygps.begin(4800);
pinMode(13, OUTPUT); // diagnostic led on Wiring-board
myLCD.clear();
myLCD.home();
myLCD.print("GPS-NAV By Eshu");
delay(1000);
}
void loop() {
// check if data from GPS available on Serial1 port
if (mygps.available() > 0 ) {
// check if full sentence recieved from GPS
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();
myLCD.clear();
myLCD.home();
myLCD.setCursor(0, 0);
myLCD.print("lat:");
myLCD.print(lat);
myLCD.setCursor(0, 1);
myLCD.print("longi:");
myLCD.print(longi);
myLCD.setCursor(15, 1);
myLCD.print(myGPS.gprmc_status());
}
}
}
The position from a GPS receiver will drift continuously, due to inaccuracies in the system and the fact that the constellation is moving.
Part of the GPS inaccuracy is due to atmospheric conditions, which are constantly changing, causing propagation delays and errors in the resulting the calculation. That error changes with time, as the satellites move overhead.
This phenomenon is usually called drift. The drift will be worse if you have a poor signal, reflections (multipath), etc.
At a previous employer, we called this a WAD problem - it Works As Designed.
Under what circumstances? When displaying the value somewhere? If so, that depends on the display class being used. If the class derives from Print, the Print::print() method that prints a float takes two arguments - one mandatory (the float to print) and one optional - the number of digits after the decimal point.
Chopping off digits for any other purpose is not possible. Get over it.
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
cutebuddy6:
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