For this project, except a cell phone with GPS to record NMEA GPS sentences, no hardware is required. I used an Android phone and several apps are available on the Play Store that allow you to record NMEA sentences in “.txt” or “.log” format. Since not all users have access to an Android phone, I have attached two sets of GPS phrases to allow you to complete this project. Since no GPS signal could be obtained indoors, the first set of GPS sentences were recorded by walking approximately 100 meters outdoors. The second set of GPS sentences was recorded indoors for a condition with no GPS signal. The only other hardware required is a Host PC. For this project, I used an HP Pavilion G6 series laptop with a 2.1 GHz Intel processor and 3 GB of RAM running the Windows 7 Home Basic 64-bit operating system. The following software is required to successfully complete this project:
1) GPS Yes
2) Labcenter Proteus v7.6 or higher (v7.8 with SP2 was used for this project)
3) Eltima v5.0 Serial Port Splitter
Figure 1: GPS Simulator Window
Figure 1 shows the GPS Simulator window. To begin browsing to the folder containing the NMEA sentence log files, click the Browse button. Select the interval as 8 seconds. 4 seconds can also be selected; however, any range less than this will cause errors in Proteus and latitude and longitude information will not be displayed for all sentences. Additionally, select RMC as the sentence type, as only these sentences are passed to the Proteus simulation and are used to obtain latitude and longitude information. Then select the COM1 port from the port selection menu. Any available port can be selected, as long as it is not the COM2 port. The COM2 port is used on the Proteus to transmit data to the controller's USART RX pin. Additionally, the port selected in this menu must be the same one used to create a virtual link (using Eltima Serial Splitter) between the port and the COM2 port on Proteus. The GPS Simulator software can be downloaded from the following link:
Fig. 2: Serial Divider Window
Figure 2 shows the Eltima Software Serial Splitter 5.0 window. To create the virtual link between the port selected in the GPS Simulator and the COM2 port used in Proteus, select the 'Complex Bundles' tab. For the input side, select the 'Virtual Port' option and then the COM port used by the GPS Simulator to pass sentences to Proteus (COM1 in this case). Then click on the 'Add Port' button. Repeat the same procedure for the output side, but select the COM2 port. Once the input and output ports have been added, click on the 'Add Package' button. A successfully created package will appear on the left side of the software window, as shown in the figure. A 14-day trial version of Serial Splitter can be downloaded from the following link:
The Circuit Diagram tab shows the Proteus circuit for the simulation. A 15.9744 MHz crystal is connected to pins 13 and 14 of the PIC18F458 microcontroller. Switch SW1 is the reset switch. The RXD pin of the P2 COMPIM component is connected to the RX pin (pin 26) of the controller. A MAX232 IC is not required as it is integrated into the COMPIM component. The D port of the controller is connected to the parallel data lines D0:D7 of the LCD display. The VSS and VDD pins of the LCD are grounded and provide a voltage of 5V respectively. The RS, R/W and E pins of the LCD are connected to pins 38, 39 and 40 respectively on Port B.
To develop the control logic for GPS sentence analysis, the UART module was configured and latitude and longitude information was analyzed using string manipulation. To configure the UART module, the RX pin was configured for input and serial reception was enabled by assigning a value 0x90 to the RCSTA receive register. The baud rate generator register SPBRG received a value of 0x19 for baud rate of 9600bps. Asynchronous mode was chosen by clearing the SYNC bit in the transmit status and control register of the TXSTA. The receive flag was cleared and data was copied from the RCREG receive register to a temporary variable when the flag was set upon receiving the data. The CREN continuous receive enable bit in the RCSTA receive register was then cleared to allow continuous data reception.
The $GPRMC sentences were passed from the GPS simulator to the RX pin of the controller via the COMPIM component. Two sets of these sentences were pre-recorded using a GPS-enabled cell phone for two conditions – a varying GPS location and no GPS signal. For a variable GPS location, the first set of sentences was recorded at a distance of 100m. In the absence of a GPS signal, the second set of GPS sentences were recorded indoors. The sentences $GPRMC and $GPGGA (GPS signal condition found) were the same length (76 characters). If no GPS signal was found, sentences shorter than 76 characters contained no latitude and longitude information; instead, a series of commas were found in the recorded sentences. These features of the recorded sentences were used to identify the $GPRMC sentence and then extract latitude and longitude information. The identification of the $GPRMC sentence and the absence of GPS signal was obtained using string comparison. Once the GPS signal and $GPRMC were found, the latitude and longitude were extracted by determining the starting position and the number of characters in the latitude and longitude values. Figure 5 shows the control logic for parsing the $GPRMC sentence.
Figure 3: Control logic for GPS sentence analysis
To run the simulation, the following steps must be performed in the order indicated:
1) Start the Serial Splitter and create the complex packet between the input port of the GPS Simulator and the COM2 port of the Proteus circuit
2) Open 'gps.DSN' in Proteus
3) Start GPS Simulator and select log file
4) Start the simulation in Proteus and then start transmitting the log file in GPS Simulator
The LCD display will show that the GPS signal has been found and will display latitude and longitude information. Only part of this information is shown in Figure 6, as the LCD display is turned off and the following latitude and longitude information is shown. For the second log file, the LCD display will show that the GPS signal is not found.
Fig. 6: Latitude information partially showing
Project source code
###
#include
###
Circuit diagrams
gps_proteus |