This AVR microcontroller-based global positioning system (GPS) receiver can be used to find the exact location of a place and know its standard time. It provides the data corresponding to its position on international standard latitude-longitude basis and also the standard coordinated universal time (UTC) along with some more information received from the nearest satellite assigned for this purpose. (UTC is the primary time standard by which the world regulates clocks and time.)
It can prove useful in remote areas where no other wireless network such as the cellphone or the Internet is available. It can also be used for research and other sophisticated applications.
Circuit and working
Fig. 1 shows the block diagram of the standalone GPS receiver with liquid crystal display (LCD). The system consists of a GPS receiver module that collects data from the satellite, Atmega16 microcontroller for processing the received signal, power supply section and LCD for displaying the latitude, longitude and time.
The complete circuit is shown in Fig. 2. The connection setup is simple. All you need is a 3-wire cable for connecting the GPS module to the microcontroller. Transmit pin (TXD) of the GPS module is connected to receive pin (RXD) of the microcontroller (IC2). Resistors R6 and R5 are used to pull the pins high when in idle mode. However, in this circuit, these two resistors are optional because port D of ATmega16 has internal pull-ups.
Power supply. To derive the power supply for the circuit, 230V AC mains is stepped down by a 9V, 250mA secondary transformer, rectified by bridge rectifier module BR1 and filtered by capacitor C1. The voltage is regulated by a 7805 regulator. LED1 glows to indicate the presence of power in the circuit. The regulated 5V DC powers the microcontroller and the LCD. Zener diode ZD1 converts 5V into 3.3V for the GPS module.
You can also use a 9V AC mains adaptor or 9V battery for the circuit. Switch S1 is used to connect the battery to the circuit.
LCD. The project uses a 16×2, Hitachi HD44780-controlled LCD module. The 16-character, 2-line LCD module normally has eight data lines (D0 through D7) for data transfer. In this project, only four data lines (D4 through D7) are used for data transfer. Bus lines D0 through D3 are disabled. Data transfer between HD44780 and the microcontroller completes after the 4-bit data is transferred twice.
Port-C pins PC4 through PC7 of the microcontroller (IC2) are connected to data lines D4 through D7 of the LCD. LCD control lines—read/write (R/W), register-select (RS) and enable (E)—are connected to PD6, PC2 and PC3 of IC2, respectively.
GPS module. We have used an iWave GPS module with external antenna (refer Fig. 3). The module requires a 3.3V DC supply.
The GPS receiver receives the latitudinal and longitudinal data from the satellite. This data provides the exact position of the receiver on the Earth’s surface and also the real time. With the latitude and longitude information, you can view the location from the standard map. The latitude and longitude data obtained can also be entered into any freely available software such as itouchmap available from http://itouchmap.com/latlong.html, where you can view the exact location of any point on earth. You can also get the map from http://www.mapsofworld.com/lat_long/india-lat-long.html
You can also use Google Maps for locating the place. It is the common software used for this purpose. You just need to type the latitude and longitude in standard format. For example, enter 28.52, 77.22 in its search box and press ‘Search’ tab to view the location. It will show you the location somewhere in south
The program for the microcontroller is written in ‘C’ language using AVR Studio 4.
NMEA protocol. The basic working of the project is based on decoding of National Marine Electronics Association (NMEA) protocol through software program. The iWave GPS module uses NMEA-0183, which is a subset of NMEA protocol. This protocol includes a set of messages that use ASCII character set and have a defined format. These messages are continuously sent by the GPS module to the interfacing device. Each message starts with a ‘$’ (hex 0x24) and ends with (hex 0x0D 0x0A).
These messages include GGA, GGL, GSA, GSV, RMC, VTG and ZDA. For this project we need not know about all of these messages. We just need the GGA message string, which represents the time, position and fixed data for this application. This string has a format like:
$GPGGA, 002153.000, 3342.6618,
N,11751.3858, W, 1.2, 27.0, M, -34.2,
Here each field separated by comma (‘,’) represents a particular information. We are using only five of these fields for our purpose of displaying the time, latitude, latitude-direction, longitude and longitude-direction, which are 2nd, 3rd, 5th, 4th and 6th fields, respectively.
The project uses two software programs, namely, ‘gpss.c’ and ‘lcd2.h,’ where ‘gpss.c’ is the main program and ‘lcd2.h’ driver file for the LCD module.
The main ‘C’ program starts with the following code lines:
where ‘#include’ is the AVR microcontroller header file for input/output (I/O) ports and ‘#include “lcd2.h”’ is the header file for the LCD module.
The codes have been commented wherever necessary. For details of LCD interfacing and message display on the LCD, please refer the ‘Moving Message Display On LCD’ project published in EFY Dec. 2011 issue.
Data transfer between the GPS module and microcontroller through their respective transmit and receive pins is straightforward and therefore we have not discussed it here.
Compiling and programming the code. To work with the Atmel AVR microcontroller using ‘C’ programming language, you need two tools: AVR Studio and WinAVR. Both of these tools are freely available for download from the Internet.
AVR Studio is an integrated development environment that includes an editor, assembler, etc. It can be downloaded from the link.
WinAVR is a GCC-based compiler for AVR. It appears in AVR Studio as a plug-in. WinAVR also includes a program called Programmer’s Notepad that can be used to edit and compile ‘C’ programs, independently of AVR Studio. WinAVR setup file is available at http://winavr.sourceforge.net/
Remember to install AVR Studio before WinAVR.
To compile the gpss.c code, first launch AVR Studio from the desktop. You need to create a new project for the gpss.c code. Next, click ‘Build→Rebuild All’ to compile the ‘C’ code. If there is no error message, a file called ‘gpss.hex’ will be generated. This file contains the machine code that is ready to be downloaded to the ATmega16 microcontroller. The file is stored in sub-folder ‘\default’ of your project. If there are error messages, check your ‘C’ code. Most often these are caused by some typo or syntax errors.
Burn the hex code into the chip using EFY-KnS AVR development board or any other standard AVR programmer/burner.
Construction and testing
An actual-size, single-side PCB layout of the standalone GPS receiver with LCD display is shown in Fig. 4 and its component layout in Fig. 5.
Testing is relatively simple and user-friendly. When you connect 9V power supply to the circuit, LED1 glows, indicating the presence of power supply in the circuit. Wait for some time, say, 5 to 10 minutes, for initialisation of the GPS module.
If everything is fine, you will receive the latitude and longitude right on the LCD screen. Otherwise, switch off the circuit and switch on again, wait for some time and repeat the above steps. You can also press switch S2 momentarily to reset the circuit.
To help you troubleshoot the problems, test points (TP0 through TP5) are indicated in the circuit (Fig. 2). Their details are given in the table.
First, check proper power supply at TP1 with respect to TP0. You should get 9V in your voltmeter. Next, check the voltage at TP2. If you don’t get 5V, either 7805 is faulty or there is some connection problem (short or open) in the circuit. Next, check 3.3V at TP3. Otherwise, check the zener diode value and connection. Next, at TP4, check 5V supply for the LCD. Vary the LCD contrast control by turning the preset wiper right and left. Next, check the voltage at TP5. It should be 0V when S2 is pressed, otherwise 5V.
If you still face any problem, please refer to the ‘PC-Based GPS Receiver’ project published in EFY Oct. 2012 issue. If you are getting proper data on your PC, you will get the same in this project also, provided the gpss.c program is loaded correctly.
Download PCB and Component Layout PDFs: click Here
Download Source Code: Click Here
Once you have the coordinates on your screen, you can pick up a world map and locate the place yourself. In case you want to see the exact standard time, refer to the time obtained in this application, which entirely depends on satellite navigation.
Sani Theo is a B.Tech in electronics & communication engineering and Prince Gupta is a third-year B.Tech (electrical engineering) student at IIT, Rajasthan