Go Down

Topic: How to use NeoGPS (Read 3069 times) previous topic - next topic

mkc2lr

Hello,

I tried to get NeoGPS to work, because TinyGPS++ didn't work with my Neo M8N. Basically it works now, but I don't understand how to extract the data. In TinyGPS++ (with my Neo 6) it was easy to understand how to extract speed, course, etc. But the examples in NeoGPS don't show how to do that. I only see a whole sentence. I ran the ubox.ino example successfully...

I'd be glad to get an example as simple as for TinyGPS++ how to get to the data.


Thanks,
Christof

TommiP

#1
Feb 26, 2017, 03:29 pm Last Edit: Feb 26, 2017, 04:17 pm by TommiP
Hi

I got what I need awhile ago after I watched this video and some more from this guy.. This example is for binary method but when you get it work, you don't want the text version..  :)

TommiP

-dev

The Data Model page shows all the pieces of a fix structure that you can access.

It has examples, but you can also look at Streamers.cpp.  it has functions to print out everything you have enabled in the config files.  Everything.  :)

Try searching for "fix." in the example programs. I know NMEAloc, NMEAdistance, NMEAdistance, or NMEArevGeoCache use various parts of a fix.

Or just ask...  :)

NeoGPS also supports the UBX binary protocol, in the example program ublox.ino.  It is harder to debug than the NMEA text, so I don't recommend it to beginners.  BTW, the code from that video is not very robust, so I wouldn't recommend it.

I would suggest starting with NMEAloc.ino and adding the other pieces you want, according to the Data Model page examples.

I'll try and add another basic example soon.  You can never have too many examples.

Cheers,
/dev
Really, I used to be /dev.  :(

mkc2lr

@TommyP: Thanks for the hint. I found that before, but I'm not sure if it works with the M8. Also the video is based on a Neo6.

@/dev: Also many thanks! This looks like what I need. Do you know if the same fixes work in binary mode?
Probably I'll follow your advice and start in text mode. If it works with 10Hz, I probably don't change.

-dev

Do you know if the same fixes work in binary mode?
Fixes are independent of the text (NMEA) or binary (UBX) mode.

Fixes can contain many pieces or just one piece, according to what is enabled in GPSfix_cfgh.

Pieces of a fix are set when NeoGPS parses a text or binary message from the GPS device.  Different messages set different pieces.  Any part of a message that would have set a disabled piece is quickly skipped.

NeoGPS parses only the messages that are enabled in NMEAGPS_cfg.h (text) or UBX_cfg.h (binary).  Disabled messages are quickly skipped.

So, to answer your question, all fix pieces are available when parsing NMEA or UBX messages.  However, you must

*  enable fix pieces that you want (edit GPSfix_cfg.h)

*  enable the messages that set those pieces (read Choosing Your Configuration, edit NMEAGPS_cfg.h)

*  make sure your device is sending those messages (use NMEAorder, set LAST_SENTENCE in NMEAGPS_cfg.h, and perhaps send a command to the GPS device in setup).

Quote
If it works with 10Hz, I probably don't change.
Another person is using it at 20Hz, but it's a different brand.  NeoGPS is the fastest library, parsing a sentence in less than 1ms.  There's still 99ms left in each update at 10Hz, text or binary mode.

You may already know that the baud rate has to be higher for the higher update rates.

Cheers,
/dev
Really, I used to be /dev.  :(

TommiP

@TommyP: Thanks for the hint. I found that before, but I'm not sure if it works with the M8. Also the video is based on a Neo6.
I have M8 too and it worked just fine  :)

TommiP

mkc2lr

Thanks a lot again. I tried to use the fixes, had some updates in the configuration and it works fine in NMEA mode.
But in binary mode, I didn't get it working so far. I'll continue to try...

fix.heading doesn't output anything but 0, I enabled all sentences my GPS module supports. Do you have any idea why?

Thanks
Christof

-dev

Quote
it works fine in NMEA mode.  But in binary mode, I didn't get it working so far.
I'm not sure you really need the binary mode.  As I said, text parsing in NeoGPS is very fast.

Quote
fix.heading doesn't output anything but 0, I enabled all sentences my GPS module supports. Do you have any idea why?
Because you're always moving north?  ;)

Ok, you must have HEADING enabled in GPSfix_cfg.h, or you couldn't print fix.heading.

I assume you have enabled NMEAGPS_PARSE_RMC and/or VTG.  Those are the only sentences that provide the current heading.

Are you sure your device is actually sending the RMC (probably) and/or VTG (maybe)?

And finally, if you are not moving more than 5kph, the heading may never be anything other than 0.  Be sure to check fix.valid.heading first.  You may not even have a valid heading value (it defaults to 0).

You said ublox.ino was working.  Did it show a 0 heading, too?  (Be sure to press ENTER in the Serial Monitor window, before loading NMEA.ino, so it puts the GPS device back in text mode.)

You should use NMEA.ino to print everything the sketch is receiving.  The header line shows all the pieces that are enabled.  If the data lines show an empty or 0 heading, that's really what the device is sending.  If not data lines come out, it is still in binary mode (see above) or the wrong baud rate.

Cheers,
/dev
Really, I used to be /dev.  :(

TegwynTwmffat

I've got NMEA working on an Arduino Due with the Ublox M8 and its outputting lots of data on the serial port.

I've read the instructions and examples on GitHub for using the 'fix' protocol but can't get any of the examples to actually work within NMEA.ino.

Could you give me a simple couple of lines of code that would get me started, I presume using fix.latitudeL()?

I'd want to put the code in void loop() and then be able to use the floats to do some simple calculations for navigation.

To summarise, I've got lots of data in the serial port but have no idea where it has come from or how I can reduce it to simple lat and long and then make simple calculations on it.

Thanks!

-dev

Try the examples NMEAsimple, NMEAdistance or Tabular.  If you want the extra precision of the integer lat/lon values (not float), try NMEAloc.  The NeoGPS distance and bearing calculations preserve the accuracy of the integer lat/lon values.

If you still have questions, post your code and error messages, in between [code]... [/code] tags,

Code: [Select]
 so it looks
   like this.

You can type those in, or select the code in your post and press the "</>" button in the upper left corner of the post editor.

Cheers,
/dev
Really, I used to be /dev.  :(

TegwynTwmffat

Thanks for that! I got some tangible results using this code snippet:
Code: [Select]
NeoGPS::Location_t madrid( 404381311L, -38196229L );
NeoGPS::Location_t llange( 532558000L, -43114000L );

static void doSomeWork()
{
  // Print all the things!

  trace_all( DEBUG_PORT, gps, fix_data );

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  float dist = fix_data.location.DistanceKm( madrid );
  float lat = fix_data.latitudeL(); // float value of latitude
 // Serial.print("Latitude:  ");Serial.println(lat,0);
  Serial.print("Latitude:  ");Serial.println(fix_data.latitudeL());
  Serial.print("DistanceKm to Llangefni:  ");Serial.println(fix_data.location.DistanceKm( llange ));
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

I'm now trying to increase the resolution by one more digit as I'm intending to work to very small distances. How would I increase the resolution from 10 digits to 11? ..... Thanks again!

-dev

Quote
I'm now trying to increase the resolution by one more digit as I'm intending to work to very small distances. How would I increase the resolution from 10 digits to 11?
10 significant digits is the limit.  That allows you to distinguish two points 1cm apart.  Your GPS isn't even close to being that accurate... 10m is common, 3m on a good day.

BTW, the llange location has room for 3 more digits.
Really, I used to be /dev.  :(

TegwynTwmffat

I'm getting much better results than 3m - maximum deviation over 8 hours is 200mm and most of the time it's working to about 40mm overall deviation.

I'm using the base and rover setup so the main sources of GPS errors are corrected. Here's my write up of the results:

https://hackaday.io/project/21744-weedinator/log/60618-more-ublox-m8p-tests

It would be useful for me to have one extra digit - is there absolutely no way to do this at all?  :smiley-sad:

-dev

Image embedded for our convenience:



Technique described here.

Quote
the main sources of GPS errors are corrected
Ah, very nice.  A little different from the typical setup we see here.  Interesting project!

Quote
It would be useful for me to have one extra digit - is there absolutely no way to do this at all?
The GPS device isn't providing the information for that digit.  Look at the u-center display: it shows "52.40242533".  That looks like 11 significant digits (hundreds == 0), but it' actually only 10 significant digits.  The last "3" is the repeated remainder from converting fractional minutes (NMEA format DDDMM.mmmmm) to decimal degrees.  NeoGPS correctly reports "524024253".

The same is true for the lon: "-4.24079550", last "0" is the remainder, and NeoGPS reports "42407955".

FWIW, NeoGPS uses the remainder to round the 10th significant digit properly.

Another way to look at this: read the description of the binary UBX NAV-POSLLH message (Section 31.18.13).  The lat/lon is provided in a 32-bit integer, as degrees * 1e7.  That's 10 significant digits.

Needing one more digit requires a few more bits, and now you've stepped across the 32-bit integer size.  Things get messy real quick.  However...

There is a binary message that provides 2 more digits: see the NAV-HPPOSLLH binary message, Section 31.18.9 on page 300.  It still provides the 10 significant digits in a 32-bit integer, but it adds 2 extra fields with (-99..+99) in a byte (8 more bits).  Adding the message to NeoGPS is not too difficult, but it's a significant effort to use them correctly in Distance and Bearing calculations.  If you're just comparing lat and lon values, it would be much easier.

Are you recording the location of the plants to that precision?  If not, these digits are useless. 

After a quick look at that project, I wondered if you are sending the raw NMEA data over the air?  If you are, you can get much better results by sending the parsed information.  That would be 10x-80x fewer bytes. 

I don't know, 4cm seems pretty good.  I would hope the CV part does the rest. 

Cheers,
/dev
Really, I used to be /dev.  :(

romel

I have one Neo M8N and i try to use it to give me lat, long, time, speed and heading for an sail -meter . I use the NMEAsimple.ino to display the data and it works. When i try to add the  fix.valid.heading and DEBUG_PORT.print( fix.heading(),3 ) any data was print on serial.

BTW when i write argument heading this is not in red colour like altitude or longitude.

1.I enable in NMEAGPS_cfg.h the lines

#define NMEAGPS_PARSE_RMC
#define NMEAGPS_PARSE_VTG

2. I enable #define GPS_FIX_HEADING in GPSfix.cfg

3. Into the sentence of NMEA , the heading place is empty  like    , ,       not even 0

Please -dev , some more ideas ? :)

Go Up