jump to navigation

Adding a 3.3v GPS to a 5v AVR Atmega32 04/06/2009

Posted by aliasmrjones in The Build.

So the maiden voyage of Deathpod3000 was a disaster.  The problems seemed to be twofold.  One, gps updates were too slow and two and probably most importantly, heading info coming from the gps was way too slow to be useful in turns.  The net result was that it mostly drove around in circles.  I decided to add a gps with a faster refresh rate and a digital compass.  In this installment, I’ll add the gps.  The main issue I had to deal with is the gps is 3.3v and the rest of the electronics are 5v…

After looking at available options, I settled on the Locosys LS20031 5hz gps receiver.  It is a self-contained unit, complete with antenna.  It outputs nmea and I already have an nmea parser library.  The only connections required are power, ground and serial tx/rx.  After doing some research, the only problem to overcome was the 3.3v to 5v conversion required.

Sparkfun sells a 3.3v to 5v logic level converter board.  This little (and I mean little) board will convert tx/rx for 2 serial connections.  One side of the board takes 5v and the other takes 3.3v connections for power.  Tx/rx on the high side operates at 5v and the low side operates at 3.3v.  It worked like a charm.

The gps has no connectors, just pads to solder to so I soldered wires to the pads.  I decided to connect everything using a breadboard to make sure communication was working before doing the final wiring.  I used a 3.3v voltage regulator to supply the 3.3v, connected tx/rx on the low side to the gps and the high side to the tx/rx pins on the Atmega32.  Note that because the gps uses ttl serial I did not have to use an rs232 converter like I did with the Garmin unit.  That is why I am connecting directly to the pins on the microcontroller.

Here is a pic of the breadboard setup.  You can see the gps chip (large looking white/cream/green square – it is actually only about an inch square) to the right.  To the left you can barely see the logic level converter board buried in wires and just above and to the left of that the voltage regulator.

Locosys LS20031 GPS

The gps has a little light that is supposed to flash once per second if it has a lock.  I turned on the power and waited to see if I’d get “flashy lights”.

GPS Flashy Lights

All right, so the gps appears to be working.  To start I decided to connect it to the computer because it would be easier to debug communication problems when I can see the actual output and test various baud settings, etc.  After connecting things up I got…garbage.  The datasheet for the gps chip said by default it used 9600 bps.  Nope, after some experimentation I found by default it was spitting out data at 57,600 bps.  On the bright side, it seemed to be working perfectly.

There is a little program available for download on the sparkfun site here for another gps that I found works fine with the gps I bought as well.  It will show you how many sats it has locked, lat/long, settings, etc.  The nice thing is it will also let you set the parameters and save them to the chip.  I am only parsing 2 nmea sentences,  GGA and VTG, so I turned off all the others and set the unit for 5hz updates.

Sorry about the blurry pic, but you can at least see that it found satellites and is giving data to the program.  Everything looks great.

Happy GPS

Next, I connected the gps directly to the microcontroller pins and started getting lat/long readings just like before, except a lot faster.  I increased the size of the serial buffer in my uart library to allow for the faster serial speed.  I also decided to cut back to 2 updates per second, at least for now.  This is a huge improvement over 1 every 2 seconds and if I get everything else working and I can spare the cpu cycles, I will increase it later.

Next on the agenda is connecting the digital compass.  It uses i2c to communicate with the microcontroller.  We’ll have to add some more library code to deal with that and connect to some more pins.  We’ll cover that in the next post.



1. Skater_j10 - 04/17/2009

I am also using an Atmega32 for my robot design (just a hobby robot) but never conceived of added a GPS to the project. I was kinda intimidated by the technology and never really looked into to it, but after reading your post it now seems within reach. Thanks for sharing your findings, struggles, and ideas!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: