Aim:
A global positioning system (GPS) receiver is used to get precise geographical location by receiving information from satellites. It not only gives information about location but also information like time, date, height and speed. It is so useful that most smartphones are embedded with it.
Description:
GPS receivers have many applications in aircraft, ships, sea vessels and the like for navigation purposes. Smartphones with maps (like Google Maps) find routes to a specific destination such as a restaurant, hospital or hotel. With the help of a GPS, a target camp can be located and a missile launched to destroy it.
The GPS receiver module includes an antenna and a built-in processor. The built-in processor calculates the required information from the signals’ output serially in form of strings using NMEA (expanded as National Marine Electronics Association) 0183 protocol. These strings are received serially by the host computer for display or by host processor/controller to take any decision or action.
NEMA protocol includes standard messages given by the GPS receiver. Some standard message outputs from NMEA are GGA, ZDA, VTC, RMC, GSA and GSV. The string starts with $GPRMC tag and gives time, latitude, longitude, etc.
Block Diagram
Schematic
Code
// ***************************************************
// Project: Interfacing GPS module with atmega8
// Author: Hack Projects India
// Module description: Operate GPS
// ***************************************************
#include<p18f4520.h>
#pragma config OSC=HS, FCMEN=ON, WDT=OFF, IESO=OFF, XINST=OFF, LVP=OFF
void txd(unsigned char ch);
unsigned char rxd();
unsigned char LATITUDE[15];
unsigned char LONGITUDE[15];
void USART_Init()
{
SPBRG =0x19; // 9600 bps at XTA=4MHZ
TXSTA=0X24; // Transmission part enable
RCSTA=0x90; // Receiving part enable
}
void txd(unsigned char ch)
{
TXREG=ch; // Character send through transmission register
while(!PIR1bits.TXIF); // Upto transmitting character
}
unsigned char rxd()
{
while(!PIR1bits.RCIF); // Upto receiving character
return RCREG; // Return the character to main
}
void Tx_String(char *str)
{
while(*str)
{
txd(*str);
str++;
}
}
void GPS_Receive()
{
unsigned int k=6,d=0,y=0,i=0,l=6,z=1,b,a=0,c=0,Temp=0;
while(rxd()=='$')
{
if(rxd()=='G')
{
if(rxd()=='P')
{
if(rxd()=='R')
{
if(rxd()=='M')
{
if(rxd()=='C')
{
while(rxd() != ',');
while(rxd() != ',');
if(rxd()=='V')
{
while( rxd() != ',');
Temp = 0;
a=0;
i=0;
while(Temp != ',')
{
Temp = rxd();
if(Temp != ',')
{
LATITUDE[i++] = Temp;
}
else
{
a=rxd();
LATITUDE[i++]=a;
LATITUDE[i] = '\0';
}
}
while( rxd() != ',');
Temp = 0;
a=0;
i=0;
while(Temp != ',')
{
Temp = rxd();
if(Temp != ',')
{
LONGITUDE[i++] = Temp;
}
else
{
a=rxd();
LONGITUDE[i++]=a;
LONGITUDE[i] = '\0';
}
}
Tx_String("LATI:");
Tx_String(LATITUDE);
txd('\r');
Tx_String("LONG:");
Tx_String(LONGITUDE);
txd('\r');
}
else
{
Tx_String("NOT IN CVRG AREA");
txd('\r');
}
}
}
}
}
}
}
}
void main()
{
char c;
ADCON1=0b00001111;
USART_Init();
while(1)
{
GPS_Receive();
}
}
Downloads:
The code was compiled in Keil uvision4 and simulation was made in Proteus v7.7.
To download code and proteus simulation click here.
Further Reading suggestions:
You may also like,
- Interfacing keypad with PIC
- Interfacing with UART of PIC controller
- Interfacing SPI communication with PIC
- PIC Displaying Custom Characters on LCD
- PIC Graphical LCD
- RTC interfacing using I2C in PIC
- Interfacing ultrasonic sensor with PIC
- Interfacing GPS Modu with PIC
- Interfacing GSM Module with PIC
- Interfacing PWM in PIC
- Interfacing ADC with PIC
- Scrolling string on LCD using PIC
- Interfacing keypad with PIC
- Interfacing with UART of PIC controller
- Interfacing SPI communication with PIC
- PIC Displaying Custom Characters on LCD
- PIC Graphical LCD
- RTC interfacing using I2C in PIC
- Interfacing ultrasonic sensor with PIC
- Interfacing GPS Modu with PIC
- Interfacing GSM Module with PIC
- Interfacing PWM in PIC
- Interfacing ADC with PIC
- Scrolling string on LCD using PIC
No comments:
Post a Comment