This project is an extension to interfacing GPS with 8051. Here the microcontroller interfaced with GPS module is used to obtain latitude, longitude, time, date and speed of the receiver. These received values are displayed on a 16x2 character LCD.
The GPS module continuously transmits serial data (RS232 protocol) in the form of sentences according to NMEA standards. The latitude, longitude, time, date and speed values of the receiver are contained in the GPRMC sentence as given in the following example (also refer NMEA format for other sentences). In this project, these values are extracted from the GPRMC sentence and are displayed on LCD.
Example : $GPRMC,132455.970,A,2651.0145,N,07547.7051,E,0.50,342.76,301010,,,A*64
where:
RMC
132455.970
A
2651.0145, N
07547.7051, E
0.50
342.76
301010
Empty field (xxx.x, y)
*64
|
Recommended Minimum sentence C
Fix taken at 13:24:55.970 UTC
Status A=Active or V=Void.
Latitude 26 deg 51.0145′ N
Longitude 075 deg 47.7051′ E
Speed over the ground in knots
Track angle in degrees True
Date : 30th of October 2010
Magnetic Variation
The checksum data, always begins with *
|
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 GPRMC sentence is identified and processed.
The extraction of required values is done as follows. The first six bytes of the data received are compared with the pre-stored ($GPRMC) string and if matched then only data is further accounted for; otherwise the process is repeated again. From the comma delimited GPRMC sentence, latitude, longitude, date, time, speed values are extracted by finding the respective comma positions. The values thus extracted are displayed on the LCD interfaced with AT89C51.
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
###
/* Program to display time date,latitude,longitude,speed on LCD by extracting the GPRMC... ...statement sent by GPS receiver*/ #include<reg51.h> #define port2 P2 sbit rs = P1^0; sbit rw = P1^1; sbit e = P1^2; char info[70]; char test[6]={"$GPRMC"}; char comma_position[13]; unsigned int check=0,i; unsigned char a; void receive_data(); void lcd_time(); void lcd_latitude(); void lcd_longitude(); void lcd_speed(); void lcd_date(); //DELAY FUNCTION void delay(unsigned int msec) { int i,j ; for(i=0;i<msec;i++) for(j=0;j<1275;j++); } // LCD COMMAND SENDING FUNCTION void lcd_cmd(unsigned char item) { port2 = item; rs= 0; rw=0; e=1; delay(1); e=0; return; } // LCD DATA SENDING FUNCTION void lcd_data(unsigned char item) { port2 = item; rs= 1; rw=0; e=1; delay(1); e=0; return; } // LCD STRING SENDING FUNCTION void lcd_string(unsigned char *str) { int i=0; while(str[i]!='