GPS has become an efficient tool in the field of scientific use, commerce, surveillance and tracking. This project presents a small application based on Global Positioning System. It depicts the use of GPS module/receiver to find latitude and longitude of its location. The data obtained from GPS receiver (GPGGA sentence) is processed by the microcontroller to extract its latitude and longitude values.
The GPS Module has been interfaced with AT89C51 and the location values are displayed on a 16x2 LCD interface.
The GPS Module has been interfaced with AT89C51 and the location values are displayed on a 16x2 LCD interface.
The GPS module continuously transmits serial data (RS232 protocol) in the form of sentences according to NMEA standards. The latitude and longitude values of the location are contained in the GPGGA sentence (refer NMEA format). In this program, these values are extracted from the GPGGA sentence and are displayed on LCD.
The serial data is taken from the GPS module through MAX232 into the SBUF register of 8051 controller (refer serial interfacing with 8051). The serial data from the GPS receiver is taken by using the Serial Interrupt of the controller. This data consists of a sequence of NMEA sentences from which GPGGA sentence is identified and processed.
The extraction of location values is done as follows. The first six bytes of the data received are compared with the pre-stored ($GPGGA) string and if matched then only data is further accounted for; otherwise the process is repeated again. From the comma delimited GPGGA sentence, latitude and longitude positions are extracted by finding the respective comma positions and extracting the data. The latitude and longitude positions extracted are displayed on the LCD interfaced with AT89C51.
To obtain more details (other than latitude and longitude) from the GPS receiver, GPRMS sentence can be used. Refer next article.
The circuit connections are as follows:
Receiver1 (R1) of MAX232 has been used for the serial communication. The receiver pin of GPS module is connected to R1IN (pin13) of MAX232. R1OUT (pin 12) of MAX232 is connected to RxD (P3.0) of AT89C51.
Pins 1-3 of port P1 (P1.0, P1.1 & P1.2 respectively) of AT89C51 are connected to the control pins (RS, R/W& EN) of LCD. The data pins of LCD are connected to Port P2 of the controller. The latitude and longitude positions are displayed on the LCD.
Project Source Code
###
/* Basic program to show latitude and longitude on LCD extracted from GPGGA statement */
#include<reg51.h>#define port2 P2sbit rs = P1^0;sbit rw = P1^1;sbit e = P1^2;char info[70];char test[6]={"$GPGGA"};char comma_position[15];unsigned int check=0,i;unsigned char a;void receive_data();void lcd_latitude();void lcd_longitude();//DELAY FUNCTIONvoid delay(unsigned int msec){int i,j ;for(i=0;i<msec;i++)for(j=0;j<1275;j++);}// LCD COMMAND SENDING FUNCTIONvoid lcd_cmd(unsigned char item){port2 = item;rs= 0;rw=0;e=1;delay(1);e=0;return;}// LCD DATA SENDING FUNCTIONvoid lcd_data(unsigned char item){port2 = item;rs= 1;rw=0;e=1;delay(1);e=0;return;}// LCD STRING SENDING FUNCTIONvoid lcd_string(unsigned char *str){int i=0;while(str[i]!='