Pages: 1 [2] 3 4   Go Down
Author Topic: I made a GPS library for decoding NMEA protocol  (Read 7805 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So this code works on the Hardware Serial (UART) just change the Baundrate and set your GPS to send the data in GPRMC

Thanks GekoCH  although I can't get the latest code to work. I put the baudrate to 4800 and I also tried putting the following code into the setup function:

Code:
pinMode(2, INPUT);
pinMode(3, OUTPUT);
Logged

Switzerland
Offline Offline
Sr. Member
****
Karma: 0
Posts: 269
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I told you it does just work on the UART port.
Connect the GPS pin to Arduino Pin 0 (RX).

I haven't tried it with the SoftwareSerial (pin 2 or pin 3)

Would be strange if it doesn't work...
What kind of Sentence does your GPS send?

Geko
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Geko, thank you so much for you assistance and help on this topic! It is much appreciated by me.

I have looked into the remarks in this thread shortly, and believe that nearly all problems are caused because the example programs were written for Wiring, not Arduino! I do not have an Arduino, and as a result, I didn't know that there is no port "Serial1" on Arduino.

I will write new example code, and try it on an actual Arduino this weekend. Will then post an update on this thread and inform you how to download the new example code. I'm pretty sure it will work fine then.

thanks for your feedback and patience,
Maarten
Logged

Switzerland
Offline Offline
Sr. Member
****
Karma: 0
Posts: 269
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Geko, thank you so much for you assistance and help on this topic! It is much appreciated by me.

I have looked into the remarks in this thread shortly, and believe that nearly all problems are caused because the example programs were written for Wiring, not Arduino! I do not have an Arduino, and as a result, I didn't know that there is no port "Serial1" on Arduino.

I will write new example code, and try it on an actual Arduino this weekend. Will then post an update on this thread and inform you how to download the new example code. I'm pretty sure it will work fine then.

thanks for your feedback and patience,
Maarten

Thx a lot Maarten

Yes I think there are some bugs in the Library but he core code does work for me. Just some tiny bits
do not work!

Thx again for your great work!
Geko
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

GekoCH,

Code:
I told you it does just work on the UART port.
Connect the GPS pin to Arduino Pin 0 (RX).

OK, this won't work for me as I have a GPS/GPRS shield that sits directly on top of the Arduino and uses pins 2 and 3.

Maarten, thanks that would be great!
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
OK, this won't work for me as I have a GPS/GPRS shield that sits directly on top of the Arduino and uses pins 2 and 3.

I am aware that the example code does not work (yet) via Arduino pins 2 and 3. However, I'm hoping to borrow an Arduino this weekend and write some new example code that uses "SoftwareSerial" on those two pins. I have no reason to assume that would not work.

Maarten
« Last Edit: September 11, 2008, 06:04:18 am by maartenl » Logged

Switzerland
Offline Offline
Sr. Member
****
Karma: 0
Posts: 269
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

But as you know the SoftwareSerial is quite slow or better it does
need a lot of power and that slows the Arduino down. I got some
experience in this. I do now parse the Gps sentence at 5hz on the
UART so the Hardware Serial on pin 0. I think as your program grows
Software Serial is going to be a problem.
And at 5hz the Software Serial is relay struggling getting the
data and parse them...

Geko
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I wasn't really aware that SoftwareSerial was much slower than Serial, but I trust that it is. This may indeed be limiting to the number of sentences the library can process per second. However, this not only depends on the frequency of NMEA cycles (for example 1 Hz, or 5 Hz), but also on the number of sentences output per cycle. If you are only using a particular sentence type (for example GPRMC or GPGGA), then some GPS receivers let you choose to only output those sentence types. This will considerably speed-up processing.

Also, I would think that the library as-it-is does not require much processing, but only at the moment when a GPRMC sentence was completed: at that moment it does a lot of floating-point stuff.

Maarten
« Last Edit: September 11, 2008, 07:15:58 am by maartenl » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Maarten,

Any progress with the Arduino port of the NMEA library? It works fine with the Wiring IDE though.

Keep up the good work.

thanks,
Madhu.
Logged

Korea
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm looking forward to Maarten's progress too.

And I got some success(? )  

with Arduino and NMEA library , I connected  GPS to HW serial and AFSoftSerial to the PC
It works ^^ (<- smiling eyes. kind of Korean emoticon. korean emoticon is upright style. can you understand it? )
But programming is some hassle --; (<- cold sweating ?)


Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Any idea of how to connect the arduino BT to a BT GPS receiver?

this is the closest I've read to a BT connection other than a computer:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1180546719  :-[

« Last Edit: October 26, 2008, 07:09:27 am by busstopArduino » Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 103
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How is the arduino port coming along?

I am looking foward to this smiley
Logged

Salem, Oregon
Offline Offline
Sr. Member
****
Karma: 7
Posts: 307
Friends don't let friends use Strings
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not sure why anybody is waiting for a "port" to the Arduino - the NMEA library works out of the box for me.  I think the example programs are what needs to be modified.

I grabbed the provided example to show all sentences and modified two or three lines - it worked fine for me.  

Here is the modified code, but my contribution wasn't much.  Oh yeah, you'll need the AFSoftSerial library (since the normal software serial doesn't have an avaliable function).


Code:
// This example illustates access to all sentence types,
// using the NMEA library. It assumes that a GPS receiver
// is connected to serial port 'Serial1' at 4800 bps.

#include <nmea.h>
#include <AFSoftSerial.h>

// Constants
#define rxPin 9
#define txPin 8

// set up the serial port

AFSoftSerial mySerial = AFSoftSerial(rxPin, txPin);

// variables
NMEA gps(ALL);    // GPS data connection to all sentence types

void setup() {
  Serial.begin(9600);
  mySerial.begin(4800);
}

void loop() {
  if (mySerial.available() > 0 ) {
    // read incoming character from GPS and feed it to NMEA type object
    if (gps.decode(mySerial.read())) {
      // full sentence received
      Serial.print ("Sentence = ");
      Serial.println (gps.sentence());
      Serial.print ("Datatype = ");
      Serial.println (gps.term(0));
      Serial.print ("Number of terms = ");
      Serial.println (gps.terms());
    }
  }
}

Hope this helps,

Brad.

[edit]I've seen a reference somewhere on the forum that this library has a large memory footprint - perhaps that's the problem people are seeing?  I've upgraded to the 328P, so maybe that's why I don't see a problem?[/edit]
« Last Edit: December 12, 2008, 07:24:26 pm by bradb » Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 4
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I've seen a reference somewhere on the forum that this library has a large memory footprint - perhaps that's the problem people are seeing?  I've upgraded to the 328P, so maybe that's why I don't see a problem?

I think your assessment is correct, Brad.  Creating a single NMEA object allocates ~1200 bytes of RAM, which is probably great for the 328P, but a little too big to fit in a "conventional" Arduino.

I am working on a derivative library called TinyGPS that provides a subset of NMEA's functionality but is much smaller.  It provides latitude, longitude, time, date, course, speed, and magnetic variation -- everything that the $GPRMC sentence provides.  I would welcome suggestions on whether this would suffice for a majority of users.

Mikal
« Last Edit: December 19, 2008, 12:01:30 am by mikalhart » Logged

Salem, Oregon
Offline Offline
Sr. Member
****
Karma: 7
Posts: 307
Friends don't let friends use Strings
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It provides latitude, longitude, time, date, course, speed, and magnetic variation -- everything that the $GPRMC sentence provides.  I would welcome suggestions on whether this would suffice for a majority of users.

Mikal-

I'm not sure what everybody else needs, but I think it would be fine for my purposes (I haven't looked, but I think that's enough information to plot my location on google maps).

Since I'm passing the data via XBee using API mode, I'm limited to a payload of 72 bytes (once I get the code sorted out) so simple is really better.

I'm looking forward to your library.

Brad.
Logged

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