GPS options for ATMega32u4 boards?

Post Reply
humblehacker
Posts: 46
Joined: Thu Aug 07, 2014 6:40 pm

GPS options for ATMega32u4 boards?

Post by humblehacker »

Hello,
I know there are more than enough topics on GPS already, but its tough to filter out which issues have been resolved in recent releases.

So here goes- I'm working on two different airframes. One a Flying Wing and the other a more traditional QuadX. It looks like I have enough components lying around to use 2 out of 4 flight controller configurations.

    *HobbyKing NanoWii with Spektrum Satellite
    *Classic Pro Mini+HK+NC
    *Pro Mini+MPU6050
    *Micro Leonardo Clone + MPU6050

Figuring out the pinouts for Flying Wing mode on the NanoWii has been a challenge, so I might as well use the NanoWii for the QuadX and one of the others for the wing. That leaves the GPS connections as my next big challenge... As it stands I have two different GPS receiver/breakouts that I've reliably used on my Arduino projects. The solid MTK3339 (AKA Adafruit Ultimate GPS) and the super tiny GP-2106 from Sparkfun.

Of course, I"ve always accessed these modules through the serial port, but it only recently dawned on me that MultiWii requires a much higher refresh rate than serial provides. So what are my options for using the MTK3339 with my setup? Do I still need to use a seperate i2C module on top of what I already have? If so, would it be possible to "roll my own" using an ATTiny85 (aka Adafruit Trinket) as the i2C slave device? Or if I still have to order an additional GPS/NAV board, how well do they work with the ATMega32u4?

I'm sorry if my questions seem to be all over the place, but there are so many variables to my setup that I found it might be best to make one post about it, rather than try to pull information from a bunch of possibly outdated sources.

Thank You Very Much!

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: GPS options for ATMega32u4 boards?

Post by haydent »

so yeah, if you aint go the spare serial port as is often the case on the little boards for a gps you need an i2c adapter (slave arduino) like this: http://www.dx.com/p/i2c-gps-nav-module- ... AkId2PKpOI

i think gps can be used on serial 0 though...

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: GPS options for ATMega32u4 boards?

Post by QuadBow »

Due to my experience, you can't compile the sketch with i2c_gps enabled because of the 32U4's size limitations.
In this forum, there is described how to save some bytes by disabling the USB function.
But, latest with the next release including waypoint navigation you will regret having just an 32U4.
It is time to move towards an Mega2560!

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: GPS options for ATMega32u4 boards?

Post by haydent »

it can run with i2c_gps, though i too highly recommend nothing less that mega unless you are space/weight restricted, though there's not much in it

humblehacker
Posts: 46
Joined: Thu Aug 07, 2014 6:40 pm

Re: GPS options for ATMega32u4 boards?

Post by humblehacker »

Its starting to look like GPS might be a tad too much I guess... In my experience, anything I would've needed extra HW Serial in Mega2560 I could manage using software serial in 32u4. But if the issue is one of size limitations then wouldn't it make more sense to move up to 32 Bit?
Per the i2c adapter- Isn't there a way to roll your own using something like an ATTiny85? Or does it involve a lot more than programming another board as a slave?

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: GPS options for ATMega32u4 boards?

Post by haydent »

mega has more than enough space. 32bit has more processing power, though mega has enough too.
here is sketch's for 32u4 based board that uses i2c gps: https://www.multiwiicopter.com/product_ ... etches.zip
software serial is no good, as is blocking, and will likely be bad for your loop time. the i2c adapter is essentially a that. just another 32u4 that takes serial data on its comport from gps and outputs it to i2c stream for fc.

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: GPS options for ATMega32u4 boards?

Post by QuadBow »

humblehacker wrote:Per the i2c adapter- Isn't there a way to roll your own using something like an ATTiny85? Or does it involve a lot more than programming another board as a slave?
An ATTiny might be too weak, since it is missing the hardware multiplier and you need to rewrite a lot in order to fit into the memory. The sketch https://code.google.com/p/i2c-gps-nav/ requires an 168p at least. An 328p is the version which is recommended and which is available for a few bucks/euro, seearch for i2c-gps-nav.

humblehacker
Posts: 46
Joined: Thu Aug 07, 2014 6:40 pm

Re: GPS options for ATMega32u4 boards?

Post by humblehacker »

I just noticed that Adafruit came out with something called the "Pro Trinket"- http://www.adafruit.com/products/2000. Apparently, its just like a Pro Mini only with onboard USB and more pins. Of course then it just dawned on me that I could just use my Pro-Mini as a slave and my Micro as the main controller.

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: GPS options for ATMega32u4 boards?

Post by haydent »

http://www.dx.com/p/i2c-gps-nav-module- ... AkId2PKpOI

this design is available widely online

humblehacker
Posts: 46
Joined: Thu Aug 07, 2014 6:40 pm

Re: GPS options for ATMega32u4 boards?

Post by humblehacker »

I probably should've mentioned that the project parameters specify using as many off-the-shelf, interchangeable components as possible while limiting purpose-built UAV parts. Part of which was a major reason for going with MultiWii in the first place. Otherwise, I'd definitely just spring for one of the gps-nav boards. Especially considering they seem to cost less than a stand along GPS RX anyway!
So my options seem to be to see how much I can squeeze out of a standard Arduino (or multiple arduinos if need be.)
In any case, I can probably get along fine without GPS for the time being. So I've got plenty of room for experimentation.

humblehacker
Posts: 46
Joined: Thu Aug 07, 2014 6:40 pm

Re: GPS options for ATMega32u4 boards?

Post by humblehacker »

I'm going to try connecting my MTK3339 GPS to my Pro Mini per suggestions made on this thread- viewtopic.php?f=15&t=4163

Connections would roughly look like this-
Image

Though my Pro Mini clone has a slightly different pinout and I'm not actually using an Arduino Micro for my controller but rather a new 32u4 based board called the "Lil'Nardo". For which the pinout is actually as follows-
Image

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: GPS options for ATMega32u4 boards?

Post by haydent »

You could use mini or micro for both

humblehacker
Posts: 46
Joined: Thu Aug 07, 2014 6:40 pm

Re: GPS options for ATMega32u4 boards?

Post by humblehacker »

Now that I"m wrapping up most of the initial configurations for my MW build, its getting closer to decision time for GPS... As I mentioned earlier, I'm trying to avoid purpose-built electronics like the Crius MW-GPS-NAV adapter (even if the up front cost is lower) so as to use as many common components as possible.
So that pretty much leaves the i2C-GPS-NAV library as my only option. I've got my choice of any number of Mega-328s/32u4 boards to use as the slave device, but I figure I'll try the Pro-Mini clone first, since it was the cheapest. For GPS receivers, I have three choices. It would be great if I could use the GP-2106 from Sparkfun, (https://www.sparkfun.com/products/10890) as its still one of the lightest and smallest options available. I'm guessing however, that the capabilities of this module are somewhat limited and probably won't be up to the challenge. So that leaves the GTK3999 module for which I have two breakout options. One is meant for use in wearable applications in the form of the Adafruit Flora GPS (https://www.adafruit.com/products/1059) while the other is included in Adafruits Ultimate GPS Breakout (https://www.adafruit.com/products/746). The latter board has been my go-to GPS/RX because of powerful features like its built-in flash memory with datalogging capability and its 5V tolerant VIN. So my initial inclination would be to use this board. However, further reading of the i2c-GPS-NAV library (https://code.google.com/p/i2c-gps-nav/) implies the firmware of the GPS module itself needs to be replaced, in addition to programming the i2C slave device.
So my question is this- Will the i2c-GPS-NAV firmware completely erase the features programmed by Adafruit? If so, it might make more sense just to purchase a generic GTK3999 module without all the additional breakout connections added by Adafruit.
I'm also somewhat surprised to find the i2C-GPS-NAV library hasn't been updated since 2012 (https://code.google.com/p/i2c-gps-nav/downloads/list). Is this really the most up-to-date code available or is there a better resource I'm missing? Has it even been tested with recent versions of MultiWii?

humblehacker
Posts: 46
Joined: Thu Aug 07, 2014 6:40 pm

Re: GPS options for ATMega32u4 boards?

Post by humblehacker »

Something tells me there's got to be an easier way of doing this!? The following method appears to be the closest I"ve found for changing the update rate to 10Hz, along with the Baud rate and NMEA output (necessary for i2C transmission)...
http://www.camelsoftware.com/firetail/blog/electronics/adafruit-ultimate-gps-update-rate/

The Adafruit Ultimate GPS is marketed at being capable of providing 10Hz updates. By default, it does only 1Hz updates. It took me a while to work this one out, and I see this question posted around the internet quite a lot. So I thought I’d share the secret.
If you go reading through the list of PMTK commands, you’ll find one called PMTK_SET_NMEA_UPDATERATE. That’s what you’re after.
To set it to 10Hz, you must write this command
“$PMTK220,100*2F\r\n”
You will now get an ACK back from the GPS to confirm that the command was received OK.
$PMTK001,220,2*15 is probably what you’re going to receive. Notice the 2 in bold? That means it failed! That’s a perfectly legitimate command, so why did it fail?
Apparently the GPS module is smart enough to know that at 9600 baud, a 10Hz update rate will produce more data than the serial port can handle. The trick is to either reduce the number of NMEA sentences being transmitted (chances are you don’t need all of them) or increase the baud rate.
This command changes the baud rate to 38400 baud.
“$PMTK251,38400*27\r\n”


This snippet of code shows typical usage of this command in Arduino.
//switch the GPS baud rate to 38400
Serial1.write("$PMTK251,38400*27\r\n");
//change baud rate of serial port to 38400
Serial1.flush();
delay(10);
Serial1.end();
Serial1.begin(38400);

This command turns off all NMEA messages except VTG, GGA and GSA. GSA is only sent once every five transmissions.
“$PMTK314,0,0,1,1,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0*2D\r\n”
After sending those commands to the GPS, it is possible to turn on 10Hz update rate.
“$PMTK220,100*2F\r\n”
And this time you’ll get
$PMTK001,220,3*30
Success!


Still, this seems like something that could be automated with something like a Python utility... If I find the time to update the i2C-GPS-NAV code and post on Github, would anybody be interested?

humblehacker
Posts: 46
Joined: Thu Aug 07, 2014 6:40 pm

Re: GPS options for ATMega32u4 boards?

Post by humblehacker »

I might have just discovered a major bump in the road.... According to this thread- viewtopic.php?f=8&t=649&start=1700, the i2c-gps-nav code has been discontinued!!! I don't know if this means that the i2c protocol is no longer supported by MW or if theres a better library or what... But I seem to be back at square one...

Crazy Professor
Posts: 2
Joined: Wed Sep 24, 2014 1:12 pm

Re: GPS options for ATMega32u4 boards?

Post by Crazy Professor »

Does anyone know if this GPS will fit on this Board??
Attachments
GPS Front.jpg
GPS Back.jpg
Screen Shot 2014-11-05 at 12.45.36 pm.png

Post Reply