Professional Documents
Culture Documents
Implementation
of a Complete
GPS Receiver
Using Simulink
COMSTOCK
Gihan Hamza,
Abdelhaliem Zekry,
and Ibrahim Motawie
Abstract
During the past few years a lot of efforts
have been exerted to make the inner
working of the GPS receiver visible, clear
and easy to learn and modify either on
the level of software or hardware. This
article adds a step on the route toward
the implementation of a more visible,
clearer, and easier to learn and modify
a single frequency GPS receiver using
the C/A code on the L1 carrier. Simulink
was used in the implementation of such
receiver, thereby introducing a new look
for the SDR technology that can be accomplished via a graphical user interface environment.
I. Introduction
uring the past decade a lot of efforts have been exerted not only
to open the inner working of the GPS receiver but also to facilitate
the education of the design and implementation of such system.
The Software-Defined Radio technique was used as a tool in the implementation. From the efforts that were exerted in this field are:
The open source GPS project that was initiated in 1995 and leaded by
Clifford Killy and Douglas Baker (with collaboration with others) [1].
This project had an educational aims to help any GPS enthusiast to
learn deeply the internal working of the GPS receiver. They developed
both a commercial hardware and software that constitute a complete
GPS receiver. The hardware was introduced by developing two chipsets called GP1010 and GP1020. The GP1010 was used as a front-end
and performs the acquisition phase; while The GP1020 was the tracking and navigation data extraction chip that has 6 correlators channels [2][3]. The software of this project was a C program written in
Borland C. This program contained a library of the GPS functions such
as the satellite location by using the almanac, the ephemeris, computing the navigation solution and decoding the navigation message.
Dick Benson, a consulting application engineer at Mathworks: developed an incomplete single channel GPS receiver using Simulink.
He implemented acquisition, partial tracking, and no pseudorange
in SIMULINK [4].
The efforts of Kai Bore and Dennis Akos (with collaboration with
others) fruited a book titled A Software-Defined GPS and GALILEO
1531-636X/09/$26.002009 IEEE
43
Gihan Hamza is a research assistant in the National Institute of Standards, Guiza, Egypt (Tel: +202-26356263; E-mail: gihan_hamza@yahoo.com).
Abdelhaliem Zekry is a professor in the Faculty of Engineering, Ain Shams University, Cairo, Egypt (Tel: +202-24840051; E-mail: aaazekry@asunet.shams.edu.
eg). Ibrahim Motawie is a professor in the National Institute of Standards, Guiza, Egypt (Tel: +202-35715755; E-mail: motawie@nis.sci.eg).
44
6
PSD Magnitude (dB)
40
Amplitude
4
2
0
2
4
6
20
0
20
40
60
8
0
0.5
1.5
Time
2.5
105
0
2
Frame
8
10 12 14
Frequency (MHz)
16
18
104
Incoming Signal
16
Number Within Bin
14
Acquisition
12
10
8
Tracking
6
4
2
0
8
Bins
10
12
14
16
Pseudorange
and Position Calculation
X, Y, Z dt
samples that is shown in Fig. 4. It is clear that the symmetry is around the IF frequency.
Incoming Signal
Demodulation
Carrier.mdl
Dispreading Code.mdl
Acquisition.mdl
Tracking.mdl
Pseudorange
and
Position Calculation.mdl
X, Y, Z dt
45
|u|2
IDFT
|u|2
IDFT
46
Double [1 8]
[1]
[1]
[1]
Detected
PRN
21
Detected
PRN
22
15
18
26
4.326
4.216
Display
Double [1 8]
Peak
Metric
Peak
Metric
14.62
13.26
12.09
9.4
Display 1
Double [1 8]
Carr Freq
Carr Freq
9548200.3250
Display 2
Double [1 8]
[1]
Code
Phase
Code
Phase
13.404
6288
36321
207xxx
Display 3
fs / 2
,
N/2
(1)
Fig. 9 shows the final results obtained from the acquisition model before resampling. The first branch shows
the PRN of the visible satellites. The second branch illustrates that the peakMetric of all the visible satellites
exceeds 2.5, which is a criteria putted to differentiate
between the visible and nonvisible satellite. The third
branch shows the corresponding carrier frequency of
each visible satellite. The fourth branch gives the corresponding code phases of the detected ones. Fig. 10
shows the acquisition results after resampling with the
results sorted from the strongest to weakest visible satellites. These results are stored in the Workspace as inputs to the tracking. Comparing the results of Fig. 9 and
Fig. 10, we see that the resampling process has a minor
effect on the acquisition process in spite of reducing the
acquisition time to only its 1/3 of its original value. Fig.
11 and Fig. 12 show the acquisition results for one of the
visible satellites and invisible satellites respectively. It
is clear that the visible satellite has a single dominant
peak while the nonvisible satellite doesnt have a distinct peak such that the ratio of the first to second peak
is more than 2.5.
E. Tracking
The main purpose of tracking is to refine the acquisition
results, track any changes that occur to these values,
and demodulate the incoming signal to obtain the 50 Hz
navigation data bits.
IEEE CIRCUITS AND SYSTEMS MAGAZINE
47
21
22
15
18
26
Detected
PRN
Double [32 1]
Double [8 1]
12.56
Detected
PRN
Detected
PRN
12.32
12.15
Display
10.09
Peak Metric
Double [32 1]
Double [8 1]
for {...}
Carr Freq
Double [32 1]
Double [32 1]
Carr Freq
Carr Freq
Double [8 1]
4.421
9547429.6875
3.372
9549695.3125
3.006
9549921.875
2.938
9548250
Display 1
9545015.625
9550843.75
Double [8 1]
Code Phase Code Phase
13404
9544312.5
6288
9549914.0625
36321
Display 2
20725
26826
4696
or Iterator
28202
34211
Display 3
Tracking consists of a carrier tracking loop implemented as a PLL and a code phase tracking loop implemented as a DLL. The two loops are combined in one
loop to decrease the number of multipliers that consume a lot of time. Fig. 13 shows the combined code and
carrier tracking loops, i.e., a complete tracking channel
[5]. The implementation of these loops in Simulink is
107
107
12
10
8
6
4
2
0
4
104
0 0
10
15 20
48
25
30
12
10
8
6
4
2
0
4
104
0 0
10
15 20
25
30
a refined value for the carrier frequency, the fourth block is the
PRN code generator which provide the early, late, and prompt
codes. The fifth block is the integrate block at which we integrate
over the number of samples per
C/A code for the early, late, and
prompt codes. This block consists of summing blocks. The
sixth block is the code loop discriminator, which helps in adjusting the code phase. This discriminator was built as a noncoherent
discriminator according to the
following equation:
codeError 5
1 I 2E 1 Q2E 2 2 1 I 2L 1 Q2L 2
1 I 2E 1 Q2E 2 1 1 I 2L 1 Q2L 2
Integrate lE
and Dump
Integrate lP
Data
and Dump
P
Integrate
and Dump
lL
L
Incoming
Signal
Code Loop
Discriminator
PRN Code
Generator
L
Integrate
and Dump QL
Integrate
and Dump QP
Integrate
and Dump QE
90
NCO Carrier
Generator
(2)
Carrier Loop
Filter
Carrier Loop
Discriminator
Figure 13. Combined code and carrier tracking loops (complete tracking channel).
Q
f 5 tan 21 a b,
I
For 1 : N
1
Iterator
chNo
For Iterator
> 37000 Compare To Constant
4
fid
R
fid
IncomingSignal
PhaseStep abSample
remPhase
U
PhaseStep
remPhase_N
FeedBackBlock
remPhase
blksize
3
fid
iBaseband
Signal
qaseband
Signal
earlyCode
RemPhase
lateCode
acqFreq
carrSin
PhaseStep
R
promptCode
blkSize carrCos
caCode
3
carrFreq_N
tcode_P
caCode
remPhase_N
PRN Code
tcode_P
Generator
NCO Carrier
Generator
Incoming Signal
2
acqFreq
(3)
IE
IP
IL
QE
IL
QL
IE
QE
IL
QL
IP
QP
Code Loop
Discriminator
Reset
I_E codeNco
Q_E
I_L
codeFreq
Q_L
Integrate Resetting
the I/P Is the Dump
2
Out4
Reset
carrError
1
I_P
Out2
Q_P
carrFreq
acqFreq
Carrier
Loop
Discriminator
and Loop
Filter
Figure 14. Top view for the Trackink.mdl (the implementation of the tracking loops in Simulink).
49
x 104
1.5
Tracking Result
1
0.5
Calculate Pseudorange
0
0.5
1
1.5
0 100 200 300 400 500 600 700 800 900 1,000
Tracking Results
Find Preamble
Subframe Start
Calculate Pseudorange
Pseudorange
Sat. Clock
Correction
Ephemeris
Satellite Position
Ephemeris
TOW
Sat. Position
Figure 17. The block diagram according to which the Pseudorange and position calculation was built in SIMULINK.
pseudoranges
[1x8]
satClkCorr
corrected_psuedoranges
Double [1x8]
21285293.33907
22688941.376222
[1x8]
Display
pos
[1x8]
navSolutions.channel.correctedP
[1x4]
[1x4]
UY
Double
pos(1)X
Double
477646.66344317
Display 1
[1x8]
[1x4]
UY
Double
pos(1)Y
Double
4429017.6790361
Display 2
[1x4]
UY
Double
pos(1)Z
Double
1403.372632145
4720789.6023873
Display 3
4079720.7646892
519510.63323641
[1x4]
Display 4
72.558332232667
[1x8]
46.486710475713
57.26070306979
72.483443421818
Display 5
easier building, debugging, and modification in SIMULINK environment. Fig. 15 shows a part of the navigation data extracted from one of the receiver channels.
50
The simulation time for the tracking algorithm that implemented as m-files (tracking.m) for a single channel was
about 20 minutes while the time for that implemented as a
FOURTH QUARTER 2009
National Institute for Standards (NIS) in the Time and Frequency Department and a PhD student. She is interested
in the time and frequency dissemination through using
GPS receivers.
III. Conclusion
In general, system design becomes easier and clearer if it is
accomplished via a graphical user interface environment.
The simulated model has an educational and commercial
aims. The educational aims come from the transparency
in the design and simulation of any part of the algorithm.
Also, it is very easy to modify, debug, or test any part of
the system. The commercial aims are embedded in the
tools available in Simulink, such as the RTW embedded
coder [10], [11].
Gihan Hamza received her BSc in Communications and Electronics from Ain
Shams University, Egypt in 1998. She
received the MSc degree from the same
university in 2004 in the field of automating the long-term measurements.
Now, she is a research assistant in the
FOURTH QUARTER 2009
51