GPS Receiver Using 8051 Micro Controller
GPS Receiver Using 8051 Micro Controller
Summary
Description
Circuit Diagram
Video
Code
Components
Summary
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.
Description:
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
Example :
$GPRMC,132455.970,A,2651.0145,N,07547.7051,E,0.50,342.76,301010,,,A*64
where:
*64
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
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
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
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.
CODE
//DELAY FUNCTION
void delay(unsigned int msec)
{
int i,j ;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}
void find_comma()
{
unsigned int i,count=0;
for(i=0;i<70;i++)
{
if(info[i]==',')
{
comma_position[count++]=i;
}
}
}
void compare()
{
IE=0x00;
find_comma();
lcd_time();
lcd_date();
lcd_latitude();
lcd_longitude();
lcd_speed();
check=0;
IE=0x90;
}
void lcd_latitude()
{
unsigned int c3=comma_position[2];
lcd_shape();
lcd_cmd(0x01); //Clear LCD display
lcd_cmd(0x84); //Move cursor to position 6 of
line 1
lcd_string("LATITUDE"); //Showing latitude
lcd_cmd(0xC0); //Begining of second line
lcd_data(info[c3+1]);
lcd_data(info[c3+2]);
lcd_data(0);
lcd_data(info[c3+3]);
lcd_data(info[c3+4]);
lcd_data(info[c3+5]);
lcd_data(info[c3+6]);
lcd_data(info[c3+7]);
lcd_data(info[c3+8]);
lcd_data(info[c3+9]);
lcd_data(0x27); //ASCII of minute sign(')
lcd_data(info[c3+10]);
lcd_data(info[c3+11]);
delay(250);
}
void lcd_longitude()
{
unsigned int c5=comma_position[4];
lcd_cmd(0x01); //Clear LCD display
lcd_cmd(0x84); //Move cursor to position 4 of
line 1
lcd_string("LONGITUDE"); //Showing longitude
lcd_cmd(0xC0); //Begining of second line
lcd_data(info[c5+1]);
lcd_data(info[c5+2]);
lcd_data(info[c5+3]);
lcd_data(0);
lcd_data(info[c5+4]);
lcd_data(info[c5+5]);
lcd_data(info[c5+6]);
lcd_data(info[c5+7]);
lcd_data(info[c5+8]);
lcd_data(info[c5+9]);
lcd_data(info[c5+10]);
lcd_data(0x27); //ASCII of minute sign(')
lcd_data(info[c5+11]);
lcd_data(info[c5+12]);
delay(250);
}
void lcd_speed()
{
unsigned int c6=comma_position[6], c7=comma_position[7];
lcd_cmd(0x01); //Clear LCD display
lcd_cmd(0x80); //Move cursor to
position 5 of line 1
lcd_string("SPEED(inKNOTS)"); //Showing longitude
lcd_cmd(0xC0); //Begining of second
line
for(i=c6+1;i<c7;i++)
{
lcd_data(info[i]);
}
lcd_string("KNOTS");
delay(250);
}
void lcd_date()
{
unsigned int c9=comma_position[8];
lcd_cmd(0x01); //Clear LCD display
lcd_cmd(0x85); //Move cursor to position 5 of
line 1
lcd_string("DATE");
lcd_cmd(0xC0);
lcd_data(info[c9+1]);
lcd_data(info[c9+2]);
lcd_data('-');
lcd_data(info[c9+3]);
lcd_data(info[c9+4]);
lcd_data('-');
lcd_data(info[c9+5]);
lcd_data(info[c9+6]);
delay(250);
}
void main()
{
serial();
lcd_cmd(0x38); //2 LINE, 5X7 MATRIX
lcd_cmd(0x0e); //DISPLAY ON, CURSOR BLINKING
IE=0x90;
while(1)
{
if(check==69)
compare();
}
}