You are on page 1of 77

GPS BASED NAVIGATION SYSTEM

A PROJECT REPORT

Submitted by

ANISH KUMAR.P (41502105005)


BALAJEE.T (41502105014)
DIVYA.G (41502105018)
KANNAN.N (41502105030)

in partial fulfillment for the award of the degree

of

BACHELOR OF ENGINEERING

IN

ELECTRICAL AND ELECTRONICS ENGINEERING

SRM ENGINEERING COLLEGE, KATTANKULATHUR

ANNA UNIVERSITY: CHENNAI 600 025

APRIL 2006

ANNA UNIVERSITY: CHENNAI 600 025

BONAFIDE CERTIFICATE
Certified that this project report “GPS BASED NAVIGATION SYSTEM” is the bonafide

work of “ ANISH KUMAR.P (41502105005), BALAJEE.T (41502105014), DIVYA.G

(41502105018) AND KANNAN.N (41502105030) ” who carried out the project work

under my supervision.

SIGNATURE OF THE HOD SIGNATURE OF SUPERVISOR

PROF R CHIDAMBARAM Mr.C.VAITHILINGAM &


Mr.R.CHANDRAMOHAN PROF & HEAD OF
DEPARTMENT SUPERVISORS
Department of Electrical & Department of Electrical &
Electronics Engineering Electronics Engineering SRM
Engineering College SRM Engineering College Kattankulathur
Kattankulathur Chennai – 603203 Chennai - 603203

Internal Examiner External Examiner ACKNOWLEDGEMENT

It is our great pleasure to express our deep sense of gratitude and indebtedness to Mr. C.
Vaithilingam and Mr. R. Chandramohan, our project guides, for their invaluable guidance
and constant encouragement throughout this project. Their critical appraisal of the work
done and valuable suggestions, in spite of their busy official schedule, have always been a
source of inspiration and motivation to complete the project.

We are also thankful to Sands Instrumentation Pvt. Ltd., Ashok Nagar, Chennai, and its
Head of Training Division, Mr. A.P. Sundar, for providing us facilities for carrying out
the project work. Our special thanks and gratitude are due to Mr. R. Francis Rajesh,
Project Guide at Sands Instrumentation, for providing the required support and guidance
throughout the project work.

We also thank the Professor R.Chidambaram, professor and head, Department of


Electrical Engineering, faculty and staff of the Department of Electrical Engineering,
SRM Engineering College, for all the help and encouragement given to us during the
course of the project work.

Anish Kumar, P.
Balajee, T.
Divya, G.
Kannan, N.

ABSTRACT

The GPS based navigation system aims at building a GPS reception system which can be

used to track a target location.

A GPS reception system consists of a GPS antenna, a GPS receiver, an UART (Universal

Synchronous Asynchronous Receiver Transmitter),a PIC microcontroller and an LCD.

Once the reception system hardware has been set up, the GPS receiver is synchronized

with the satellites. After this, data is obtained by the microcontroller from the satellites

through the GPS receiver using the UART. This data is then manipulated to extract

desired data alone and displayed on the LCD in a suitable form.


Using the GPS reception system, the current location is given to a Visual Basics program.

A target location is also keyed in. Comparing these two, control signals are given to a toy

car to direct it to move towards the target location.

LIST OF TABLES

TABLE NO TITLE PAGE

5.1 DESCRIPTION OF INDIVIDUAL


RMC DATA SET BLOCKS 22
6.1 REGISTERS SUMMMARY 28 6.2
WORD LENGTHS 29 6.3 BAUD RATE
FORMULA 45

LIST OF FIGURES
FIGURE NO TITLE PAGE

2.1 DETERMINING THE TRANSIT TIME 3 2.2 FOUR


SATELLITES ARE REQUIRED
TO DETERMINE A POSITION IN 3D SPACE
6
2.3 PSEUDO RANDOM NOISE 7 2.4 SIMPLIFIED
BLOCK DIAGRAM 8 2.5 DATA STRUCTURE OF A GPS
SATELLITE 9
2.6 MEASURING SIGNAL TRANSIT TIMES 10 2.7
TYPICAL BLOCK DIAGRAM OF A GPS
MODULE 11
3.1 STRUCTURE OF THE ENTIRE NAVIGATION
MESSAGE 14
5.1 SYNCHRONISATION 18 5.2 BLOCK
DIAGRAM OF A GPS RECEIVER
WITH INTERFACES 20
5.3 MAX 232 PIN DIAGRAM 23 6.1 BASIC BLOCK
DIAGRAM 26 6.2 PROGRAM MEMORY MAP AND STACK
OF PIC 18F452 33
6.3 DATA MEMORY MAP OF PIC 18F452 36 6.4 PIR1:
PERIPHERAL INTERRUPT
REQUEST (FLAG) REGISTER 39
6.5 RCSTA REGISTER 43 6.6 TXSTA
REGISTER 43 6.7 GPS RECEIVER BOARD
48 6.8 PIC 18F452 MICROCONTROLLER
BOARD 49

TABLE OF CONTENTS

CHAPTER NO TITLE PAGE

ABSTRACT iv
LIST OF TABLE v
LIST OF FIGURES vi

1 INTRODUCTION 1

2 GPS, THE TECHNOLOGY 2


2.1 THE PRINCIPLE OF MEASURING SIGNAL
TRANSIT TIME 2
2.2 GENEARTING SIGNAL TRANSIT TIME 3
2.3 DETERMINING A POSITION ON A PLANE 4
2.4 THE EFFECT AND CORRECTION OF TIME
ERROR 5
2.5 THE THREE SEGMENTS OF GPS 6

2.5.1 SPACE SEGMENT 7


2.5.2 CONTROL SEGMENT 9
2.5.3 USER SEGMENT 10
2.6 GPS RECEIVER 11
2.7 GPS APPLICATIONS 12

3 THE GPS NAVIGATION MESSAGE 13


3.1 INTRODUCTION 13
3.2 STRUCTURE OF NAVIGATION MESSAGE 14
3.3 INFORMATION CONTAINED IN THE
SUBFRAMES 14

4 THE TWO MODULES OF THE GPS BASED


NAVIGATION SYSTEM 16

5 THE GPS RECEPTION SYSTEM:


SYNCHRONISATION 18
5.1 GPS SMART ANTENNA 19
5.2 GPS RECEIVER 20
5.3 MAX232 22
5.4 GMONITOR SOFTWARE 24

6 THE GPS RECEPTION SYSTEM:


DATA EXTRACTION 26
6.1 TRANSMISSION AND RECEPTION
USING UART 16C550 27
6.1.1 REGISTER DESCRIPTION 28
6.1.2 RECEPTION 31
6.1.3 TRANSMISSION 31
6.2 DATA MANIPULTION USING THE
MICROCONTROLLER: PIC18F452 31
6.2.1 MEMORY ORGANIZATION 32

6.2.1.1 PROGRAM MEMORY


ORGANIZATION 32
6.2.1.2 DATA MEMORY
ORGANIZATION 34
6.2.2 BANK SELECTION USING
BANK SELCT REGISTER (BSR) 37
6.2.3 INDIRECT ADDRESSING USING
INDF AND FSR REGISTERS 37
6.2.4 CHECKING PIR REGISTER 38
6.2.5 CONFIGURING I/O PORTS 39
6.2.5.1 PORTA AND TRISA REGISTERS 40
6.2.5.2 PORTB AND TRISB REGISTERS 40
6.2.5.3 PORTC AND TRISC REGISTERS 41
6.2.5.4 PORTD AND TRISD REGISTERS 41
6.2.5.5 PORTE AND TRISE REGISTERS 41
6.2.6 SERIAL COMMUNICATION USING USART 42
6.2.6.1 RCSTA: RECEIVE STATUS AND
CONTROL REGISTER 43
6.2.6.2 TXSTA: TRANSMIT STATUS AND
CONTROL REGISTER 43
6.2.7 USART BAUD RATE GENERATION 44
6.2.8 USART ASYNCHRONOUS MODE 45
6.2.8.1 USART ASYNCHRONOUS
TRANSMITTER 46
6.2.8.2 USART ASYNCHRONOUS
RECEIVER 46
6.3 GPS RECEIVER BOARD 48
6.4 PIC 18F452 MICROCONTROLLER BOARD 49

7 ALGORITHM AND FLOWCHART FOR DATA


EXTRACTION 50
7.1 ALGORITHM FOR DATA EXTRACTION 50
7.2 FLOWCHART FOR DATA EXTRACTION 53

8 TRACKING OF A TARGET LOCATION 56

9 PROGRAMS 57
9.1 PIC 18F452 PROGRAM 57
9.2 VISUAL BASIC PROGRAM 75

10 CONCLUSION 82

APPENDIX 1: PIN DIAGRAM AND DEVICE


FEATURES OF PIC 18F452 83
APPENDIX 2: ARCHITECTURE OF PIC 18F452 84
APPENDIX 3: ELECTRICAL CHARACTERISTICS
OF PIC 18F452 85
APPENDIX 4: UART ARCHITECTURE 87
APPENDIX 5: PIN DESCRIPTION OF UART16C550 88
APPENDIX 6: ABSOLUTE MAXIMUM RATINGS
- MAX 220/222/232A/233A/242/243 90

REFERENCES 91

1: INTRODUCTION
The GPS based navigation system is used to obtain positional information, date and time
from the GPS satellites in orbit. The motives for using a GPS as a means for achieving
these purposes are:

• Using GPS, we can obtain one’s exact location (longitude, latitude and height
coordinates) accurate to within a range of 20 m to approximately 1mm.
• Using GPS, we can obtain the precise (Universal Time Coordinated, UTC)
accurate to within a range of 60ns to approximately 5ns.

The reason for the highly accurate time obtainable from the GPS is the presence of atomic
clocks on the GPS satellites. Atomic clocks are currently the most precise instruments
known, losing a maximum of one second every 30,000 to 1,000,000 years.

In this project, using this highly accurate positional data, a target location is tracked by a
toy car. This is done by comparison of current position (latitude and longitude) with the
target position (latitude and longitude). Thus tracking of a target location with a very high
degree of accuracy can be achieved.

2: GPS, THE TECHNOLOGY

The Global Positioning System (GPS) is a space based navigation system developed and
operated by the United States government which is used to establish a position at any
point on the globe.

GPS (the full description is: NAVigation System with Timing And Ranging Global
Positioning System- NAVSTAR-GPS) was developed by the US Department Of Defense
(DoD) and can be used by both civilian and military personnel. The civil signal SPS
(Standard Positioning Service) can be used freely by the general public, whilst the
military signal PPS (Precise Positioning Service) can only be used by authorized
government agencies. The first satellite was placed into orbit on 22 nd February 1978, and
there are currently 28 operational satellites orbiting the Earth at a height of 20,180km on
six different orbital planes. Their orbits are inclined at 55° to the equator, ensuring that at
least four satellites are in radio communication with any point on the planet. Each satellite
orbits the Earth in approximately 12 hours and has four atomic clocks on board.
2.1 THE PRINCIPLE OF MEASURING SIGNAL TRANSIT TIME

In order to calculate one’s exact position, all that needs to be measured is the signal transit
time between the point of observation and four different satellites whose positions are
known.
2.2 GENERATING GPS SIGNAL TRANSIT TIME
28 satellites inclined at 55º to the equator orbit the earth every 11 hours and 58 minutes at
a height of 20,180 km on 6 different orbital planes.
Each one of these satellites has up to four atomic clocks on board. Each satellite transmits
its exact position and it’s precise on board time to earth at a frequency of 1575.42 MHz.
These signals are transmitted at the speed of light (3,00,000Km/s) and therefore require
approximately 67.3ms to reach a position on the Earth’s surface located directly below
the satellite. The signals require an extra 3.33 micro seconds for every excess kilometer
of travel. If we wish to establish our position on land (or at sea or in the air), all we
require is an accurate clock. By comparing the arrival time of the satellite signal with the
onboard clock time the moment the signal was emitted, it is possible to determine the
transit time of that signal.

Fig 2.1: Determining the transit time


The distance ‘S’ to the satellite can be determined using the known signal transit time‘t’:

Distance = Transit time * Speed of light


S=t*c

Measuring signal transit time and knowing the distance to a satellite is still not enough to
calculate one’s position in 3-D space. To achieve this four independent time
measurements are required. Hence signal communication with four different satellites is
needed to calculate one’s exact position.

2.3 DETERMINING A POSITION ON A PLANE

Let us imagine that two satellites are orbiting far above us transmitting their on board
clock times and their positions. By using the signal transit time to both satellites, we can
draw two circles with radii S1 and S2 around the satellites. Each radius corresponds to the
distance calculated to the satellite. All possible distances are located on the circumference
of the circle. If the position above the satellite is excluded, the location of the receiver is
at the exact point where the two circles intersect beneath the satellites.

In reality, a position has to be determined in three dimensional space, rather than on a


plane. As the difference between a plane and three-dimensional space consists of an extra
dimension height z), an additional third satellite must be available to determine the true
position.

If the distance to the three satellites is known, all possible positions are located on the
surface of the three spheres whose radii correspond to the distance calculated. The
position sought is the point where all three surfaces of the spheres intersect.

All statements made so far will only be valid, if the terrestrial clock and the atomic clocks
on board the satellites are synchronized, i.e. signal transit time can be accurately
determined.

2.4 THE EFFECT AND CORRECTION OF TIME ERROR

For the receiver to measure time precisely, a highly accurate, synchronized clock is
needed. If the transit time is out by just 1 micro second, this produces a positional error of
300m. As the clocks on board all three clocks are synchronized, the transit time in the
case of all three measurements is inaccurate by the same amount. When producing
calculations, if N variables are unknown, we need N independent equations.

If the time measurement is accompanied by a constant unknown error, we will have four
unknown variables in 3-D space:

1. Longitude (X)
2. Latitude (Y)
3. Altitude (Z)
4. Time Error (∆t)
It therefore follows that in three-dimensional space, four satellites are needed to
determine a position.
.

Fig 2.2: Four


satellites are
required to
determine a position in 3-D space

2.5 THE THREE SEGMENTS OF GPS

The global positioning system comprises three segments:

1. The space segment (all functional satellites)


2. The control segment (all ground stations involved in the monitoring of the
system: master control station, monitor stations and ground control stations) 3.
The user segment (all civil and military GPS users)
2.5.1 SPACE SEGMENT

Satellite movement
The space segment currently consists of 28 operational satellites orbiting the Earth on six
different orbital planes (four to five satellites per plane). They orbit at a height of
20,180km above the earth’s surface and are inclined at 55º to the equator. Any one
satellite completes its orbit in around 12 hours. Due to the rotation of the Earth, a satellite
will be at its initial starting position after approximately 24 hours.

Satellite signals
The following information (navigation message) is transmitted by the satellite at the rate
of 50 bits per second.
• Satellite time and synchronization signals
• Precise orbital data (Ephemeris)
• Time correction information to determine the exact satellite time
• Correction signals to calculate signal transit time
• Data on the ionosphere
• Information on the satellite health
Each of the 28 satellites transmits a unique signature assigned to it. The signature consists
of an apparent random sequence (Pseudo Random Noise code, PRN) of 1023 zeros and
ones.

Fig 2.3: Pseudo random noise


Lasting a millisecond, this unique identifier is continually repeated and serves two
purposes with regard to the receiver:
• Identification: the unique signature pattern means that the receiver knows from
which satellite the signal originated.
• Signal transit time measurement.
Generating the satellite signal
The following pulses and frequencies required for day-to-day operation are derived from
the resonant frequency of one of the four atomic clocks:
• The 50Hz data pulse
• The C/A code pulse ( Coarse acquisition code, PRN code, Coarse Reception Code
at a frequency of 1023Mhz), which modulates the data using an exclusive OR
operation
• The frequency of the civil L1 carrier(1575.42Mhz)
The data modulated by the C/A code modulates the l1 carries in turn using Bi-Phase-
ShiftKeying. With every change in the modulated data, there is a 180º change in the L1
carrier phase.

Fig 2.4: Simplified block diagram

Fig 2.5: Data


structure of a GPS
satellite
2.5.2 CONTROL SEGMENT

The control segment (Operational Control System OCS) consists of a master control
station located in the state of Colorado, five monitor stations equipped with atomic clocks
that are spread around the globe in the vicinity of the equator, and three ground control
stations that transmit information to the satellites.
The most important tasks of the control segment are:
• Observing the movement of the satellites and computing orbital data (ephemeris)
• Monitoring the satellite clocks and predicting their behaviour
• Synchronizing on board satellite time
• Relaying precise orbital data received from satellites in communication
• Relaying the approx. orbital data of all satellites (almanac)
• Relaying further information including satellite health, clock errors etc.

2.5.3 USER SEGMENT

The signals transmitted by the satellites take approx. 67 milliseconds to reach a receiver.
As the signals travel at the speed of light, their transit time depends on the distance
between the satellite and the user.

Four different signal are generated in the receiver having the same structure as those
received from the four satellites. By synchronizing the signals
Fig 2.6: Measuring signal transit times

generated in the receiver with those from the satellites, the four satellite signal time shifts
∆t are measured as a timing mark.
The measured time shifts of all four satellite signals are used to determine signal transit
time. The relevant distance to the satellites is determined by the transit time of the signals.
The receiver then calculates the user’s latitude, longitude, altitude and time from the
range and known position of the four satellites.

2.6 GPS RECEIVERS

GPS modules have to evaluate weak antenna signals from at least four satellites, in order
to determine a correct three dimensional position. The signals received (1575.42 MHz)
are preamplified and transformed to a lower intermediate frequency. The reference
oscillator provides the necessary carrier wave for frequency conversion, along with the
necessary clock frequency for the processor and correlator. The analog intermediate
frequency is converted into a digital signal by means of a 2-bit ADC.

Fig 2.7:

Typical block diagram of a GPS module

Signal transit time from the satellites to the receiver is ascertained by correlating PRN
pulse sequences. The satellite PRN code must be used to determine this time, otherwise
there is no correlation maximum. Data is recovered by mixing it with the correct PRN
sequence. At the same time, the useful signal is amplified above the interference level. Up
to sixteen satellite signals are processed simultaneously. The control and generation of
PRN sequences and the recovery of data is carried out by a signal processor. Calculating
and saving the position, including the variables derived from this, is carried out by a
processor with memory facility.
2.7 GPS APPLICATIONS

GPS aided navigation and positioning can be used in many sectors of the economy, as
well as in science, technology, tourism, research and surveying. The GPS process can be
employed wherever three-dimensional geodata has a significant role to play. A few
important sectors are detailed below:

• Science and research


• Commerce and industry
• Agriculture and forestry
• Communications technology
• Tourism/Sport
• Military
• Time measurement

GPS provides us with the opportunity of measuring time exactly on a global basis.
Right around the world “time” (UTC Universal Time Co-coordinated) can be
accurately determined to within 1-60ns. Measuring time with GPS is a lot more
accurate than with so-called radio clocks.

3: THE GPS NAVIGATION MESSAGE

3.1 INTRODUCTION

The navigation message is a continuous stream of data transmitted at 50 bits per second.
Each satellite relays the following information to the Earth:

• System time and clock correction values


• Its own highly accurate orbital data (ephemeris)
• Approx. orbital data of all other satellites (almanac)
• System health

The navigation message is needed to determine the current position of the satellite and to
determine signal transit times.
The data stream I modulated to the HF carrier of each individual satellite. Data is
transmitted in logically grouped units known as frames or pages. Each frame is 1500 bits
long and takes 30 seconds to transmit. The frames are divided into 5 subframes. Each
subframe is 300 bits long and takes 6 seconds to transmit. In order to transmit a complete
almanac, 25 different frames are required. Transmission time for the entire almanac is
therefore 12.5 minutes. A GPS receiver must have collected the complete almanac at least
once to be capable of functioning.

3.2 STRUCTURE OF THE NAVIGATION MESSAGE

A frame is 1500 bits long and takes 30 seconds to transmit. The 1500 bits are divided into
5 frames each of 300 bits. Each subframe is in turn divided into 10 words each containing
30 bits. Each subframe begins with a telemetry word and a handover word (HOW). A
complete navigation message consists of 25 frames. The structure of the navigation
message is illustrated in the figure 3.1.

Fig 3.1: Structure of the entire navigation message

3.3 INFORMATION CONTAINED IN THE SUBFRAMES


• Subframe 1 contains the time values of the transmitting satellites, including the
parameters for correcting signal transit delay and on board clock time, as well as
information on satellite health and an estimation of the positional accuracy of the
satellite. Subframe 1 also transmits the so-called 10-bit week number.

• Subframe 2 and 3 contain the ephemeris data of the transmitting satellite. This
data provides extremely accurate information on the satellites orbit.

• Subframe 4 contains the almanac data on satellite number 25 and further and
information regarding any measurement errors caused by the ionosphere.

• Subframe 5 contains the almanac data on satellite numbers 1 to 24. all 25 pages
are transmitted together with information on the health of the satellite numbers 1
to 24

4: THE TWO MODULES OF THE GPS BASED NAVIGATION SYSTEM

The project can be divided into two basic modules:

1. The GPS reception system:


This is the main module. This consists of building the hardware for reception of
data from satellites through a GPS receiver, synchronizing the receiver with the
satellite through Gmonitor software, extracting appropriate data from GPS
receiver once it has been synchronized, calculating Indian Standard Time (IST)
and displaying the data on a LCD screen.

2. Tracking of a target location:


This consists of designing the Visual Basic Interface, extracting relevant
positional data from microcontroller, comparing target location and current
location and tracking by a vehicle as a result of this comparison.

The hardware elements used for the two modules are:


• GPS receiver
• GPS antenna
• UART 16C550
• PIC 18F452
• LCD screen
• MAX 232 chip
• A toy vehicle

The software used is:

• MPLAB IDE for the assembly language coding of PIC18F452


• P1618QP programming software
• Gmonitor for synchronizing the GPS receiver with the GPS satellites
• Visual Basic for building the tracking system

5: THE GPS RECEPTION SYSTEM: SYNCHRONISATION

There are two parts to building a GPS reception system. They are:

1. Synchronization
2. Data Extraction

Synchronization is dealt with in this chapter.

SYNCHRONISATION

In order to obtain accurate positional and time data from the satellites, the GPS receiver
must be synchronized with the satellites. Failure to do so will result in erroneous data
being received.
The hardware setup for synchronizing the GPS receiver is very simple. We have to
connect a GPS antenna to the receiver and interface the receiver to a computer through a
MAX 232 chip. Then we use the Gmonitor software to synchronize the GPS receiver with
the satellites.
GPS ANTENNA

GPS RECEIVER MAX 232 COMPUTER

Fig 5.1: Synchronization


5.1 GPS SMART ANTENNA

The antenna used for reception of information from GPS satellites is the “GPS Smart
Antenna” from Leadtek Company. It has the following features:

• Foliage Lock: operates even in areas of dense foliage.


• Single satellite: allows position updates from a single satellite once the initial
position has been calculated.
• Dual multipath rejection: effectively eliminates redundant data derived from
signals coming from an indirect path.
• Snaplock: the ability to renew satellite positioning within a tenth of a second after
emerging from a blocked region.
• Trickle power: achieves the lowest average power dissipation by powering down
the main processor, after a position is determined. When it is turned back on, it
can recompute a position fix in the shortest amount of time.

This antenna is used to establish contact by the GPS receiver with the satellites. It has
a magnet base which helps in easy mounting. Once the antenna has been positioned
properly and connected with the GPS receiver, we can start synchronizing the GPS
receiver with the satellites through Gmonitor software.

5.2 GPS RECEIVER


The GPS receiver used is the “GPS-MS1E” – a fully self controlled receiver module for
Global Positioning System manufactured by SiRF technology, Inc.

GPS receivers require different signals in order to function. These variables are broadcast
after time and position have been successfully calculated. To ensure that the different
types of appliances, there are international standards for data exchange (NMEA and
RTCM).

In order to relay computed GPS variables such as position, velocity, course etc to a
peripheral (e.g. computer, screen, transceiver etc), GPS receivers have a serial interface
(TTL or RS-232 level).

Fig 5.2: Block diagram of a GPS receiver with interfaces

The most important elements of receiver information are broadcast via this interface in a
special data format. This format is standardized by the National Marine Electronics
Association (NMEA) to ensure that data exchange takes place without any problems.
Nowadays, data is relayed according to NMEA-0183 specification. NMEA has several data
sets. In our application, we make use of the RMC- Recommended Minimum Specific data
set.

RMC data set: the RMC data set contains information on time, latitude, longitude, height,
system status, speed, course and date. This data set is relayed by all GPS receivers.

An example of an RMC data set:


$GPRMC,130304.0,A,4717.115,N,00833.912,E,000.04,205.5,200601,01.3,W*7C<R
><L F>

The function of the individual characters or character sets is explained in table 5.1:

Table 5.1: Description of individual RMC data set blocks

5.3 MAX 232


The GPS module outputs a serial TTL (0V / 5V) signal. This must be converted to
RS232 levels before it is usable by the PC host computer. The RS232 level converter
used in this project is MAX232.
Fig 5.3: MAX232 pin diagram

The MAX232 has two internal charge pumps that convert +5V to ±10V (unloaded) for
RS232 driver operation. The first converter uses capacitor C1 to double the +5V input to
+10V on C3 at the V+ output. The second converter uses capacitor C2 to invert +10V to
10V on C4 at the V- output.

Connections:

• For the capacitor C1, the negative leg goes to pin 3 and the positive leg goes to
pin 1.
• For the capacitor C2, the negative leg goes to pin 5 and the positive leg goes to
pin 4.
• For the capacitor C3, the negative leg goes to 5 volts and the positive leg goes to
pin
2.
• For the capacitor C4, the negative leg goes to pin 6 and the positive leg goes to
ground.
• For the capacitor C5, the negative leg goes to ground and the positive leg goes to
pin
16.

The MAX232 includes 2 receivers and 2 transmitters so two serial ports can be used
with a single chip. We have used only one transmitter for this project.
To power the MAX232, we need to
• Connect pin 16 to 5 volts.
• Connect pin 15 to ground
.

The only thing left is that we need some sort of connector to connect to the serial port.
Most computers use a 9 pin DB9 male connector for Comm1 and Comm2, so a 9 pin
female connector is included for this project. We need a DB9 extension cable to make
the connection easier. There should be 3 wires soldered to the DB9 connector pins 2, 3
and 5. Connect the wire from pin 5 of the connector to ground. Connect the wire from pin
2 of the connector to pin 14 of the MAX232.
5.4 GMONITOR SOFTWARE

The GMonitor software is used for synchronizing the GPS receiver with the satellites. On
assembling the hardware for synchronizing, it is connected with the computer’s serial port
through a DB9 extension cable. Then the Gmonitor Software is started up. Then

• The “connect” tab is clicked


• In the menu bar, the action tab is clicked followed by the synchronize option in it.
• We will see the RMC data set being displayed on the screen. A valid data set is in
the form:

$GPRMC,130304.0,A,4717.115,N,00833.912,E,000.04,205.5,200601,01.3,W*7C<R
><L
F>
• If instead of the alphabet ‘A’ in the above set, we see a ‘V’, then synchronization
has not yet taken place
• Once we see the alphabet ‘V’ changing to ‘A’, we can be sure that the GPS
receiver has been synchronized with the satellites

Then we can close the GMonitor software and proceed to the extraction of relevant data
from the GPS receiver by the microcontroller.
6: THE GPS RECEPTION SYSTEM: DATA EXTRACTION

Now that the GPS receiver is receiving valid data, we proceed to connect the GPS
receiver to the PIC18F452 microcontroller through UART16C550. Once this is
accomplished, we then proceed to display the appropriate data on an LCD.

The basic block diagram for these processes is:

GPS ANTENNA

GPS RECEIVER

UART 16C550 PIC 18F452 LCD

Fig 6.1: Basic block diagram

6.1 TRANSMISSION AND RECEPTION USING UART 16C550

The Universal Asynchronous Receiver Transmitter provides a full-featured


transmitterreceiver pair, configurable by software for different speeds, character widths,
parity codification, etc. The UART is used for receiving data from the GPS receiver and
passing it on to the microcontroller which does the necessary manipulations on the data.

The UART is designed as an 8-bit peripheral and so it provides 8-bit input and output
data buses, data_in and data_out respectively. A 3-bit address input add selects which
register is being access by the microprocessor. There are more than 8 registers and so the
selection is also based on the state of a special bit. In order to enable any read or write
operation on the registers, a “chip select” condition must be met. This condition is
defined by three different signals: cs1, cs2 and cs_n. The first two must be set at high
level and the third at low level in order for any operation to take place. A read operation
is executed when the chip select condition is met and the signal ior is 1 while ior_n is 0.
Similarly, a write operation occurs when the chip select condition is met and the signal
iow is 1 while iow_n is 0.
Splitting the chip select input and the read and write strobes into several signals provides
more versatility to the module while few more gates are added to the circuitry. In this
way, the UART can be connected in a straightforward manner to different microprocessor
architectures.

6.1.1 REGISTER DESCRIPTION: The table 6.1 describes the registers of UART
Table 6.1: Registers summary

The registers relevant to this project are discussed below:


• Receiver holding register (RHR)
The user can get the data received through the serial channel (pin rxd) reading this read-
only location. The DLAB bit in LCR must be 0. Before reading this register the user must
ensure that the UART is ready to transmit data for reception, for example checking that
‘data ready’ flag is set in the LSR.

• Transmitter holding register (THR)


The user writes in this write-only location the data to be sent through the txd pin of the
UART. The DLAB bit in LCR must be 0. Before writing this register the user must
ensure that the UART is ready to accept data for transmission, for example checking that
‘THR Empty’ flag is set in the LSR.

• Line control register (LCR)


This register controls the way in which transmitted characters are serialized and received
characters are assembled and checked. Bits 0 and 1 define the word length of the data
being transmitted and received. The table 6.2 below details the possible selections. Table
6.2: Word lengths

Since we use 8 bit long words, the last two bits of LCR register should be set to 1.
Bit 7 is Divisor Latch Access Bit (DLAB). This bit must be set in order to access the
DLL, DLM and PSD registers which program the division constants for the baud rate
divider and the prescaler. As these registers occupy the same locations as the THR, RHR,
and IER, DLAB must be zero to access these other registers.
• Line status register
This register informs the user about the status of the transmitter and the receiver. In order
to get information about a received character, LSR must be read before reading that
received character from RHR.
Bit 7 functions as the ‘data ready’ flag. When this flag is set, the user can read data from
the RHR register. Bit 5 functions as the ‘THR empty’ flag. Only when this bit is set, will
the user be able to give the data to be transmitted to the THR register.

• Divisor latch (DLL & DLM)


These two registers, together with the PreScalerDivision (PSD) select the speed at which
the communication will occur. This is the baud rate at
which characters will be transmitted and the expected baud rate for the characters that
will be received. Only one baud rate is defined for both transmission and reception. The
Divisor Latch is a 16-bit register, whose most significant byte is hold in DLM and its
least significant byte is hold in DLL. The access to these two registers, located at
addresses 1 and 0
respectively, is conditioned to the value of the DLAB bit in LCR register. Only if this bit
is 1 the two registers can be written and read. Otherwise the IER, RHR, and THR will be
accessed instead.

6.1.2 RECEPTION

The serial data comes into the UART through the rxd pin. The Receiver Shift Register
(RSR) gets this data and converts it to parallel format. When a complete character has
been assembled it is passed to the Receiver Holding Register (RHR), where it is read
from the microprocessor. The reception of a character starts when a bit at low

6.1.3 TRANSMISSION

The transmission of data is done through the txd pin. The transmitter has a Transmitter
Holding Register (THR) to hold the data to be sent. This buffer is written from by
microprocessor. The data in the THR is passed to the Transmitter Shift Register (TSR),
which is used to serialize the character data bits. During this serialization process, the
start, stop and parity bits are added.
6.2 DATA MANIPULATION USING THE MICROCONTROLLER: PIC18F452

Once the data has been passed to the microcontroller, it does the following functions:
• Selectively receives data only between ‘$’ and ‘*’. Thus the information between
these two bits in the RMC data set is only used.
• Extracts the required information i.e. time, latitude, longitude and date separately.
• Performs the conversion from GMT (Greenwich Meridian Time) to IST (Indian
Standard Time).
• Displays the data on an LCD in an appropriate format.

6.2.1 MEMORY ORGANIZATION

There are three memory blocks in this microcontroller. These memory blocks are:
• Program Memory
• Data RAM
• Data EEPROM

Data and program memory use separate busses, which allows for concurrent access of
these blocks.

6.2.1.1 Program memory organization

A 21-bit program counter is capable of addressing the 2-Mbyte program memory space.
Accessing a location between the physically implemented memory and the 2-Mbyte
address will cause a read of all ’0’s (a NOP
instruction). The PIC18F452 has 32 Kbytes of FLASH memory. This means that
PIC18F452 can store up to 16K of single word instructions. The RESET vector address is
at 0000h and the interrupt vector addresses are at 0008h and 0018h.

The figure 6.2 shows the Program Memory Map for PIC18F452
Fig 6.2: Program memory map and
stack for PIC18F452

PCL, PCLATH and PCLATU

The program counter (PC) specifies the address of the instruction to fetch for execution.
The PC is 21-bits wide. The low byte is called the PCL register. This register is readable
and writable. The high byte is called the PCH register. This register contains the
PC<15:8> bits and is not directly readable or writable. Updates to the PCH register may
be performed through the PCLATH register. The upper byte is called PCU. This register
contains the PC<20:16> bits and is not directly readable or writable. Updates to the PCU
register may be performed through the PCLATU register. The PC addresses bytes in the
program memory. To prevent the PC from becoming misaligned with word instructions,
the LSB of PCL is fixed to a value of ’0’. The PC increments by 2 to address sequential
instructions in the program memory. The CALL, RCALL, GOTO and program branch
instructions write to the program counter directly. For these instructions, the contents of
PCLATH and PCLATU are not transferred to the program counter. The contents of
PCLATH and PCLATU will be transferred to the program counter by an operation that
writes PCL. Similarly, the upper two bytes of the program counter will be transferred to
PCLATH and PCLATU by an operation that reads PCL. This is useful for computed
offsets to the PC.

6.2.1.2 Data memory organization

The data memory is implemented as static RAM. Each register in the data memory has a
12bit address, allowing up to 4096 bytes of data memory. The data memory map is
divided into as many as 16 banks that contain 256 bytes each. The lower 4 bits of the
Bank Select Register (BSR<3:0>) select which bank will be accessed. The upper 4 bits
for the BSR are not implemented.

The data memory contains Special Function Registers (SFR) and General Purpose
Registers (GPR). The SFRs are used for control and status of the controller and peripheral
functions, while GPRs are used for data storage and scratch pad operations in the user’s
application. The SFRs start at the last location of Bank 15 (0xFFF) and extend
downwards. Any remaining space beyond the SFRs in the Bank may be implemented as
GPRs. GPRs start at the first location of Bank 0 and grow upwards. Any read of an
unimplemented location will read as ’0’s.
The entire data memory may be accessed directly or indirectly. Direct addressing may
require the use of the BSR register. Indirect addressing requires the use of a File Select
Register (FSRn) and a corresponding Indirect File Operand (INDFn). Each FSR holds a
12-bit address value that can be used to access any location in the Data Memory map
without banking.
The instruction set and architecture allow operations across all banks. This may be
accomplished by indirect addressing or by the use of the MOVFF instruction. The
MOVFF instruction is a two-word/two-cycle instruction that moves a value from one
register to another. To ensure that commonly used registers (SFRs and select GPRs) can
be accessed in a single cycle, regardless of the current BSR values, an Access Bank is
implemented. A segment of Bank 0 and a segment of Bank 15 comprise the Access
RAM.

GENERAL PURPOSE REGISTER FILE:


The register file can be accessed either directly or indirectly. Indirect addressing operates
using a File Select Register and corresponding Indirect File Operand. Enhanced MCU
devices may have banked memory in the GPR area. GPRs are not initialized by a Power-
on Reset and are unchanged on all other RESETS. Data RAM is available for use as GPR
registers by all instructions. The top half of Bank 15 (0xF80 to 0xFFF) contains SFRs. All
other banks of data memory contain GPR registers, starting with Bank 0.
SPECIAL FUNCTION REGISTERS
The Special Function Registers (SFRs) are registers used by the CPU and Peripheral
Modules for controlling the desired operation of the device. These registers are
implemented as static RAM. The SFRs can be classified into two sets; those associated
with the “core” function and those related to the peripheral functions. The SFRs are
typically distributed among the peripherals whose functions they control. The unused
SFR locations will be unimplemented and read as '0's.

Fig 6.3: Data memory map for PIC18F452


6.2.2 BANK SELECTION USING BANK SELECT REGISTER (BSR)
The need for a large general purpose memory space dictates a RAM banking scheme. The
data memory is partitioned into sixteen banks. When using direct addressing, the BSR
should be configured for the desired bank. BSR<3:0> holds the upper 4 bits of the 12-bit
RAM address. The BSR<7:4> bits will always read ’0’s, and writes will have no effect. A
MOVLB instruction has been provided in the instruction set to assist in selecting banks.
We select the bank 0 when General purpose registers are to be used and bank 15 when
special function registers are to be used.

6.2.3 INDIRECT ADDRESSING USING INDF AND FSR REGISTERS

Indirect addressing is a mode of addressing data memory, where the data memory address
in the instruction is not fixed. An FSR register is used as a pointer to the data memory
location that is to be read or written. Since this pointer is in RAM, the contents can be
modified by the program. This can be useful for data tables in the data memory and for
software stacks.

Indirect addressing is possible by using one of the INDF registers. Any instruction using
the INDF register actually accesses the register pointed to by the File Select Register,
FSR. Reading the INDF register itself, indirectly (FSR = 0), will read 00h. Writing to the
INDF register indirectly, results in a no operation. The FSR register contains a 12-bit
address. The INDFn register is not a physical register. Addressing INDFn actually
addresses the register whose address is contained in the FSRn register (FSRn is a pointer).
This is indirect addressing.

There are three indirect addressing registers. To address the entire data memory space
(4096 bytes), these registers are 12-bit wide. To store the 12-bits of addressing
information, two 8bit registers are required. These indirect addressing registers are:
1. FSR0: composed of FSR0H:FSR0L
2. FSR1: composed of FSR1H:FSR1L
3. FSR2: composed of FSR2H:FSR2L

In addition, there are registers INDF0, INDF1 and INDF2, which are not physically
implemented. Reading or writing to these registers activates indirect addressing, with the
value in the corresponding FSR register being the address of the data. If an instruction
writes a value to INDF0, the value will be written to the address pointed to by
FSR0H:FSR0L. A read from INDF1 reads the data from the address pointed to by
FSR1H:FSR1L.

Every character from the GPS receiver is sequentially stored in registers pointed to by the
FSR register. Just by incrementing the value of the FSR register, we can access
successive memory locations where the characters received can be stored.

6.2.4 CHECKING PIR REGISTER

The PIR registers contain the individual flag bits for the peripheral interrupts. Due to the
number of peripheral interrupt sources, there are two Peripheral Interrupt Flag Registers
(PIR1, PIR2).
In this project we are concerned with two bits, RCIF and TXIF, of the PIR1 register only.

Fig 6.4: PIR1: Peripheral Interrupt Request (Flag) Register 1

Bit 5 RCIF: USART Receive Interrupt Flag bit

1 = The USART receive buffer, RCREG, is full (cleared when RCREG is read)
1 = The USART receive buffer is empty

Bit 4 TXIF: USART Transmit Interrupt Flag bit

2 = The USART transmit buffer, TXREG, is empty (cleared when TXREG is


written)
0 = The USART transmit buffer is full

So before transmission and reception, these two bits have to be checked to ascertain
whether the microcontroller is ready for these activities.

6.2.5 CONFIGURING I/O PORTS

Depending on the device selected, there are either five ports or three ports available.
Some pins of the I/O ports are multiplexed with an alternate function from the peripheral
features on the device. In general, when a peripheral is enabled, that pin may not be used
as a general purpose I/O pin. Each port has three registers for its operation. These
registers are:
• TRIS register (data direction register)
• PORT register (reads the levels on the pins of the device)
• LAT register (output latch)
The data latch (LAT register) is useful for read-modify-write operations on the value that
the I/O pins are driving.

6.2.5.1 PORTA and TRISA Registers

PORTA is a 7-bit wide, bi-directional port. The corresponding Data Direction register is
TRISA. Setting a TRISA bit (= 1) will make the corresponding PORTA pin an input (i.e.,
put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISA bit (= 0)
will make the corresponding PORTA pin an output (i.e., put the contents of the output
latch on the selected pin). Reading the PORTA register reads the status of the pins,
whereas writing to it will write to the port latch.

6.2.5.2 PORTB and TRISB Registers

PORTB is an 8-bit wide, bi-directional port. The corresponding Data Direction register is
TRISB. Setting a TRISB bit (= 1) will make the corresponding PORTB pin an input (i.e.,
put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISB bit (= 0)
will make the corresponding PORTB pin an output (i.e., put the contents of the output
latch on the selected pin).
6.2.5.3 PORTC and TRISC Registers

PORTC is an 8-bit wide, bi-directional port. The corresponding Data Direction register is
TRISC. Setting a TRISC bit (= 1) will make the corresponding PORTC pin an input (i.e.,
put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISC bit (= 0)
will make the corresponding PORTC pin an output (i.e., put the contents of the output
latch on the selected pin).

6.2.5.4 PORTD and TRISD Registers


PORTD is an 8-bit wide, bi-directional port. The corresponding Data Direction register is
TRISD. Setting a TRISD bit (= 1) will make the corresponding PORTD pin an input (i.e.,
put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISD bit (= 0)
will make the corresponding PORTD pin an output (i.e., put the contents of the output
latch on the selected pin)

6.2.5.5 PORTE and TRISE Registers

PORTE is a 3-bit wide, bi-directional port. The corresponding Data Direction register is
TRISE. Setting a TRISE bit (= 1) will make the corresponding PORTE pin an input (i.e.,
put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISE bit (= 0)
will make the corresponding PORTE pin an output (i.e., put the contents of the output
latch on the selected pin).

6.2.6 SERIAL COMMUNICATION USING USART

The Universal Synchronous Asynchronous Receiver Transmitter (USART) module is one


of the two serial I/O modules. (USART is also known as a Serial Communications
Interface or SCI.) The USART can be configured as a full duplex asynchronous system
that can communicate with peripheral devices, such as CRT terminals and personal
computers, or it can be configured as a half-duplex synchronous system that can
communicate with peripheral devices, such as A/D or D/A integrated circuits, serial
EEPROMs, etc.
The USART can be configured in the following modes:
• Asynchronous (full-duplex)
• Synchronous - Master (half-duplex)
• Synchronous - Slave (half-duplex)

There are two important registers concerned with the USART


• RCSTA - Receive Status and Control register
• TXSTA – Transmit Status and Control register

In order to configure pins RC6/TX/CK and RC7/RX/DT as the Universal Synchronous


Asynchronous Receiver Transmitter:
• bit SPEN (RCSTA<7>) must be set (= 1),
• bit TRISC<6> must be cleared (= 0), and
• bit TRISC<7> must be set (=1).

6.2.6.1 RCSTA: Receive Status And Control Register


Fig 6.5: RCSTA register

We are concerned only with the following bits


Bit 7 SPEN: Serial Port Enable bit
1 = Serial port enabled (configures RX/DT and TX/CK pins as serial port pins)
0 = Serial port disabled

Bit 4 CREN: Continuous Receive Enable bit


Asynchronous mode:
1 = Enables receiver
0 = Disables receiver

Thus in order to enable reception, both SPEN and CREN should be set.

8.2.6.2 TXSTA: Transmit Status And Control Register

Fig 6.6: TXSTA register

We are concerned only with the following bits


Bit 5 TXEN: Transmit Enable bit
1 = Transmit enabled
1 = Transmit disabled
Note: SREN/CREN overrides TXEN in SYNC mode.

Bit 4 SYNC: USART Mode Select bit


2 = Synchronous mode
1 = Asynchronous mode

Bit 2 BRGH: High Baud Rate Select bit


Asynchronous mode:
2 = High speed
0 = Low speed

Thus to enable the low speed asynchronous transmission required, TXEN is set, SYNC is
reset and RGH is also reset.

6.2.7 USART BAUD RATE GENERATION (BRG)

The BRG supports both the Asynchronous and Synchronous modes of the USART. It is a
dedicated 8-bit baud rate generator. The SPBRG register controls the period of a free
running 8-bit timer. In Asynchronous mode, bit BRGH (TXSTA<2>) also controls the
baud rate.
Given the desired baud rate and Fosc (Frequency of Oscillator), the nearest integer value
for the SPBRG register can be calculated using the formula:

Table 6.3: Baud rate formula

6.2.8 USART ASYNCHRONOUS MODE

In this mode, the USART uses standard non-return-to zero (NRZ) format (one START
bit, eight or nine data bits and one STOP bit). The most common data format is 8-bits. An
onchip dedicated 8-bit baud rate generator can be used to derive standard baud rate
frequencies from the oscillator. The USART transmits and receives the LSB first. The
USART’s transmitter and receiver are functionally independent, but use the same data
format and baud rate. Asynchronous mode is selected by clearing bit SYNC
(TXSTA<4>).
The USART Asynchronous module consists of the following important elements:
• Baud Rate Generator
• Asynchronous Transmitter
• Asynchronous Receiver

6.2.8.1 USART Asynchronous Transmitter

The heart of the transmitter is the Transmit (serial) Shift Register (TSR). The shift
register obtains its data from the read/write transmit buffer, TXREG. The TXREG
register is loaded with data in software. The TSR register is not loaded until the STOP bit
has been transmitted from the previous load. As soon as the STOP bit is transmitted, the
TSR is loaded with new data from the TXREG register (if available). Once the TXREG
register transfers the data to the TSR register, the TXREG register is empty and flag bit
TXIF (PIR1<4>) is set.

To set up an asynchronous transmission:

1. Initialize the SPBRG register for the appropriate baud rate. If a high speed baud rate
is desired, set bit BRGH.
2. Enable the asynchronous serial port by clearing bit SYNC and setting bit SPEN.
3. Enable the transmission by setting bit TXEN, which will also set bit TXIF.
4. Load data to the TXREG register (starts transmission).

6.2.8.2 USART Asynchronous Receiver

The data is received on the RC7/RX/DT pin and drives the data recovery block. The data
recovery block is actually a high speed shifter operating at x16 times the baud rate,
whereas the main receive serial shifter operates at the bit rate or at FOSC. This mode
would typically be used in RS-232 systems.
To set up an Asynchronous Reception:

1. Initialize the SPBRG register for the appropriate baud rate. If a high speed baud rate
is desired, set bit BRGH.
2. Enable the asynchronous serial port by clearing bit SYNC and setting bit SPEN.
3. Enable the reception by setting bit CREN.
4. Flag bit RCIF will be set when reception is complete
5. Read the 8-bit received data by reading the RCREG register.
6.3 GPS RECEIVER BOARD

Fig:
6.7
GPS

Receiver Board
6.4 PIC 18F452 MICROCONTROLLER BOARD

Fig 6.8: PIC 18F452 microcontroller board

7: ALGORITHM AND FLOWCHART FOR DATA EXTRACTION

7.1 ALGORITHM FOR DATA EXTRACTION

1. START
2. Do the initializations for serial communication, the UART and the LCD.
3. Start receiving characters through UART.
4. Check whether the character received is ‘$’. I. If not, GOTO 2.
II. If so, transfer the characters after $ to registers pointed to by the File
Select Register.
5. Check whether the received character is ‘*’.
I. If not, continue transfer of characters to the registers pointed to by File
Select Register.
II. If so, stop transfer
6. Display “GPS NAVIGATION SYS” on the first line (address: 80H) of LCD
through the use of data tables and move to the second line.
7. Move initial address to File Select Register.
8. Start inspection of character in the INDF register.
9. Ignore characters till the first comma (‘,’), after the first comma, proceed.
10. Transfer the six digits (which specify time) after comma (‘,’) to six registers
and return
11. Pair up the digits in the six registers to specify hour, minute and second
respectively using AND operation
12. GOTO 23 13. GOTO 24
14. GOTO 25
15. On the second line (address: C0H) of the LCD, display content of hour
register followed by a colon (‘:’).
16. In the same line, display content of minutes register followed by a colon (‘:’).
17. Again, in the same line, display content of seconds register
18. In the third line (address: 94H) of the LCD, display “LAT:” through the use
of data tables.
19. GOTO 26
20. In the fourth line (address: D4H) of the LCD, display “LON:” through the use
of data tables.
21. GOTO 27
22. There are two commas after the longitude data. Check for these and display
characters after these two at a time followed by a slash (‘/’) each time till the
next comma. This represents the date.
23.
I. The IST is 5 hours, 30 minutes and 3 seconds ahead of GMT. So add 3
to the value of seconds stored in the register.
II. If this value turns out to be greater than 60, increment the minute
register by 1 and decrement the seconds register by 60.

24. The IST is 5 hours, 30 minutes and 3 seconds ahead of GMT. So add 30 to the
value of minutes stored in the register.
I. If this value turns out to be greater than 60, increment the hour
register by 1 and decrement the minutes register by 60.
25.
I. The IST is 5 hours, 30 minutes and 3 seconds ahead of GMT. So
add 5 to the value of hours stored in the register.
II. If this value turns out to be greater than 24, decrement the hour
register by 24.
26. Transmit the characters after the third comma (‘.’) till the next comma to the
third line of the LCD (after “LAT :”). This comprises the Latitude data.
27. Transmit the characters after the fifth comma (‘,’) till the next comma to the
fourth line of the LCD (after “LON :”). This comprises the longitude data.
28. END

7.2 FLOWCHART FOR DATA EXTRACTION


START

INITIALISE SERIAL
COMMUNICATION, THE UART
AND THE LCD

RECEIVE DATA WHICH ARE


SANDWICHED BETWEEN “$”
AND “*”

DISPLAY “GPS NAVIGATION SYS”


ON THE FIRST LINE OF LCD

EXTRACT THE SIX DIGITS AFTER


THE FIRST COMMA AND PERFORM
MANIPULATIONS TO GET THE TIME

DISPLAY TIME ON SECOND


LINE OF LCD

A
A

DISPLAY “LAT:” ON THE SECOND LINE OF


THE LCD

EXTRACT LATITUDE DATA – THE DATA


AFTER THE THIRD COMMA

DISPLAY LATITUDE DATA ON SECOND


LINE AFTER “LAT:”

DISPLAY “LON:” ON THE THIRD LINE OF


THE LCD

B
B

EXTRACT LONGITUDE DATA – THE DATA


AFTER THE FIFTH COMMA

DISPLAY LONGITUDE DATA ON


SECOND LINE AFTER “LON:”

EXTRACT DATE – THE DATA AFTER THE


NINTH COMMA AND DISPLAY IT

END

8: TRACKING OF A TARGET LOCATION

This module has been designed to track a target location with reference to the current
location and has been built as scope of the project. Software used for this is visual Basic.

In this, the antenna is mounted on a toy car. Now the location shown by the GPS system
designed so far is the position of the car. This data is given to the Visual Basic program.
A target location is typed in the Visual Basic form. Now comparison of the current
location and target location takes place. Using a set of nine conditions, the toy car is
directed to move towards the target location by controlling it using signals from the
parallel port.

This module is totally software based. Hence the Visual Basic program used is enclosed
in the following pages

9: PROGRAMS

9.1 PIC18F452 PROGRAM

LIST P=PIC18F452
INCLUDE"P18F452.INC"

; Declaring general purpose registers

CBLOCK 80H
SEC
RESU
RLT
MIN
HUR
R1
RG1
REG1
REG2
DAT
TEMP
NO1
NO2
NO3
NO4
NO5
NO6
CON1
CON2
HR
MN
SC
TEM
SC1
MN1
REG
COUNT
REG11
RESULT
ENDC
ORG 200H
RVReset
GOTO START
ORG 208H
RVIntH
RETFIE
ORG 218H
RVIntL
RETFIE

START
MOVLB 0
CALL SE_INIT
CALL UART_INIT
MOVLB 0F
CLRF TRISD
CLRF TRISA
MOVLW 0X06
MOVWF ADCON1
CALL LCD_INIT MOVLB
0F
LFSR 0,0X0A0

; Extracting data between ‘$’ and ‘*’


REP
CALL UART_RECX
MOVLW '$'
CPFSEQ DAT
GOTO REP
MOVFF DAT,INDF0
MOVLB 0F
INCF FSR0L,1
MOVLB 0
RP
MOVF DAT,0
CALL UART_RECX
MOVLB 0
MOVFF DAT,INDF0
MOVLB 0F
INCF FSR0L,1
MOVLW '*' MOVLB 0
CPFSEQ DAT
GOTO RP
MOVF DAT, 0
CALL DISP1
LFSR 0,0X0A0
GOTO REP

; Serial transmission initialization

SE_INIT
MOVLB 0F
BSF RCSTA,SPEN
BSF RCSTA,CREN
BSF TXSTA,TXEN
BCF TXSTA,BRGH
BCF TXSTA,SYNC
MOVLW 09H
MOVWF SPBRG
RETURN

; LCD initialization

LCD_INIT
BCF PORTA,0
MOVLW 3CH
MOVWF PORTD
CALL L_SEND
MOVLW 01H
MOVWF PORTD
CALL L_SEND
MOVLW 02H
MOVWF PORTD
CALL L_SEND
MOVLW 06H
MOVWF PORTD
CALL L_SEND
MOVLW 0X0E
MOVWF PORTD
CALL L_SEND
RETURN
; Displaying data on LCD

LCD
MOVLB 0F
BSF PORTA,0
MOVWF PORTD
CALL L_SEND
RETURN
L_SEND
BSF PORTA,1
CALL DELAY
CALL DELAY
BCF PORTA,1
CALL DELAY
CALL DELAY
RETURN

; Transmission

TRANX
MOVLB 0F
MOVWF TXREG
NOP
BTFSS PIR1,TXIF
GOTO $-1
RETURN

; Reception

RECX
BTFSS PIR1,RCIF GOTO $-1
MOVF RCREG,0
MOVLB 0
MOVWF RG1
RETURN

DISP1
CALL DISP
MOVLB 0F
BCF PORTA,0
MOVLW 0XC1
MOVWF PORTD
CALL L_SEND
LFSR 0,0X0A0

; Complete sequence explaining flow of program AS2


MOVLW ','
CPFSEQ INDF0
GOTO AS1
CALL TTIME
CALL HMS
CALL SEC_CON
MOVWF SEC
CALL MIN_CON
MOVWF MIN
CALL HR_CON
MOVWF HUR
CALL DSP_HR
CALL DSP_MN
CALL DSP_SC
CALL ARV
CALL DLAT
CALL LAT
CALL DLONG
CALL LONG
CALL DATE
INV
RETURN
AS1
INCF FSR0L,1
GOTO AS2

; Puts six digits of time into six registers

TTIME
INCF FSR0L,1
MOVF INDF0,0
MOVLB 0
MOVWF NO1
MOVLB 0F

INCF FSR0L,1
MOVF INDF0,0
MOVLB 0
MOVWF NO2
MOVLB 0F

INCF FSR0L,1
MOVF INDF0,0
MOVLB 0
MOVWF NO3
MOVLB 0F
INCF
FSR0L,1
MOVF INDF0,0
MOVLB 0
MOVWF NO4
MOVLB 0F

INCF FSR0L,1
MOVF INDF0,0
MOVLB 0
MOVWF NO5
MOVLB 0F

INCF FSR0L,1
MOVF INDF0,0
MOVLB 0
MOVWF NO6
MOVLB 0F

RETURN

; Separates time data as hours, minutes and seconds and stores them in 3 registers

HMS
MOVLB 0
MOVFF NO1,CON1
MOVFF NO2,CON2
CALL ADD
MOVWF HR
MOVLW ':' MOVLB 0
MOVFF NO3,CON1
MOVFF NO4,CON2
CALL ADD
MOVWF MN
MOVLW ':' MOVLB 0
MOVFF NO5,CON1
MOVFF NO6,CON2
CALL ADD
MOVWF SC
RETURN

; Does ‘AND’ operation to concatenate numbers

ADD
MOVLW 0X0F
ANDWF CON1,1
SWAPF CON1,1
MOVLW 0X0F
ANDWF CON2,0
ADDWF CON1,0
RETURN

; Adds 30 to the numbers

NUMBER
MOVLB 0
MOVWF TEM
MOVWF REG
MOVLW 0XF0
ANDWF REG,1
SWAPF REG,0
ADDLW 30H
CALL LCD MOVLB 0
MOVLW 0X0F
ANDWF TEM,0
ADDLW 30H
CALL LCD
RETURN

; Performs seconds conversion

SEC_CON
MOVLB 0
MOVF SC,0
ADDLW 03H
DAW
MOVWF RESULT MOVLW 60H
CPFSEQ RESULT
GOTO NE
MOVLW
00H INCF MN,1
RETURN NE
CPFSGT RESULT
GOTO NG
INCF MN,1
MOVLW 0X60
SUBWF RESULT,0
RETURN
NG CPFSLT RESULT
GOTO NL
MOVF RESULT,0
NL
RETURN
; Performs minute conversion

MIN_CON
MOVLB 0
MOVF MN,0
ADDLW 30H
DAW
MOVWF RESU
MOVLW 60H
CPFSEQ RESU
GOTO ME
MOVLW
00H INCF HR,1
RETURN ME

CPFSGT RESU
GOTO MG
INCF HR,1
MOVLW 0X60
SUBWF RESU,0
RETURN
MG
CPFSLT RESU
GOTO ML
MOVF RESU,0
ML
RETURN

; Performs Hour conversion

HR_CON
MOVLB 0
MOVF HR,0
ADDLW 05H
DAW
MOVWF RLT
MOVLW 24H
CPFSEQ RLT
GOTO HE
MOVLW
00H RETURN HE

CPFSGT RLT GOTO


HG
MOVLW 0X24
SUBWF RLT,0
RETURN
HG
CPFSLT RLT
GOTO HL
MOVF RLT,0
HL
RETURN

; Displays hour data of time

DSP_HR
MOVF HUR,0
CALL NUMBER
MOVLW ':'
CALL LCD
RETURN

; Displays minute data of time


DSP_MN
MOVLB 0
MOVF MIN,0
CALL NUMBER
MOVLW ':'
CALL LCD
RETURN

; Displays seconds data of time

DSP_SC
MOVLB 0
MOVF SEC,0
CALL NUMBER
RETURN

; Checks for valid data

ARV
MOVLB 0F
MP
INCF FSR0L,1
MOVLW ','
CPFSEQ INDF0
GOTO MP
INCF FSR0L,1
MOVLW 'A'
CPFSEQ INDF0
GOTO INV
MOVLW 'A'
RETURN

; Displays “LON” on fourth line of LCD

DLONG
MOVLB 0F
BCF PORTA,0
MOVLW 0XD4
MOVWF PORTD
CALL L_SEND
MOVLB 0
MOVLW 0X3C
MOVWF COUNT
CALL XX
RETURN

; Displays “LAT” on third line of LCD


DLAT
MOVLB 0F
BCF PORTA,0
MOVLW 0X94
MOVWF PORTD
CALL L_SEND
MOVLB 0
MOVLW 0X2C
MOVWF COUNT
CALL XX
RETURN

; Displays from data table

DISP
MOVLB 0F
MOVLW 08H
MOVWF PCLATH
MOVLB 0
CLRF COUNT
MOVLB 0F
BCF PORTA,0
MOVLW 0X80
MOVWF PORTD
CALL L_SEND

; Moves data from data table and checks for end of line XX
MOVLB 0
MOVF COUNT,0
MOVLB 0Fb
CALL LOOK
MOVLB 0
MOVWF REG11
MOVLW '*'
CPFSEQ REG11
GOTO YY
RETURN
YY
MOVF REG11,0
CALL LCD
MOVLB 0
INCF COUNT,1
INCF COUNT,1
CALL DELAY
CALL DELAY
GOTO XX

; Displays latitude data on third line of LCD


LAT
MOVLB 0F
EF
INCF FSR0L,1
MOVLW ','
CPFSEQ INDF0
GOTO EF
INCF FSR0L,1
MOVLW '.'
CPFSEQ INDF0
GOTO ED
MOVF
INDF0,0 CALL
LCD GOTO ER ED

MOVF INDF0,0
CALL TRANX
CALL LCD
ER
INCF FSR0L,1
MOVLW ','
CPFSEQ INDF0
GOTO ED
INCF FSR0L,1
MOVF INDF0,0
CALL LCD
RETURN

; Displays longitude data on fourth line of LCD

LONG
MOVLB 0
GH
INCF FSR0L,1
MOVLW ','
CPFSEQ INDF0
GOTO GH
LONG_N
INCF FSR0L,1
CPFSEQ INDF0
GOTO LONG_T
GOTO EG
LONG_T
MOVF INDF0,0
CALL TRANX
CALL LCD MOVLW
','
GOTO LONG_N
EG
INCF FSR0L,1
MOVF INDF0,0
CALL LCD
RETURN

; UART initialization

UART_INIT

;Ports

MOVLB 0F
CLRF TRISB
CLRF TRISC
CLRF TRISE

;Make analog to digital

MOVLW 06H
MOVWF ADCON1

;Address line
MOVLW 03H
MOVWF PORTE
BCF PORTE,2

; Data line

MOVLW 03H
MOVWF PORTC MOVLW 80H
MOVWF PORTB
CALL SEND

; Baud rate low byte

MOVLW 00H
MOVWF PORTC MOVLW 18H
MOVWF PORTB
CALL SEND

; Baud rate high byte

MOVLW 01H
MOVWF PORTC MOVLW 00H
MOVWF PORTB
CALL SEND
; Word length selection

MOVLW 03H
MOVWF PORTC MOVLW 03H
MOVWF PORTB
CALL SEND
RETURN
SEND
BCF PORTE,1
CALL DELAY
BSF PORTE,1
RETURN

; UART reception

UART_RECX
MOVLB 0F
SETF TRISB
RE
MOVLB 0F
MOVLW 05H
MOVWF PORTC
BCF PORTE,0
MOVF PORTB,0
BSF PORTE,0
MOVLB 0
MOVWF TEMP
BTFSS TEMP,0
GOTO RE
MOVLB 0F
MOVLW 00H
MOVWF PORTC
BCF PORTE,0
MOVF PORTB,0
BSF PORTE,0
MOVLB 0
MOVWF DAT
RETURN

; Giving delay

DELAY
MOVLB 0
MOVLW 0XFF
MOVWF REG2
DECFSZ REG2,1
GOTO $-1
MOVLB 0F
RETURN

; Extracting date

DATE
BCF PORTA,0
MOVLW 0XCA
MOVWF PORTD
CALL L_SEND

DS
INCF FSR0L,1
MOVLW ','
CPFSEQ INDF0
GOTO DS
DX
INCF FSR0L,1
MOVLW ','
CPFSEQ INDF0 GOTO DX

; Displays date

DM
INCF FSR0L,1
MOVLW ','
CPFSEQ INDF0
GOTO DM
INCF FSR0L,1
MOVF INDF0,0
CALL LCD
INCF FSR0L,1
MOVF INDF0,0
CALL LCD
MOVLW '/'
CALL LCD
INCF FSR0L,1
MOVF INDF0,0
CALL LCD
INCF FSR0L,1
MOVF INDF0,0
CALL LCD
MOVLW '/'
CALL LCD
INCF FSR0L,1
MOVF INDF0,0
CALL LCD
INCF FSR0L,1
MOVF INDF0,0
CALL LCD
RETURN

; Data table

ORG 800H
LOOK
ADDWF PCL,1
DT " GPS NAVIGATION SYS *"
DT " LAT :*" ;28
DT " LON :*";3C
END

9.2 VISUAL BASIC PROGRAM

OPTION EXPLICIT
PRIVATE DECLARE SUB PORTOUT LIB "IO.DLL" (BYVAL PORT AS INTEGER,
BYVAL DATA AS BYTE)
PRIVATE DECLARE SUB PORTWORDOUT LIB "IO.DLL" (BYVAL PORT AS
INTEGER, BYVAL DATA AS INTEGER)
PRIVATE DECLARE SUB PORTDWORDOUT LIB "IO.DLL" (BYVAL PORT AS
INTEGER, BYVAL DATA AS LONG)
PRIVATE DECLARE FUNCTION PORTIN LIB "IO.DLL" (BYVAL PORT AS
INTEGER) AS BYTE
PRIVATE DECLARE FUNCTION PORTWORDIN LIB "IO.DLL" (BYVAL PORT AS
INTEGER) AS INTEGER
PRIVATE DECLARE FUNCTION PORTDWORDIN LIB "IO.DLL" (BYVAL PORT
AS INTEGER) AS LONG
PRIVATE DECLARE SUB SETPORTBIT LIB "IO.DLL" (BYVAL PORT AS
INTEGER, BYVAL BIT AS BYTE)
PRIVATE DECLARE SUB CLRPORTBIT LIB "IO.DLL" (BYVAL PORT AS
INTEGER, BYVAL BIT AS BYTE)
PRIVATE DECLARE SUB NOTPORTBIT LIB "IO.DLL" (BYVAL PORT AS
INTEGER, BYVAL BIT AS BYTE)
PRIVATE DECLARE FUNCTION GETPORTBIT LIB "IO.DLL" (BYVAL PORT AS
INTEGER, BYVAL BIT AS BYTE) AS BOOLEAN
PRIVATE DECLARE FUNCTION RIGHTPORTSHIFT LIB "IO.DLL" (BYVAL PORT
AS INTEGER, BYVAL VAL AS BOOLEAN) AS BOOLEAN
PRIVATE DECLARE FUNCTION LEFTPORTSHIFT LIB "IO.DLL" (BYVAL PORT
AS INTEGER, BYVAL VAL AS BOOLEAN) AS BOOLEAN
PRIVATE DECLARE FUNCTION ISDRIVERINSTALLED LIB "IO.DLL" () AS
BOOLEAN
DIM PORTNO, I, J AS INTEGER DIM
INP AS STRING
DIM DLAT(40), DLON(50) AS SINGLE
DIM LA, LO, S, T, TLAT, TLON, PLAT, PLON, SLON, SLAT, LLON, LLAT AS
SINGLE
PRIVATE SUB COMMAND2_CLICK()
TIMER2.ENABLED = TRUE
COMMAND4.VISIBLE = TRUE
COMMAND2.VISIBLE = FALSE
END SUB

PRIVATE SUB COMMAND3_CLICK()


IF MSCOMM1.PORTOPEN THEN MSCOMM1.PORTOPEN = FALSE
UNLOAD ME
END SUB

PRIVATE SUB COMMAND1_CLICK()


MSCOMM1.SETTINGS = "9600,N,8,1"
MSCOMM1.INPUTLEN = 1
SLAT = TEXT2
SLON = TEXT3
TIMER1.ENABLED = TRUE
FOR I = 1 TO 20
DLAT(I) = PLAT + 0.002
NEXT I
FOR I = 40 TO 21 STEP -1
DLAT(I) = PLAT - 0.002
NEXT I
FOR J = 1 TO 25
DLON(J) = PLON + 0.0025
NEXT J
FOR J = 50 TO 26 STEP -1
DLON(J) = PLON - 0.0025
NEXT J
END SUB

PRIVATE SUB COMMAND4_CLICK()


TIMER2.ENABLED = FALSE
COMMAND2.VISIBLE = TRUE
END SUB

PRIVATE SUB COMMAND5_CLICK()


'CALL CLRPORTBIT(&H378, 0): CALL CLRPORTBIT(&H378, 1): CALL
CLRPORTBIT(&H378, 2): CALL CLRPORTBIT(&H378, 3): CALL
CLRPORTBIT(&H378, 4): CALL CLRPORTBIT(&H378, 5): CALL
CLRPORTBIT(&H378, 6): CALL CLRPORTBIT(&H378, 7)
CALL SETPORTBIT(&H378, 3): 'CALL SETPORTBIT(&H378, 1)
END SUB

'PRIVATE SUB COMMAND5_MOUSEDOWN(BUTTON AS INTEGER, SHIFT AS


INTEGER, X AS SINGLE, Y AS SINGLE)
'CALL SETPORTBIT(&H378, 1)
'END SUB'

'PRIVATE SUB COMMAND5_MOUSEUP(BUTTON AS INTEGER, SHIFT AS


INTEGER, X AS SINGLE, Y AS SINGLE)
'CALL SETPORTBIT(&H378, 3)
'END SUB

PRIVATE SUB COMMAND6_CLICK()


CALL CLRPORTBIT(&H378, 0): CALL CLRPORTBIT(&H378, 1): CALL
CLRPORTBIT(&H378, 2): CALL CLRPORTBIT(&H378, 3): CALL
CLRPORTBIT(&H378, 4): CALL CLRPORTBIT(&H378, 5): CALL
CLRPORTBIT(&H378, 6): CALL CLRPORTBIT(&H378, 7)
END SUB

PRIVATE SUB FORM_LOAD()


ON ERROR RESUME NEXT
IF NOT MSCOMM1.PORTOPEN THEN MSCOMM1.PORTOPEN = TRUE
IF ISDRIVERINSTALLED = TRUE THEN
PORTNO = &H378
MSGBOX PORTIN(PORTNO)
ELSE
MSGBOX "DRIVER NOT INSTALLED"
END IF
END SUB

PRIVATE SUB TIMER1_TIMER() '


MSCOMM1.RTHRESHOLD = 1
MSCOMM1.INPUTLEN = 9
TEXT2.TEXT = MSCOMM1.INPUT
MSCOMM1.INPUTLEN = 10
TEXT3.TEXT = MSCOMM1.INPUT
PLAT = TEXT2
PLON = TEXT3
END SUB

'FORWARD - DATA PIN 0,3


'REVERSE - DATA PIN 1,2
'RIGHT - DATA PIN 2,0
'LEFT - DATA PIN 3,1
PRIVATE SUB TIMER2_TIMER()
DIM LA, LO, S, T, TLAT, TLON, PLAT, PLON, SLON, SLAT, LLON, LLAT AS
SINGLE
TLAT = TEXT1
TLON = TEXT4
CALL CLRPORTBIT(&H378, 0): CALL CLRPORTBIT(&H378, 1): CALL
CLRPORTBIT(&H378, 2): CALL CLRPORTBIT(&H378, 3): CALL
CLRPORTBIT(&H378, 4): CALL CLRPORTBIT(&H378, 5): CALL
CLRPORTBIT(&H378, 6): CALL CLRPORTBIT(&H378, 7)

'1ST CONDITION
IF PLON < TLON AND PLAT < TLAT THEN
1:
CALL SETPORTBIT(&H378, 3): CALL SETPORTBIT(&H378, 0)
'IF [(TLAT-SLAT)PLON] - [(TLON-SLON)PLAT] = [(TLAT-SLAT)*SLON] -
[(TLONSLON)*SLAT)] THEN
'CALL SETPORTBIT(&H378, 3)
'ELSE
'IF PLON > LLON THEN CALL SETPORTBIT(&H378, 3): CALL
SETPORTBIT(&H378, 0)
'IF PLON < LLON THEN CALL SETPORTBIT(&H378, 3): CALL
SETPORTBIT(&H378, 1)
'END IF
END IF

'2ND CONDITION
IF PLON < TLON AND PLAT > TLAT THEN
2:
CALL SETPORTBIT(&H378, 3): CALL SETPORTBIT(&H378, 1)
'IF [(TLAT-SLAT)PLON] - [(TLON-SLON)PLAT] = [(TLAT-SLAT)SLON] -
[(TLONSLON)SLAT)] THEN
'CALL SETPORTBIT(&H378, 3)
'ELSE
'IF PLON > LLON THEN CALL SETPORTBIT(&H378, 3): CALL
SETPORTBIT(&H378, 1)
'IF PLON < LLON THEN CALL SETPORTBIT(&H378, 3): CALL
SETPORTBIT(&H378, 0)
'END IF
END IF

'3RD CONDITION
IF PLON < TLON AND PLAT = TLAT THEN CALL SETPORTBIT(&H378, 3)

'4TH CONDITION
IF PLON > TLON AND PLAT < TLAT THEN
DO
CALL SETPORTBIT(&H378, 2)
LOOP UNTIL TLON = PLON + 5
GOTO 1
END IF
'5TH CONDITION
IF PLON > TLON AND PLAT > TLAT THEN
DO
CALL SETPORTBIT(&H378, 2)
LOOP UNTIL TLON = PLON + 5
GOTO 2
END IF

'6TH CONDITION
IF PLON > TLON AND PLAT = TLAT THEN CALL SETPORTBIT(&H378, 2)

'7TH CONDITION
IF PLON = TLON AND PLAT < TLAT THEN
DO
CALL SETPORTBIT(&H378, 2)
LOOP UNTIL TLON = PLON + 5
GOTO 1
END IF

'8TH CONDITION
IF PLON = TLON AND PLAT > TLAT THEN
DO
CALL SETPORTBIT(&H378, 2)
LOOP UNTIL TLON = PLON + 5
GOTO 2
END IF

'9TH CONDITION
IF PLON = TLON AND PLAT = TLAT THEN
CALL CLRPORTBIT(&H378, 0): CALL CLRPORTBIT(&H378, 1): CALL
CLRPORTBIT(&H378, 2): CALL CLRPORTBIT(&H378, 3): CALL
CLRPORTBIT(&H378, 4): CALL CLRPORTBIT(&H378, 5): CALL
CLRPORTBIT(&H378, 6): CALL CLRPORTBIT(&H378, 7)
'MSGBOX "YOU ARE AT THE REQUIRED POSITION: TARGET ACHIEVED"
END IF
LLON = PLON
LLAT = PLAT

END SUB

PRIVATE SUB TIMER3_TIMER()


'CALL CLRPORTBIT(&H378, 0): CALL CLRPORTBIT(&H378, 1): CALL
CLRPORTBIT(&H378, 2): CALL CLRPORTBIT(&H378, 3): CALL
CLRPORTBIT(&H378, 4): CALL CLRPORTBIT(&H378, 5): CALL
CLRPORTBIT(&H378, 6): CALL CLRPORTBIT(&H378, 7)
IF GETPORTBIT(&H378, 0) THEN CHECK1.VALUE = 1 ELSE CHECK1.VALUE =
0
IF GETPORTBIT(&H378, 1) THEN CHECK2.VALUE = 1 ELSE CHECK2.VALUE =
0
IF GETPORTBIT(&H378, 2) THEN CHECK3.VALUE = 1 ELSE CHECK3.VALUE =
0
IF GETPORTBIT(&H378, 3) THEN CHECK4.VALUE = 1 ELSE CHECK4.VALUE =
0
IF GETPORTBIT(&H378, 4) THEN CHECK5.VALUE = 1 ELSE CHECK5.VALUE =
0
IF GETPORTBIT(&H378, 5) THEN CHECK6.VALUE = 1 ELSE CHECK6.VALUE =
0
IF GETPORTBIT(&H378, 6) THEN CHECK7.VALUE = 1 ELSE CHECK7.VALUE =
0
IF GETPORTBIT(&H378, 7) THEN CHECK8.VALUE = 1 ELSE CHECK8.VALUE =
0
END SUB

PRIVATE SUB TIMER4_TIMER()


TLAT = TEXT2.TEXT
TLON = TEXT3.TEXT
IF PLON < TLON AND PLAT < TLAT THEN CALL SETPORTBIT(&H378, 0): CALL
SETPORTBIT(&H378, 2)
IF PLON < TLON AND PLAT > TLAT THEN CALL SETPORTBIT(&H378, 0): CALL
SETPORTBIT(&H378, 3)
IF PLON < TLON AND PLAT = TLAT THEN CALL SETPORTBIT(&H378, 0)
IF PLON > TLON AND PLAT < TLAT THEN CALL SETPORTBIT(&H378, 1): CALL
SETPORTBIT(&H378, 2)
IF PLON > TLON AND PLAT > TLAT THEN CALL SETPORTBIT(&H378, 1): CALL
SETPORTBIT(&H378, 3)
IF PLON > TLON AND PLAT = TLAT THEN CALL SETPORTBIT(&H378, 1)
IF PLON = TLON AND PLAT < TLAT THEN CALL SETPORTBIT(&H378, 1): CALL
SETPORTBIT(&H378, 2)
IF PLON = TLON AND PLAT > TLAT THEN CALL SETPORTBIT(&H378, 1): CALL
SETPORTBIT(&H378, 3)

IF PLON = TLON AND PLAT = TLAT THEN


MSGBOX "YOU ARE AT THE REQUIRED POSITION: TARGET ACHIEVED"

END SUB

10: CONCLUSION
Through this project, the applicability of GPS for target tracking has been demonstrated.
The advantage that GPS offers for target tracking is the very high degree of accuracy.
Hence any location can be tracked by a vehicle very accurately.

The main disadvantage of this system is that it does not possess an obstacle avoidance
system. Incorporation of an obstacle avoidance system into this GPS will improve the
reliability of the system greatly. The accuracy of the system can be improved by using
sophisticated antennas which enable good reception even in covered areas and adverse
climatic conditions.

Thus, exploration and collection of data of potentially hazardous regions can be done with
minimum risk by employing the tracking feature of this system. The mundane job of
landscape surveying can be automated through the implementation of an enhanced
version of this system.

Thus, applications requiring any sort of tracking can make use of the basic principle of
this system to track locate and reach any desired position. Depending on the specific
application, further enhancement of this scheme will lead to the development of a highly
accurate system.
APPENDIX 1: PIN DIAGRAM AND DEVICE FEATURES OF PIC18F452

Pin
diagram Device features of PIC 18F452

AP
PE
ND IX
2:
AR
CHITECTURE OF PIC18F452
AP
PE
N
DI
X
3:
EL
EC
TRICAL CHARACTERSITICS OF PIC18F452

Absolute Maximum Ratings (†)


Ambient temperature under bias -55°C to +125°C

Storage temperature -65°C to +150°C

Voltage on any pin with respect to VSS


(Except VDD, MCLR, and RA4) -0.3V to (VDD + 0.3V)
Voltage on VDD with respect to VSS -0.3V to +7.5V

Voltage on MCLR with respect to VSS 0V to +13.25V

Voltage on RA4 with respect to VSS 0V to +8.5V

Total power dissipation 1.0W

Maximum current out of VSS pin 300 mA

Maximum current into VDD pin 250 mA

Input clamp current, IIK (VI < 0 or VI > VDD) ±20 mA

Output clamp current, IOK (VO < 0 or


VO > VDD) ±20 mA

Maximum output current sunk by any I/O pin 25 mA

Maximum output current sourced by any I/O pin 25 mA

Maximum current sunk by PORTA, PORTB,


and PORTE (combined) 200 mA

Maximum current sourced by PORTA, PORTB,


and PORTE (combined) 200 mA

Maximum current sunk by PORTC


and PORTD (combined) 200 mA

Maximum current sourced by PORTC


and PORTD (combined) 200 mA
APPENDIX 4: UART ARCHITECTURE
APPENDIX 5: PIN DESCRIPTION OF UART16C550
APPENDIX 6: ABSOLUTE MAXIMUM RATINGS—
MAX220/222/232A/233A/242/243

Supply Voltage (VCC) -0.3V to +6V


Input Voltages
TIN -0.3V to (VCC - 0.3V)
RIN (Except MAX220) ±30V RIN (MAX220) ±25V
TOUT (Except MAX220) 15V
TOUT (MAX220) ±13.2V
Output Voltages
TOUT ±15V
ROUT -0.3V to (VCC + 0.3V)
Driver/Receiver Output Short Circuited to GND Continuous
Continuous Power Dissipation (TA = +70°C)
16-Pin Plastic DIP (derate 10.53mW/°C above +70°C) 842mW
18-Pin Plastic DIP (derate 11.11mW/°C above +70°C) 889mW
20-Pin Plastic DIP (derate 8.00mW/°C above +70°C) 440mW
16-Pin Narrow SO (derate 8.70mW/°C above +70°C) 696mW 16-
Pin Wide SO (derate 9.52mW/°C above +70°C) 762mW
18-Pin Wide SO (derate 9.52mW/°C above +70°C) 762mW 20-Pin Wide
SO (derate 10.00mW/°C above +70°C) 800mW
20-Pin SSOP (derate 8.00mW/°C above +70°C) 640mW
16-Pin CERDIP (derate 10.00mW/°C above +70°C) 800mW
18-Pin CERDIP (derate 10.53mW/°C above +70°C) 842Mw

REFERENCES

1.Elliot D Kaplan. (1996) ‘Understanding GPS ‘, Artech house, Boston.

2. US government publication. (1995),’Global Positioning System, Standard Positioning


System Service, Signal specification’.

3. Jean-Marie Zogg.(2002) ‘GPS basics’

4. Assistant secretary of defense (2001) ‘Global Positioning System Standard Positioning


Service Performance Standard’

You might also like