NMEA support

110 views
Skip to first unread message

Giulio Berti

unread,
May 14, 2012, 11:33:20 AM5/14/12
to uavde...@googlegroups.com
Hi All,
I don't know if it's interesting for someone, but I've Included the possibility to parse NMEA GGA & RMC, for those (like me) that don't own a GPS with binary protocol.
The code parse rmc1,2,3,4,5,6,7,8,9 and gga7,8,9 and doesn't check the checksum for code lightness.

If you want to give to it a try, add gpsParseNMEA.c in libDCM (and in your project), select 
#define GPS_TYPE                      GPS_NMEA
Add the following line to specify the expected BAUD at start-up, otherwise it will be 38400. (as I did here) #define DEFAULT_GPS_BAUD              57600

This should be all!

Please let me know if you have any thoughts/questions/suggestion!

Best wishes,

Giulio

Keith Merrill

unread,
May 14, 2012, 1:52:26 PM5/14/12
to uavde...@googlegroups.com
What is the baud rate a GPS receiver should be set to for the UDB4. I am using binary protocol.

Keith


From: Giulio Berti <giu...@gmail.com>
To: uavde...@googlegroups.com
Sent: Monday, May 14, 2012 9:33 AM
Subject: NMEA support

Peter Hollands

unread,
May 14, 2012, 3:38:57 PM5/14/12
to uavde...@googlegroups.com
Giulio,

Thank you very much for writing and sharing your GPS code with the UAV DevBoard community.
Quite a few people have wanted NMEA support in the past, and so it is good to see development in this direction.

Best wishes, Pete

ben levitt

unread,
May 14, 2012, 3:51:42 PM5/14/12
to uavde...@googlegroups.com
Yes, this is great!  I think though, that it would make sense to perform and test the checksum, similar to how we do for the other gps parsers, just to make sure we're using good data.  Better to skip an update than to use a value with a high bit flipped.

Ben

Peter Hollands

unread,
May 14, 2012, 3:52:42 PM5/14/12
to uavde...@googlegroups.com
Keith,

Generally speaking, if you buy a compatible GPS from DIY Drones.com or Sparkfun, then you do not have to setup any baud rates for the UDB4. The MatrixPilot firmware will set things up automatically to be correct.
The Wiki lists compatible GPS units on this page under Hardware.

I should not forget also that Nick Arsov is also developing the AGPS (Arsov GPS). I have just posted on another of his threads on uavdevboard to see if his AGPS has passed flight testing.

Best wishes, Pete

Giulio Berti

unread,
May 14, 2012, 9:04:58 PM5/14/12
to uavde...@googlegroups.com
Yes you are right! I'm working on it now.

Giulio

Giulio Berti

unread,
May 15, 2012, 1:08:04 AM5/15/12
to uavde...@googlegroups.com
Hi,
In revision 1508 I've added the check of the checksum!

Giulio

Huey

unread,
May 15, 2012, 11:29:25 AM5/15/12
to uavdevboard
Thanks Giulio,

perfect is the function that I've planned to develop but you have been
faster than me!!

Grazie giulio, fantastico, mi serviva proprio...

On 14 Mag, 17:33, Giulio Berti <giu...@gmail.com> wrote:
> Hi All,
> I don't know if it's interesting for someone, but I've Included the
> possibility to parse NMEA GGA & RMC, for those (like me) that don't own a
> GPS with binary protocol.
> The code parse rmc1,2,3,4,5,6,7,8,9 and gga7,8,9 and doesn't check the
> checksum for code lightness.
>
> If you want to give to it a try, add gpsParseNMEA.c<http://code.google.com/p/gentlenav/source/browse/branches/Matrixpilot...> in
> libDCM (and in your project), select
> #define GPS_TYPE                      GPS_NMEA
> Add the following line to specify the expected BAUD at start-up, otherwise
> it will be 38400. (as I did here<http://code.google.com/p/gentlenav/source/browse/branches/Matrixpilot...>

Giulio Berti

unread,
May 15, 2012, 12:32:15 PM5/15/12
to uavde...@googlegroups.com

You're welcome!
So, does someone tried it on the UDB4? Let me know if there are any problems or if something is not clear!

Giulio

Riccardo Kuebler

unread,
May 15, 2012, 2:19:14 PM5/15/12
to uavde...@googlegroups.com
Hi Giulio,

would this code work with a Venus GPS ?

I have seen it long time ago and was impressed by declared performances.
But the most interesting part for me would be to build a custom antenna, not having to use the usual patch.
I mean e.g. a cloverleaf circular polarized, which would improve reception in banked and inverted positions.

I don't know how much will be the benefit / loose, comparing gain loose  and angle of sight with this antenna vs. the (active) patch.
But it could be interesting to check, if there are not known issues to not recommend it.

Best regards,

Ric

2012/5/15 Giulio Berti <giu...@gmail.com>

Giulio Berti

unread,
May 15, 2012, 9:51:44 PM5/15/12
to uavde...@googlegroups.com

Hi Riccardo,

I've checked the datasheet and the code should work, it will ignore the "useless" messages and parse just gga & rmc. During the startup the code send some mtek commands that your GPS will ignore so it sends the default output.
You need to modify the default baud rate in options.h
You can modify the parameters of the GPS using the binary protocol, ie define a char array and send it.
If you need further help just ask!
It's interesting the idea of the cloverleaf! I've read somewhere that the reception performance of the skew planar are a little bit better, but I don't know if it's true.

Can I ask you a question? Do you follow any "tutorial" to build those antennas? There's a nice guide on rcexplorer.se under the diy tab :)

Anyway I didn't tried my code on the UDB4, let me know if works, also with an another GPS!

Best wishes,

Giulio

Sent from my Mobile phone

Riccardo Kuebler

unread,
May 16, 2012, 7:19:09 AM5/16/12
to uavde...@googlegroups.com
Hi Giulio,

thank you very much for your answer.

About antenna, you are probably right a skew planar could be better on reception side.

The gurus of those antennas are IBcrazy and Markus123.

IBcrazy started several threads on RCgroups about antennas :
skew planar
clower leaf

I discovered that Markus lives in Switzerland. So I asked him to build a couple of 5.8GHz antennas for video.
Tolerances are too close to let me try doing them myself. I don't have any tuning device.
I could try building a 1500MHz instead.

Btw, will the MatrixPilot navigation code work like with all the other GPS or could there be some issues ?

Un caro saluto,

Ric

2012/5/16 Giulio Berti <giu...@gmail.com>

Giulio Berti

unread,
May 16, 2012, 9:35:28 PM5/16/12
to uavde...@googlegroups.com

Hi,

This parser will parse every GGA received with the parameters (gga1 gga2 ecc..) sent in the standard order and the checksum must be after 14 commas. Same for the RMC but here the checksum must be after 12 commas.
I think this conditions are satisfied from every standard nmea message. So in theory this program should support every GPS that outputs at least gga & rmc.

Unfortunately every GPS engine supports its protocol for the configuration but if your GPS send gga & rmc by default this is not required. (it's better to disabled the unused strings to not load the cpu) You just have to set the correct baud rate in the define.

Hope this makes sense, it's early morning here and I still don't know who am I :)

Sent from my Mobile phone

Giulio Berti

unread,
May 17, 2012, 6:12:33 AM5/17/12
to uavde...@googlegroups.com
I did more test setting my GPS to its default options (GLL RMC VTG GSA GSV GGA @1Hz) and it's working fine, so I think also other gps will work with their standard output configuration.

R,
Giulio

Huey

unread,
May 29, 2012, 4:03:12 PM5/29/12
to uavdevboard
Hello Giulio,

I've tried to compile gpsParseNMEA.c but unfortunately I've an error
on the file deadReckoning.c


../../libDCM/deadReckoning.c:38: error: 'GPS_NMEA' undeclared here
(not in a function)
make[2]: *** [build/default/production/_ext/1077471063/
deadReckoning.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2


Really strange!!! obviously the error is not in deadReckoning.c

I use mplabx on macosx with c30 compiler

Any Idea?

Regards
Paolo




On May 14, 5:33 pm, Giulio Berti <giu...@gmail.com> wrote:
> Hi All,
> I don't know if it's interesting for someone, but I've Included the
> possibility to parse NMEA GGA & RMC, for those (like me) that don't own a
> GPS with binary protocol.
> The code parse rmc1,2,3,4,5,6,7,8,9 and gga7,8,9 and doesn't check the
> checksum for code lightness.
>
> If you want to give to it a try, add gpsParseNMEA.c<http://code.google.com/p/gentlenav/source/browse/branches/Matrixpilot...> in
> libDCM (and in your project), select
> #define GPS_TYPE                      GPS_NMEA
> Add the following line to specify the expected BAUD at start-up, otherwise
> it will be 38400. (as I did here<http://code.google.com/p/gentlenav/source/browse/branches/Matrixpilot...>

Peter Hollands

unread,
May 29, 2012, 4:43:41 PM5/29/12
to uavde...@googlegroups.com
Paolo,

It could be something to do with the following:-

Line 38 says:-
int dead_reckon_clock = DR_PERIOD ;

DR_PERIOD is defined further up the file as:-

#define DR_PERIOD (int)((40/GPS_RATE)+4 )

So that raises the question what is GPS_RATE ?
Well that is defined in libDCM_internal.h as:-

#define GPS_RATE            ((GPS_TYPE == GPS_MTEK) ? 4 : GPS_TYPE)

Now what that says is
if GPS_TYPE == GPS_MTEK then GPS_RATE is 4.
Otherwise GPS_RATE is actually the same as the GPS_TYPE, which is defined in libDCM_internal.h as:-

// Defines
// GPS Type
#define GPS_STD                1
#define GPS_UBX_2HZ            2
#define GPS_UBX_4HZ            4
#define GPS_MTEK            5


So for a GPS_STD, the GPS_RATE will be 1.

But what is interesting from your point of view is there is no GPS_NMEA.
Your GPS_TYPE will be GPS_NMEA, and the compiler will be looking for it,
to set the GPS_RATE.

So I think you will need to alter the coding at
#define GPS_RATE            ((GPS_TYPE == GPS_MTEK) ? 4 : GPS_TYPE)

If you are not sure what to do, then may be Matt or Robert could offer a thought.

Best wishes, Pete

Giulio Berti

unread,
May 29, 2012, 8:55:29 PM5/29/12
to uavde...@googlegroups.com
Hi Paolo, my fault! I forgot to mention to add a define line for the nmea parser.

Pete I think you are referring to libDCM_defines.h, and my code is

// Defines
// GPS Type
#define GPS_STD 1
#define GPS_UBX_2HZ 2
#define GPS_UBX_4HZ 4
#define GPS_MTEK 5
#define GPS_NMEA 6

#define GPS_RATE ((GPS_TYPE == GPS_MTEK) ? 4 : GPS_TYPE)

Hope this helps.. Let me know if there are other bugs or so :)

Best wishes,

Giulio

Peter Hollands

unread,
May 29, 2012, 11:06:11 PM5/29/12
to uavde...@googlegroups.com
Hi Guilio,

Yes, you are right, I meant libDCM_defines.h.

If your GPS updates at a rate of once per second, then you want to be sure that

GPS_RATE  is defined as   1
for your GPS.

From the code in your post, MatrixPilot will believe that the GPS_RATE is 6 times / second for  GPS_NMEA

That may well cause some mis-calculations. e.g. in terms of calculating GPS derived acceleration.

I think that section of code needs simplifying to something like (Note I have not compiled or tested the following):-


#define GPS_STD                      1
#define GPS_UBX_2HZ                  2
#define GPS_UBX_4HZ                  4
#define GPS_MTEK                     5
#define GPS_NMEA                     6

#if ( GPS_TYPE = GPS_STD)
#define GPS_RATE  1
#elif ( GPS_TYPE = GPS_UBX_2HZ )
#define (GPS_RATE 2)
#elif ( GPS_TYPE = GPS_UBX_4HZ )
#define (GPS_RATE 4)
#elif ( GPS_TYPE = GPS_MTEK )
#define (GPS_RATE 4)
#elif ( GPS_TYPE = GPS_NMEA )
#define (GPS_RATE 1) // Does GPS_NMEA update at 1 HZ ?
#else
#error("GPS_TYPE has no defined GPS_RATE")


Best wishes, Pete

Giulio Berti

unread,
May 29, 2012, 11:44:12 PM5/29/12
to uavde...@googlegroups.com
Hi Pete,
Thanks for the hint! I didn't figure it before... 
In hours I have to do an exam (Foundation of Electronics!) but in the next days I can work on it, I'll keep you updated here.

Regards,

Giulio

Huey

unread,
May 30, 2012, 3:20:31 AM5/30/12
to uavdevboard
Hi Pete and Giulio,

tonight when I come back home I'll try to recompile following your
hints.

It 'a shame that I was not able to find the bug by myself...


Paolo

Huey

unread,
Jun 2, 2012, 5:42:42 AM6/2/12
to uavdevboard
Hello,

the correct code to compile correctly the GPS rate section is:

// Defines
// GPS Type
#define GPS_STD 1
#define GPS_UBX_2HZ 2
#define GPS_UBX_4HZ 4
#define GPS_MTEK 5
#define GPS_NMEA 6



#if ( GPS_TYPE == GPS_STD)
#define GPS_RATE 1
#elif ( GPS_TYPE == GPS_UBX_2HZ )
#define GPS_RATE 2
#elif ( GPS_TYPE == GPS_UBX_4HZ )
#define GPS_RATE 4
#elif ( GPS_TYPE == GPS_MTEK )
#define GPS_RATE 4
#elif ( GPS_TYPE == GPS_NMEA )
#define GPS_RATE 1
#else
#error("GPS_TYPE has no defined GPS_RATE")
#endif


It's slightly different from the code posted by Peter, but only
because I've tried to compile it and found only syntax error.

Today i'll try with my nmea gps if it works correctly.

Paolo

Peter Hollands

unread,
Jun 2, 2012, 5:54:01 AM6/2/12
to uavde...@googlegroups.com

Looks good to me, Pete

Giulio Berti

unread,
Jun 2, 2012, 5:57:18 AM6/2/12
to uavde...@googlegroups.com
This evening I'll add this changes in my branch, Thanks!

Giulio

Giulio Berti

unread,
Jun 2, 2012, 6:44:52 AM6/2/12
to uavde...@googlegroups.com
Ok I just did it.

Paolo, please be sure to do a good test before flight, I'm still not sure at 100% about the conversions that I do between the NMEA and the Matrixpilot measurement units... Good luck!

Giulio

Huey

unread,
Jun 2, 2012, 3:43:21 PM6/2/12
to uavdevboard
No problem Giulio.

On the workbench for now all seem to be ok.
My gps is a Fasttrak 500, nmea protocol 9600 baud.

Next test with my car!!
Reply all
Reply to author
Forward
0 new messages