Hey Dan!
Well, I own a couple of the EM-406 receivers and they are very easy to use. Just apply power to the Vcc pin and ground to Vdd pins and voila the module will start outputing NMEA 0183 data. You said you already know how to use the uarts on your microcontroller, so just connect the Tx pin of the GPS module to the Rx of the micro and thats it. Just make sure your micro's serial ports are running at 4800 baud. The GPS module doesn't have a I2C interface so you should be fine. The only tricky part now is writing code to parse the NMEA string and get the data you want. Here's some easy code that I use in my projects that I got from the Ghetto GPS Project website
http://www.mhd.miun.se/~stok/ghetto-gps/ with
some modification:
Code: Select all#include <8051.h> // put your micro's header file here
#include <string.h>
#include <stdlib.h>
static char receivebuffer[44]; // buffer to hold the NMEA string
uchar idx = 0;
uchar temprec;
int i;
//structure to hold the latitude and longitude
struct nmea_gps_data{
char latitude[9];
char longitude[10];
};
void nmea_gprmc_parse(char *line)
{
//here im finding the $GPRMC string but you can change it to look for other sentences
if(line[0] == '$' && line[1] == 'G' && line[2] == 'P')
{
if(line[3] == 'R' && line[4] == 'M' && line[5] == 'C') // GPRMC
{
// copy the longitude and latitude values in the structure variables
memcpy(gps_data.latitude, line+20, sizeof(gps_data.latitude));
memcpy(gps_data.longitude, line+32, sizeof(gps_data.longitude));
}
}
}
// this interrupt just keeps reading data from the GPS module continuously
// since your using a atmega chip youll have to change what interrupts or just put a receive function in a while loop in your main function
void ser_rec(void) interrupt 4 using 1{
if(RI)// this bit flag is set when a byte has been received
{
// change the SBUF varible to whatever variable your micro stores the incoming bytes from
temprec = SBUF;
// once we find the end of a string send it to the parser function above to see if its
the sentence we want
if(temprec != '\n')
{
receivebuffer[idx++] = temprec;
} else {
idx = 0;
// found a sentence now parse it
nmea_gprmc_parse(receivebuffer);
}
RI = 0;
}
}
Well I hope that code helps you a little. I'm sure you'll have to do some modification on it to fit your project but it shouldn't be much. Let us know how your project goes. Later, Caleb