Main Content

GPS HDL Data Decode and Position Estimation

This example shows how to perform bit synchronization, frame synchronization, data decoding, and position estimation on global positioning system (GPS) legacy navigation (LNAV) symbols using Simulink® blocks. The GPS navigation message parameters obtained from data decoding are used for position estimation. All the blocks, except the blocks used for position estimation, are optimized for HDL code generation and hardware implementation. The blocks used for position estimation generate C/C++ code. You can obtain LNAV symbols by performing acquisition and tracking on a GPS baseband waveform using the GPS HDL Acquisition and Tracking Using C/A Code example.

GPS Navigation Message

A GPS navigation message comprises 25 frames. Each frame comprises 5 subframes, and each subframe comprises 10 words. Each word comprises 30 bits in which 24 are data bits and 6 are parity bits. Consequently, each navigation message comprises 37,500 bits. The navigation message transmits at a bit rate of 50 bits per second and has a duration of 12.5 minutes.

The figure shows the content of the first two words of a subframe. Each subframe starts with the telemetry word (TLM), which contains a preamble and a TLM message. The preamble is used to synchronize the frames. The second word in a subframe is the handover word (HOW), which contains the time of week (HOWTOW) message and subframe identifier (ID). The subframe ID provides the subframe number and the TOW increments for every subframe to show the time of the received navigation message in the week. Subframes 2 and 3 contain the ephemeris parameters, which provide the information required to determine the exact position of the transmitting satellite. Subframes 4 and 5 contain the almanac parameters, which are dispersed throughout the message. To extract one full set of almanac data, you require a complete navigation message. Almanac parameters help you to obtain rough position estimates of all 32 GPS satellites.

Model Overview

The gpshdlDataDecodePositionEstimation model in this example mainly consists of the Data Decode and Position Estimation subsystems. The Data Decode subsystem consists of bit synchronization, frame synchronization, data decoding, and data interpretation modules. The inputs to the model are the tracked and frequency-corrected GPS LNAV symbols. The model can process eight satellite channels simultaneously and outputs decoded parameters from all eight channels. The Position Estimation subsystem accepts the decoded parameters to compute visible satellite positions and then the receiver position. This figure shows the high-level overview of the model.

File Structure

The example contains these Simulink models, MATLAB scripts, and MAT files.

  • gpshdlDataDecodePositionEstimation — Decode the LNAV symbols, extract GPS parameters, and compute GPS receiver position.

  • gpshdlDataDecodePosEstInit — Generate parameters and inputs required to run the gpshdlDataDecodePositionEstimation model. The model calls this script using the InitFcn callback.

  • gpshdlDataDecodePosEstConfig — Generate parameters required for data interpretation in the gpshdlDataDecodePositionEstimation model. The gpshdlDataDecodePosEstInit script calls this function.

  • gpshdlDataDecodePosEstPostSim — Collect outputs from the gpshdlDataDecodePositionEstimation model and return a structure of the decoded parameters. The model calls this script in the StopFcn callback.

  • gpshdlDataDecPosEstInputAndReference — This MAT file contains the tracked signals of eight satellites extracted from the GPS waveform. It also contains the acquisition and tracking offset times and the actual receiver position that you can compare with the final estimated position.

  • generateGPSDataDecInputFromPosition — This script generates input to the gpshdlDataDecodePositionEstimation model by using the receiver position. The gpshdlDataDecodePosEstInit script runs this script.

  • gpshdlDataDecodePosEstNavCfg — This MAT file contains the navigation configurations extracted from a RINEX file. The generateGPSDataDecInputFromPosition script uses this file.

Model Interface

This figure shows the top-level view of the gpshdlDataDecodePositionEstimation model. The Data Decode subsystem executes the core data-decoding logic and outputs the decoded parameters. The Prepare Outputs subsystem accepts the serial parameters from the Data Decode subsystem and scales the parameters by appropriate scaling factors. The subsystem also vectorizes these parameters and groups similar parameters. The Position Estimation subsystem computes the receiver position.

Data Decode Subsystem Inputs

The input ports are column vectors of length 8 because the example decodes data from eight satellites simultaneously.

  • lnavSym — Legacy navigation symbols extracted from the GPS waveform, specified as 16-bit complex data.

  • valid — Control signal to validate the lnavSym signal, specified as a Boolean signal.

  • reset — Control signal to reset data decoding, specified as a Boolean signal.

Data Decode Subsystem Outputs

  • parameterSet — Set of GPS parameters decoded and extracted from the input LNAV symbols, returned as a 32-bit signed integer. The subsystem returns the parameters serially in consecutive clock cycles. This port has a length of eight because the subsystem decodes the data from eight satellites simultaneously.

  • parameterSetStart — Control signal that indicates the start of parameterSet. This port has a dimension of eight, because the subsystem decodes the data from eight satellites simultaneously.

  • almanacData — Almanac data of 32 GPS satellites decoded from the first input satellite channel, returned as 25-bit unsigned integer. The subsystem returns these parameters serially in consecutive clock cycles.

  • almanacDataStart — Control signal that indicates the start of almanacData.

  • bitSyncIdx — Bit synchronization index, returned as an 8-by-1 vector. This port returns the sample index of the start of a bit, within a bit duration. This port has a length of eight because the subsystem decodes the data from eight satellites simultaneously.

  • frameSyncIdx — Frame synchronization index, returned as an 8-by-1 vector. This port returns the bit index of the start of a subframe, within a subframe duration. This port has a length of eight because the subsystem decodes the data from eight satellites simultaneously.

  • wordValid — Control signal that indicates when a GPS word is decoded. This port has a length of eight because the subsystem decodes the data from eight satellites simultaneously.

  • decodingActive — Control signal that indicates whether the subsystem can synchronize the LNAV symbols and decode data properly. This port has a length of eight because the subsystem decodes the data from eight satellites simultaneously.

Prepare Outputs Subsystem Outputs

All the outputs that this subsystem returns have double data type.

  • CEI — Clock, ephemeris, and integrity parameters, returned as an 8-by-29 matrix. Each of the satellites has 29 CEI parameters.

  • UTC — Coordinated universal time parameters, returned as an 8-by-8 matrix. Each of the satellites has eight UTC parameters.

  • almanacData — Almanac data of 32 GPS satellites decoded from the first input satellite channel, returned as a 32-by-10 matrix. Each satellite has 10 such almanac parameters.

  • almanacParam — Almanac parameters other than almanacData, returned as an 8-by-34 matrix. Each satellite has 34 such parameters.

  • otherParam — Additional parameters extracted from the LNAV symbols, returned as an 8-by-102 matrix. Each satellite has 102 such parameters.

  • resetOut — Control signal, returned as an 8-by-1 Boolean signal.

Position Estimation Subsystem Inputs and Outputs

All the inputs and outputs of this subsystem have double data type.

  • CEI — Clock, ephemeris, and integrity parameters, specified as an 8-by-29 matrix.

  • otherParam — Additional parameters extracted from the LNAV symbols, specified as an 8-by-102 matrix.

  • coarseCodeOffsetTime — Coarse code phase offset time estimated during acquisition, specified as an 8-by-1 vector.

  • fineCodeOffsetTime — Fine code phase offset time estimated during tracking, specified as an 8-by-1 vector.

  • bitSyncIdx — Bit synchronization index, specified as an 8-by-1 vector.

  • frameSyncIdx — Frame synchronization index, specified as an 8-by-1 vector.

  • wordValid — Control signal, specified as an 8-by-1 vector. This port validates decoded GPS words.

  • estRecPos — Estimated receiver position, returned as a 1-by-3 vector. The position is in latitude, longitude, and altitude (lla) format.

Configure Input Generation Subsystem

Double-click the Configure Input Generation subsystem to choose how to generate the input signal to the model.

  • MAT file — Use the tracked signal stored in the gpshdlDataDecPosEstInputAndReference.mat file as the input signal.

  • Receiver position — Provide the latitude, longitude, and elevation of the receiver and generate the input signal with these position coordinates.

Data Decode Subsystem

This figure shows the Data Decode subsystem that comprises the Data Decode Core and Almanac Data subsystems.

Data Decode Core Subsystem

The Data Decode Core subsystem accepts the GPS LNAV symbols that you obtain by performing acquisition and tracking on the GPS waveform. The subsystem performs bit synchronization to find the start of a bit in the LNAV symbols and then demodulates the symbols to obtain bits. The subsystem performs frame synchronization to find the beginning of the frame and then performs Hamming decoding to recover the data. The subsystem concatenates specific bits of the decoded data to obtain GPS parameters.

The Data Decode Core subsystem contains these main subsystems:

  • Bit Synchronization — Find the bit transition boundary in the LNAV symbols based on the positive-edge and negative-edge transition of the symbols and perform hard-decision decoding to obtain bits.

  • Frame Synchronization and Data Decoding — Check for the preamble sequence in the incoming bits, verify the parity, decode the encoded data, and extract the HOWTOW and subframe ID from the data to verify that both the HOWTOW and subframe ID agree with each other. If all the checks pass, the subsystem confirms that the frame synchronization is successful and forwards the decoded data, one word (24 bits) at a time.

  • Data Interpretation — Select and concatenate a set of bits from the decoded word and then convert the concatenated value from two's complement form to signed integer form to obtain a GPS parameter. This subsystem performs these steps for all the GPS parameters.

  • Serializer — Convert the extracted GPS parameters from vector to serial values.

Almanac Data Subsystem

The Almanac Data subsystem executes the data interpretation and serializer logic for the Almanac. The subsystem takes the decoded words of the first satellite channel from the Frame Synchronization and Data Decoding subsystem and concatenates selective bits from the words to obtain almanac parameters. The subsystem processes only the first satellite channel because the other satellite channels contain similar almanac data.

Position Estimation Subsystem

The Position Estimation subsystem uses the decoded parameters from the Data Decode subsystem to compute the GPS receiver position. It contains these main subsystems and functions:

  • Transmission Time Offset — Compute the time duration starting from signal reception till a valid GPS subframe is detected. The subsystem computes the duration using the coarse, fine code phase time offsets measured by Acquisition and Tracking, and the bit synchronization, frame synchronization indices measured by the Data Decode subsystem.

  • Hold Position Estimation — Hold the position estimation process until a GPS frame is completely decoded.

  • findSatellitePosition — After a GPS frame is decoded, this MATLAB function block uses the transmission time offset and the decoded parameters to estimate GPS satellite positions.

  • findReceiverPosition — Use the estimated satellite positions and the pseudoranges, obtained using the transmission time offsets, to compute the receiver position.

Run Model

Open the gpshdlDataDecodePositionEstimation model and double-click the Configure Input Generation subsystem. Select an option to generate the input signal to the model. Run the model.

Note: When you select the input source as Receiver position, it may take around 25 minutes to complete the simulation.

Actual position in lla    = [69.02100, -6.70000, 9.00000]
Estimated position in lla = [69.02102, -6.69989, 12.93879]
Position error in metres  = 6.26487

Generate HDL Code

To generate HDL code, you must have an HDL Coder™ license. Use the makehdl and makehdltb functions to generate HDL code and an HDL test bench for the Data Decode subsystem.

Synthesize the HDL code for a Xilinx® Zynq®-7000 ZC706 evaluation board. This table shows the post-place-and-route resource utilization. The maximum frequency of operation is 221 MHz.

       Resources       Usage
    _______________    _____

    Slice LUT          15573
    Slice Registers    34562
    DSP48              24   
    RAMB36E1           8    

Generate C/C++ Code

To generate embedded C/C++ code, you must have an Embedded Coder™ license. You can generate the code for the Prepare Outputs and Position Estimation subsystems. To generate embedded code, set the System target file to embedded real-time target and the SIMULATE mode to Normal by running the following commands in the MATLAB command window:

set_param('gpshdlDataDecodePositionEstimation','SystemTargetFile','ert.tlc') and

set_param('gpshdlDataDecodePositionEstimation','SimulationMode','normal')

After running the commands, follow these steps to generate the C/C++ code:

  1. Open the gpshdlDataDecodePositionEstimation model.

  2. On the APPS tab, in the APPS gallery, under CODE GENERATION pane, click Embedded Coder.

  3. On the C CODE tab, click Quick Start to open the Embedded Coder Quick Start tool.

  4. Click Next, select the Subsystem and follow the instructions on the screen.

Appendix

This example uses these helper files:

References

[1]. IS-GPS-200, Rev: L. "NAVSTAR GPS Space Segment/Navigation User Segment Interfaces." GPS Enterprise Space & Missile Systems Center (SMC) - LAAFB. https://www.gps.gov/technical/icwg/IS-GPS-200M.pdf

Related Examples

More About