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 LPC2148 // Author: Hack Projects India // Module description: Operate GPS // *************************************************** #include <stdio.h> /* prototype declarations for I/O functions */ #include <LPC214x.H> /* LPC21xx definitions */ #define CR 0x0D int uart1_rx(void); void uart1_init (void); void uart1_putc (char); void uart1_puts (char *); void gps_data(void); unsigned char a[15],i,j,k=0,l; unsigned char x,y[20],y1[20],v1; unsigned char sdata[15],a1[]="$GPRMC,123519,A,4807.038,N,123.9899,"; void delay(int count) { int j=0,i=0; for(j=0;j<count;j++) { for(i=0;i<6000;i++); } } /* implementation of putchar (also used by printf function to output data) */ int sendchar (int ch) { /* Write character to Serial Port */ if (ch == '\n') { while (!(U1LSR & 0x20)); U1THR = CR; /* output CR */ } while (!(U1LSR & 0x20)); return (U1THR = ch); } int uart1_rx (void) { /* Read character from Serial Port */ while (!(U1LSR & 0x01)); return (U1RBR); } void uart1_init() { /* initialize the serial interface */ PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */ U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ U1DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */ U1LCR = 0x03; /* DLAB = 0 */ } //------------------------------------------------------------------------------------------------// //---------------------------- Function for send character 1 time via UART1-----------------------// //------------------------------------------------------------------------------------------------// void uart1_putc(char c) { while(!(U1LSR & 0x20)); // Wait until UART1 ready to send character U1THR = c; // Send character } //------------------------------------------------------------------------------------------------// //---------------------------- Function for send string via UART1---------------------------------// //------------------------------------------------------------------------------------------------// void uart1_puts(char *p) { while(*p) // Point to character { uart1_putc(*p++); // Send character then point to next character } } //------------------------------------------------------------------------------------------------// //---------------------------- Function for Initial UART0 ----------------------------------------// //------------------------------------------------------------------------------------------------// void uart_init() { /* initialize the serial interface */ PINSEL0 = 0x00050005; /* Enable RxD0 and TxD0 */ U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ U0DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */ U0LCR = 0x03; /* DLAB = 0 */ } //------------------------------------------------------------------------------------------------// //---------------------------- Function for send character 1 time via UART0-----------------------// //------------------------------------------------------------------------------------------------// void gps_data() { x=uart1_rx(); if(x=='$') //check for string $GPRMC { x=uart1_rx(); if(x=='G') { x=uart1_rx(); if(x=='P') { x=uart1_rx(); if(x=='R') { x=uart1_rx(); if(x=='M') { x=uart1_rx(); if(x=='C') { while(uart1_rx()!=','); while(uart1_rx()!=','); //wait untill receive , x=uart1_rx(); if(x=='A') //check A { x=uart1_rx(); //receive , if(x==',') { v1=0; //store values between , to , in y[],these are lattitude values while((y[v1++]=uart1_rx())!=','); y[v1-1]='\0' ; v1=0; while(uart1_rx()!=','); //wait untill receive , //store values between , to , in y1[],these are LONGITUDE values while((y1[v1++]=uart1_rx())!=','); y1[v1-1]='\0' ; for(v1=0;v1<8;v1++) { uart1_putc(y[v1]); //display lattitude values } uart1_putc('\r'); for(v1=0;v1<8;v1++) { uart1_putc(y1[v1]); //display LONGITUDE values } } } } } } } } } } /****************/ /* main program */ /****************/ int main (void) { /* execution starts here */ // Initialize UART1 uart1_init(); while(1) /* An embedded program does not stop */ { gps_data(); } }
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 ARM(LPC2148)
- nterfacing DAC with ARM(LPC2148)
- Interfacing with UART of ARM(LPC2148) controller
- Interfacing SPI communication with PIC
- ARM(LPC2148) Displaying Custom Characters on LCD
- RTC interfacing using I2C in ARM(LPC2148)
- Interfacing Graphical LCD with ARM(LPC2148)
- Interfacing ultrasonic sensor with ARM(LPC2148)
- Interfacing GSM Module with ARM(LPC2148)
- Interfacing PWM in ARM(LPC2148)
- Interfacing ADC with ARM(LPC2148)
- Scrolling string on LCD using ARM(LPC2148)
- Interfacing keypad with ARM(LPC2148)
- nterfacing DAC with ARM(LPC2148)
- Interfacing with UART of ARM(LPC2148) controller
- Interfacing SPI communication with PIC
- ARM(LPC2148) Displaying Custom Characters on LCD
- RTC interfacing using I2C in ARM(LPC2148)
- Interfacing Graphical LCD with ARM(LPC2148)
- Interfacing ultrasonic sensor with ARM(LPC2148)
- Interfacing GSM Module with ARM(LPC2148)
- Interfacing PWM in ARM(LPC2148)
- Interfacing ADC with ARM(LPC2148)
- Scrolling string on LCD using ARM(LPC2148)
No comments:
Post a Comment