Pages: [1] 2 3   Go Down
Author Topic: How to round off the data and Store it into Memory for processing  (Read 2019 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 196
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How to round off the data and Store it into Memory for processing  i am using a GPS data to Store it
Kindly help me out
Logged

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

Quote
How to round off the data
Round off what data? GPSs return strings. You can't round a string. The string needs to be parsed and converted to numbers. You don't want to round the numbers when you store them in memory.
Logged

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

you are right but i am new to programming can u suggest me code by which i can Store my GPS reading in to EEPROM
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 637
Posts: 34607
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am not sure why you would want to store GPS data into EEPROM but the place to start looking at how to write the code is here:-
http://www.arduino.cc/en/Reference/EEPROM
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Could you explain what you mean by "round off the data" and "store it into memory for processing"?

It may be that you're trying to do something very easy, but from your question it isn't quite clear what that is.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

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

basically what i am trying to do is to navigate my ride on Jeep through GPS the Problem i am facing is that its giving me continuous Lat\long i want to stop that and store it into EEPROM and then calculate the distance and bearing  from my way point i am using NMEA library this is the method i am using if you have got any Knowledge regarding this Kindly let me know 
Logged

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

You need to use a few of these. I've got some spares. Copy and paste these into your post. Then, maybe it will make sense.

................................................................................
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Will your Arduino be running continuously during this journey, or do you want it to remember where it has been after you switch it off?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

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

yes My Arduino will run continuously through the course from Destination to Waypoint
Logged

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

Quote
My Arduino will run continuously through the course from Destination to Waypoint
Then, every time you get a new position, you should update the distance and direction. There is no need to store any position in EEPROM.
Logged

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

But i dont know how can i fix the GPS data its continuously changing so for calculating the Distance and direction its not constant i can send you the the code
 
Logged

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

Quote
But i dont know how can i fix the GPS data its continuously changing
This assumption is invalid. The GPS returns new data often, but it does not return a continuous stream of data.

As far as the Arduino is concerned, there is an eternity between new readings.

Quote
i can send you the the code
Even better, post it.
Logged

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

Code:
// 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());

}
  }
}


i am using the following code for the latitude and Longitude display on LCD
and the result is continuously varying and i am taking this code for my direction code that is
Code:
// 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 dir = myGPS.gprmc_course_to(dest_latitude, dest_longitude) - myGPS.gprmc_course();
      if (dir < 0) { dir += 360; }
      if (dir > 180) { dir -= 360; }
     
      // display relative direction to destination
      myLCD.clear();
      myLCD.home();
      if (dir < 0) {
        myLCD.print('<');  // destination is to your left
      } else {
        myLCD.print('>');  // destination is to your right
      }
      myLCD.print(abs(dir), DEC);
      myLCD.print(223, BYTE);  // print °-character
     
       // display distance to destination in meters
      myLCD.setCursor(0, 1);
      myLCD.print("D:");
      myLCD.print(round(myGPS.gprmc_distance_to(dest_latitude, dest_longitude, MTR)));
      myLCD.print("m");
       
       // display my speed in kilometers per hour
      myLCD.setCursor(5, 0);
      myLCD.print("S:");
      myLCD.print(round(myGPS.gprmc_speed(KMPH)),DEC);
      myLCD.print("Km/h");
       
        // display GPS positioning status ('A'=active, 'V'=void)
      myLCD.setCursor(15, 1);
      myLCD.print(myGPS.gprmc_status());
     
      // set status led off
      digitalWrite(13, LOW);
    }
  }
}
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 637
Posts: 34607
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The code below uses the Wiring
// board diagnostic LED on pin 48, which does not exist
// on Arduino's -- be aware.

So what Arduino board are you using then?

Code:
if (mygps.available() > 0 )
So you check that there is at least one character in the buffer and then go on:-
Code:
myGPS.decode(mygps.read())
To read a whole pile of bytes, how many I can't tell because I haven't got that library.

I think you need to wait until all the data is in before you try and read it.
Logged

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

Quote
To read a whole pile of bytes, how many I can't tell because I haven't got that library.

I think you need to wait until all the data is in before you try and read it.
If the NMEA library is anything like the TinyGPS library, only one byte is read, and then the decode() function is called. That function returns true or false, depending on whether the packet was completed by the last byte read.

OP: If you added a Serial.print() statement to loop, you'd see that there were thousands of passes through loop needed to collect one entire packet from the GPS. Each packet contains a timestamp. You'd see, if you printed the whole packet, that the time changes for each packet.

The code you posted is showing the direction to the destination already, so I'm not sure what it is you are asking for help with. It appears that all you need to do is to calculate the distance to the target.
Logged

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