GPS stands for Global Positioning System and used to detect the Latitude and Longitude of any location on the earth, with exact UTC (Universe Time Coordinated) time. It is one of the global navigation satellite system (GSS) that provide geo-location and time information to a GPS receiver anywhere on or near the earth where is an unobstructed line of sight to four or more GPS satellites. The GPS module sends both fixed data and variable data. Our main function here to find the Latitude and Longitude; let’s look at the data that we received from the module-

Example: $GPGGA, 161229.487, 3723.2475N, 12158.3416W, 1, 07, 1.0, 9.0,M,-34.2,M,0000*18


Since we want to know the Latitude and Longitude, we only need $GPGGA – data. UART functions are available on UART library. We use ATmega8

Let’s first store only $GPGGA data-
void gps_system(void) -> store $GPGGA
void gps_system(void)
{
value=usart_getc();
if(value=='$')
{
value=usart_getc();
if(value=='G')
{
value=usart_getc();
if(value=='P')
{
value=usart_getc();
if(value=='G')
{
value=usart_getc();
if(value=='G')
{
value=usart_getc();
if(value=='A')
{
value=usart_getc();
if(value==',')
{
lat_long(); //filter setion
}
}
}
}
}
}
}
}
In the above function we enter into the $GPGGA fixed data. Now filter in and display it in the LCD display.
void lat_long(void)
{
filter=usart_getc();
GMT[0]=filter;
for(str_count=1;filter!=',';str_count++)
{
GMT[str_count]=usart_getc();
filter=GMT[str_count];
}
filter=usart_getc();
latitude[0]=filter;
for(str_count=1;filter!=',';str_count++)
{
latitude[str_count]=usart_getc();
filter=latitude[str_count];
}
filter=usart_getc();
latitude[str_count]=filter;
filter=usart_getc(); //nul char to remove char ,(0x2e)
filter=usart_getc(); //nul char to remove char ,(0x2e)
for(str_count=0;filter!=',';str_count++)
{
longitude[str_count]=usart_getc();
filter=longitude[str_count];
}
filter=usart_getc();
longitude[str_count]=filter;
LCD_write_string(1,1,latitude);
LCD_write_string(1,2,longitude);
}
The main program as follow-
/***********************************************************
************************************************************
** GPS System :$GPGGA-Global Positioning System Fixed data *
** GMT Time: Latitude: Longitude: ---: Altitude *
** *
***********************************************************/
#include<avr/io.h>
#include<util/delay.h>
#include<stdio.h>
#include"gsm.h"
#include"lcd.h"
int main(void)
{
gsm_init(); //USART initilize with timer
LCD_INIT();
DDRD|=(1<<4);
LCD_write_string(1,1,"Welcome");
_delay_ms(5000);
while(1)
{
if(min)
gps_system(); //data update every 5s
min?(PORTD|=(1<<4)):(PORTD&=~(1<<4));
}
return 0;
}







Visit Today : 49
Total Visit : 28464