MATLAB Code (GPS and Galileo Receiver) Part 2

Tracking Function

This function tracks the GPS signals allocated to each channel; see Figure A.3.

The function takes the following parameters: a block of the recorded signal from the front end, structure channel, sine, cosine, and C/A code tables. The function processes the block of the samples and returns two structures: tracking results track Results and an updated structure channel.

Structure channel is used to pass initial information for each channel and is also used to store information on the current channel. The second purpose of this structure is to make the tracking continuous. In this way, processing of two or more signal blocks can be made continuous. The structure contains current (from last processed ms) information on the carrier frequency, code phase, PRN number of the track satellite, temporal values for the loop filters, and local signal generators.

The parameters for carrier tracking are contained in the settings structure

PLL_dampingRatio Damping ratio.

PLL_noiseBandwidth Noise bandwidth of the PLL.

The list below is the code tracking specific variables contained in the settings structure:

DLL_CACorrelatorSpacing Spacing between the early and late correlators, unit of chip.

DLL_dampingRatio Damping ratio for the delay lock loop.

DLL_noiseBandwidth Noise bandwidth of the delay lock loop.


The structure trackResults is the main output from tracking function. It contains results for all channels and for each ms of the processed block: information about signal properties (carrier frequency and code phase) and outputs from all six correlators and the loop discriminator.

The output from the tracking code is used as input for the postNavigation function. Additional information is used to plot tracking results and to analyze performance of the receiver. Execute command plotTracking to plot results for any individual channel.

Function postNavigation

The function starts by finding bit transitions and preamble locations. Then the bit values are obtained. The ephemerides are decoded. This involves only information from subframes 1, 2, and 3. Also decoding of subframes 4 and 5 may be included; see Figure A.4.

Next the function calls the pseudorange measurement function and computes position coordinates. Pseudorange and position computations are done covering a specified period described in the receiver settings.

The input for the function is the tracking results and settings structure and the output is pseudoranges and receiver coordinates. The function postNavigation reads the following variables:

navSolPeriod Tells the software how often pseudoranges and position should be computed.

Flow diagram for the position computation.

FIGURE A.4. Flow diagram for the position computation.

elevationMask Satellite elevation mask. Sets the minimum elevation angle for a satellite to be included in the computation of the position solution. Signals from satellites at low elevation angles are contaminated by large atmospheric errors.

UTMzone UTM Zone to be used for the coordinate transformation (ECEF to UTM). This is an integer that depends on the location of the receiver.

truePosition If an accurate position of the receiver antenna is known, then the Easting, Northing, and Upping coordinates of the antenna can be specified. These coordinates will be subtracted from the ones computed by the software receiver, and the result will be plotted.

You may enter (E, N, U) either as approximate coordinates or as zeros.

Pseudorange Computation

This function computes pseudoranges for all tracked satellites. Pseudoranges are not computed for nontracking channels, for channels that have undetected preamble, or for channels that have detected a parity error in the navigation data; see Figure A.5.

The input for the function is the output of the in-phase prompt correlator. The function also needs precise code-phase information. Typically, both inputs are read from the structure trackResults.

Flow diagram for computing pseudoranges.

FIGURE A.5. Flow diagram for computing pseudoranges.


The output of the function is a set of pseudoranges and the signal transmission time (SOW) for all measured pseudoranges.

Position Computation

The function leastSquaresPos computes the position of the receiver from the measured pseudoranges. If for some reason the entire ephemeris for a satellite is not available, the pseudorange is excluded from the computation (see Figure A.6).

At the first computation, the elevation angles of all satellites are set to the maximum. This is necessary to estimate the receiver position and to compute the true elevation angles of all satellites. All subsequent computations of position will exclude pseudoranges from satellites with elevation angles lower than elevation-Mask.

The function postNavigation uses several other functions that are slightly modified versions of functions from the Easy Suite.

At the end of the postNavigation function, the ECEF coordinates are transformed to UTM and geodetic coordinate systems. The results are stored in structure navSolutions.

Least-squares position computation flow diagram.

FIGURE A.6. Least-squares position computation flow diagram.

Next post:

Previous post: