GNSS-SDR 0.0.21
An Open Source GNSS Software Defined Receiver
Loading...
Searching...
No Matches
GPS_L1_CA.h
Go to the documentation of this file.
1/*!
2 * \file GPS_L1_CA.h
3 * \brief Defines system parameters for GPS L1 C/A signal and NAV data
4 * \author Javier Arribas, 2011. jarribas(at)cttc.es
5 *
6 * -----------------------------------------------------------------------------
7 *
8 * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
9 * This file is part of GNSS-SDR.
10 *
11 * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
12 * SPDX-License-Identifier: GPL-3.0-or-later
13 *
14 * -----------------------------------------------------------------------------
15 */
16
17
18#ifndef GNSS_SDR_GPS_L1_CA_H
19#define GNSS_SDR_GPS_L1_CA_H
20
21#include "MATH_CONSTANTS.h"
22#include "gnss_frequencies.h"
23#include <cstdint>
24#include <utility> // std::pair
25#include <vector>
26
27/** \addtogroup Core
28 * \{ */
29/** \addtogroup System_Parameters
30 * \{ */
31
32
33// carrier and code frequencies
34constexpr double GPS_L1_FREQ_HZ = FREQ1; //!< L1 [Hz]
35constexpr double GPS_L1_CA_CODE_RATE_CPS = 1.023e6; //!< GPS L1 C/A code rate [chips/s]
36constexpr double GPS_L1_CA_CODE_LENGTH_CHIPS = 1023.0; //!< GPS L1 C/A code length [chips]
37constexpr double GPS_L1_CA_CODE_PERIOD_S = 0.001; //!< GPS L1 C/A code period [seconds]
38constexpr double GPS_L1_CA_CHIP_PERIOD_S = 9.7752e-07; //!< GPS L1 C/A chip period [seconds]
39constexpr uint32_t GPS_L1_CA_CODE_PERIOD_MS = 1U; //!< GPS L1 C/A code period [ms]
40constexpr uint32_t GPS_L1_CA_BIT_PERIOD_MS = 20U; //!< GPS L1 C/A bit period [ms]
41
42/*!
43 * \brief Maximum Time-Of-Arrival (TOA) difference between satellites for a receiver operated on Earth surface is 20 ms
44 *
45 * According to the GPS orbit model described in [1] Pag. 32.
46 * It should be taken into account to set the buffer size for the PRN start timestamp in the pseudoranges block.
47 * [1] J. Bao-Yen Tsui, Fundamentals of Global Positioning System Receivers. A Software Approach, John Wiley & Sons,
48 * Inc., Hoboken, NJ, 2nd edition, 2005.
49 */
50constexpr double MAX_TOA_DELAY_MS = 20.0;
51
52// optimum parameters
53constexpr uint32_t GPS_L1_CA_OPT_ACQ_FS_SPS = 2000000; //!< Sampling frequency that maximizes the acquisition SNR while using a non-multiple of chip rate
54
55// OBSERVABLE HISTORY DEEP FOR INTERPOLATION
56constexpr int32_t GPS_L1_CA_HISTORY_DEEP = 100;
57
58// NAVIGATION MESSAGE DEMODULATION AND DECODING
59constexpr double GPS_CA_PREAMBLE_DURATION_S = 0.160;
60constexpr int32_t GPS_CA_PREAMBLE_LENGTH_BITS = 8;
61constexpr int32_t GPS_CA_PREAMBLE_LENGTH_SYMBOLS = 160;
62constexpr int32_t GPS_CA_PREAMBLE_DURATION_MS = 160;
63constexpr int32_t GPS_CA_TELEMETRY_RATE_BITS_SECOND = 50; //!< NAV message bit rate [bits/s]
64constexpr int32_t GPS_CA_TELEMETRY_SYMBOLS_PER_BIT = 20;
65constexpr int32_t GPS_CA_TELEMETRY_RATE_SYMBOLS_SECOND = GPS_CA_TELEMETRY_RATE_BITS_SECOND * GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; //!< NAV message bit rate [symbols/s]
66constexpr int32_t GPS_WORD_LENGTH = 4; //!< CRC + GPS WORD (-2 -1 0 ... 29) Bits = 4 bytes
67constexpr int32_t GPS_SUBFRAME_LENGTH = 40; //!< GPS_WORD_LENGTH x 10 = 40 bytes
68constexpr int32_t GPS_SUBFRAME_BITS = 300; //!< Number of bits per subframe in the NAV message [bits]
69constexpr int32_t GPS_SUBFRAME_SECONDS = 6; //!< Subframe duration [seconds]
70constexpr int32_t GPS_SUBFRAME_MS = 6000; //!< Subframe duration [seconds]
71constexpr int32_t GPS_WORD_BITS = 30; //!< Number of bits per word in the NAV message [bits]
72constexpr char GPS_CA_PREAMBLE[9] = "10001011";
73constexpr char GPS_CA_PREAMBLE_SYMBOLS_STR[161] = "1111111111111111111100000000000000000000000000000000000000000000000000000000000011111111111111111111000000000000000000001111111111111111111111111111111111111111";
74
75// GPS NAVIGATION MESSAGE STRUCTURE
76// NAVIGATION MESSAGE FIELDS POSITIONS (from IS-GPS-200M Appendix II)
77
78// SUBFRAME 1-5 (TLM and HOW)
79
80const std::vector<std::pair<int32_t, int32_t>> TOW({{31, 17}});
81const std::vector<std::pair<int32_t, int32_t>> INTEGRITY_STATUS_FLAG({{23, 1}});
82const std::vector<std::pair<int32_t, int32_t>> ALERT_FLAG({{48, 1}});
83const std::vector<std::pair<int32_t, int32_t>> ANTI_SPOOFING_FLAG({{49, 1}});
84const std::vector<std::pair<int32_t, int32_t>> SUBFRAME_ID({{50, 3}});
85
86// SUBFRAME 1
87const std::vector<std::pair<int32_t, int32_t>> GPS_WEEK({{61, 10}});
88const std::vector<std::pair<int32_t, int32_t>> CA_OR_P_ON_L2({{71, 2}}); //*
89const std::vector<std::pair<int32_t, int32_t>> SV_ACCURACY({{73, 4}});
90const std::vector<std::pair<int32_t, int32_t>> SV_HEALTH({{77, 6}});
91const std::vector<std::pair<int32_t, int32_t>> L2_P_DATA_FLAG({{91, 1}});
92const std::vector<std::pair<int32_t, int32_t>> T_GD({{197, 8}});
93constexpr double T_GD_LSB = TWO_N31;
94const std::vector<std::pair<int32_t, int32_t>> IODC({{83, 2}, {211, 8}});
95const std::vector<std::pair<int32_t, int32_t>> T_OC({{219, 16}});
96constexpr int32_t T_OC_LSB = static_cast<int32_t>(TWO_P4);
97const std::vector<std::pair<int32_t, int32_t>> A_F2({{241, 8}});
98constexpr double A_F2_LSB = TWO_N55;
99const std::vector<std::pair<int32_t, int32_t>> A_F1({{249, 16}});
100constexpr double A_F1_LSB = TWO_N43;
101const std::vector<std::pair<int32_t, int32_t>> A_F0({{271, 22}});
102constexpr double A_F0_LSB = TWO_N31;
103
104// SUBFRAME 2
105const std::vector<std::pair<int32_t, int32_t>> IODE_SF2({{61, 8}});
106const std::vector<std::pair<int32_t, int32_t>> C_RS({{69, 16}});
107constexpr double C_RS_LSB = TWO_N5;
108const std::vector<std::pair<int32_t, int32_t>> DELTA_N({{91, 16}});
109constexpr double DELTA_N_LSB = PI_TWO_N43;
110const std::vector<std::pair<int32_t, int32_t>> M_0({{107, 8}, {121, 24}});
111constexpr double M_0_LSB = PI_TWO_N31;
112const std::vector<std::pair<int32_t, int32_t>> C_UC({{151, 16}});
113constexpr double C_UC_LSB = TWO_N29;
114const std::vector<std::pair<int32_t, int32_t>> ECCENTRICITY({{167, 8}, {181, 24}});
115constexpr double ECCENTRICITY_LSB = TWO_N33;
116const std::vector<std::pair<int32_t, int32_t>> C_US({{211, 16}});
117constexpr double C_US_LSB = TWO_N29;
118const std::vector<std::pair<int32_t, int32_t>> SQRT_A({{227, 8}, {241, 24}});
119constexpr double SQRT_A_LSB = TWO_N19;
120const std::vector<std::pair<int32_t, int32_t>> T_OE({{271, 16}});
121constexpr int32_t T_OE_LSB = static_cast<int32_t>(TWO_P4);
122const std::vector<std::pair<int32_t, int32_t>> FIT_INTERVAL_FLAG({{271, 1}});
123const std::vector<std::pair<int32_t, int32_t>> AODO({{272, 5}});
124constexpr int32_t AODO_LSB = 900;
125
126// SUBFRAME 3
127const std::vector<std::pair<int32_t, int32_t>> C_IC({{61, 16}});
128constexpr double C_IC_LSB = TWO_N29;
129const std::vector<std::pair<int32_t, int32_t>> OMEGA_0({{77, 8}, {91, 24}});
130constexpr double OMEGA_0_LSB = PI_TWO_N31;
131const std::vector<std::pair<int32_t, int32_t>> C_IS({{121, 16}});
132constexpr double C_IS_LSB = TWO_N29;
133const std::vector<std::pair<int32_t, int32_t>> I_0({{137, 8}, {151, 24}});
134constexpr double I_0_LSB = PI_TWO_N31;
135const std::vector<std::pair<int32_t, int32_t>> C_RC({{181, 16}});
136constexpr double C_RC_LSB = TWO_N5;
137const std::vector<std::pair<int32_t, int32_t>> OMEGA({{197, 8}, {211, 24}});
138constexpr double OMEGA_LSB = PI_TWO_N31;
139const std::vector<std::pair<int32_t, int32_t>> OMEGA_DOT({{241, 24}});
140constexpr double OMEGA_DOT_LSB = PI_TWO_N43;
141const std::vector<std::pair<int32_t, int32_t>> IODE_SF3({{271, 8}});
142const std::vector<std::pair<int32_t, int32_t>> I_DOT({{279, 14}});
143constexpr double I_DOT_LSB = PI_TWO_N43;
144
145// SUBFRAME 4-5
146const std::vector<std::pair<int32_t, int32_t>> SV_DATA_ID({{61, 2}});
147const std::vector<std::pair<int32_t, int32_t>> SV_PAGE({{63, 6}});
148
149// SUBFRAME 4
150//! \todo read all pages of subframe 4
151// Page 18 - Ionospheric and UTC data
152const std::vector<std::pair<int32_t, int32_t>> ALPHA_0({{69, 8}});
153constexpr double ALPHA_0_LSB = TWO_N30;
154const std::vector<std::pair<int32_t, int32_t>> ALPHA_1({{77, 8}});
155constexpr double ALPHA_1_LSB = TWO_N27;
156const std::vector<std::pair<int32_t, int32_t>> ALPHA_2({{91, 8}});
157constexpr double ALPHA_2_LSB = TWO_N24;
158const std::vector<std::pair<int32_t, int32_t>> ALPHA_3({{99, 8}});
159constexpr double ALPHA_3_LSB = TWO_N24;
160const std::vector<std::pair<int32_t, int32_t>> BETA_0({{107, 8}});
161constexpr double BETA_0_LSB = TWO_P11;
162const std::vector<std::pair<int32_t, int32_t>> BETA_1({{121, 8}});
163constexpr double BETA_1_LSB = TWO_P14;
164const std::vector<std::pair<int32_t, int32_t>> BETA_2({{129, 8}});
165constexpr double BETA_2_LSB = TWO_P16;
166const std::vector<std::pair<int32_t, int32_t>> BETA_3({{137, 8}});
167constexpr double BETA_3_LSB = TWO_P16;
168const std::vector<std::pair<int32_t, int32_t>> A_1({{151, 24}});
169constexpr double A_1_LSB = TWO_N50;
170const std::vector<std::pair<int32_t, int32_t>> A_0({{181, 24}, {211, 8}});
171constexpr double A_0_LSB = TWO_N30;
172const std::vector<std::pair<int32_t, int32_t>> T_OT({{219, 8}});
173constexpr double T_OT_LSB = TWO_P12;
174const std::vector<std::pair<int32_t, int32_t>> WN_T({{227, 8}});
175constexpr double WN_T_LSB = 1;
176const std::vector<std::pair<int32_t, int32_t>> DELTAT_LS({{241, 8}});
177constexpr double DELTAT_LS_LSB = 1;
178const std::vector<std::pair<int32_t, int32_t>> WN_LSF({{249, 8}});
179constexpr double WN_LSF_LSB = 1;
180const std::vector<std::pair<int32_t, int32_t>> DN({{257, 8}});
181constexpr double DN_LSB = 1;
182const std::vector<std::pair<int32_t, int32_t>> DELTAT_LSF({{271, 8}});
183constexpr double DELTAT_LSF_LSB = 1;
184
185// Page 25 - Antispoofing, SV config and SV health (PRN 25 -32)
186const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV25({{229, 6}});
187const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV26({{241, 6}});
188const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV27({{247, 6}});
189const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV28({{253, 6}});
190const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV29({{259, 6}});
191const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV30({{271, 6}});
192const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV31({{277, 6}});
193const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV32({{283, 6}});
194
195
196// SUBFRAME 5
197//! \todo read all pages of subframe 5
198
199// page 25 - Health (PRN 1 - 24)
200const std::vector<std::pair<int32_t, int32_t>> T_OA({{69, 8}});
201constexpr int32_t T_OA_LSB = TWO_P12;
202const std::vector<std::pair<int32_t, int32_t>> WN_A({{77, 8}});
203const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV1({{91, 6}});
204const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV2({{97, 6}});
205const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV3({{103, 6}});
206const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV4({{109, 6}});
207const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV5({{121, 6}});
208const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV6({{127, 6}});
209const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV7({{133, 6}});
210const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV8({{139, 6}});
211const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV9({{151, 6}});
212const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV10({{157, 6}});
213const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV11({{163, 6}});
214const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV12({{169, 6}});
215const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV13({{181, 6}});
216const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV14({{187, 6}});
217const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV15({{193, 6}});
218const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV16({{199, 6}});
219const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV17({{211, 6}});
220const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV18({{217, 6}});
221const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV19({{223, 6}});
222const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV20({{229, 6}});
223const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV21({{241, 6}});
224const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV22({{247, 6}});
225const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV23({{253, 6}});
226const std::vector<std::pair<int32_t, int32_t>> HEALTH_SV24({{259, 6}});
227
228
229// Almanac
230const std::vector<std::pair<int32_t, int32_t>> ALM_ECC({{69, 16}});
231constexpr double ALM_ECC_LSB = TWO_N21;
232const std::vector<std::pair<int32_t, int32_t>> ALM_TOA({{91, 8}});
233constexpr int32_t ALM_TOA_LSB = static_cast<int32_t>(TWO_P12);
234const std::vector<std::pair<int32_t, int32_t>> ALM_DELTAI({{99, 16}});
235constexpr double ALM_DELTAI_LSB = TWO_N19;
236const std::vector<std::pair<int32_t, int32_t>> ALM_OMEGADOT({{121, 16}});
237constexpr double ALM_OMEGADOT_LSB = TWO_N38;
238const std::vector<std::pair<int32_t, int32_t>> ALM_SVHEALTH({{137, 8}});
239const std::vector<std::pair<int32_t, int32_t>> ALM_SQUAREA({{151, 24}});
240constexpr double ALM_SQUAREA_LSB = TWO_N11;
241const std::vector<std::pair<int32_t, int32_t>> ALM_OMEGAZERO({{181, 24}});
242constexpr double ALM_OMEGAZERO_LSB = TWO_N23;
243const std::vector<std::pair<int32_t, int32_t>> ALM_OMEGA({{211, 24}});
244constexpr double ALM_OMEGA_LSB = TWO_N23;
245const std::vector<std::pair<int32_t, int32_t>> ALM_MZERO({{241, 24}});
246constexpr double ALM_MZERO_LSB = TWO_N23;
247
248const std::vector<std::pair<int32_t, int32_t>> ALM_AF0({{271, 8}, {290, 3}});
249constexpr double ALM_AF0_LSB = TWO_N20;
250const std::vector<std::pair<int32_t, int32_t>> ALM_AF1({{279, 11}});
251constexpr double ALM_AF1_LSB = TWO_N38;
252/** \} */
253/** \} */
254#endif // GNSS_SDR_GPS_L1_CA_H
Defines useful mathematical constants and their scaled versions.
GNSS Frequencies.
constexpr int32_t GPS_SUBFRAME_LENGTH
GPS_WORD_LENGTH x 10 = 40 bytes.
Definition GPS_L1_CA.h:67
constexpr double FREQ1
L1/E1 frequency (Hz).
constexpr double TWO_N11
2^-11
constexpr double PI_TWO_N31
Pi*2^-31.
constexpr double TWO_N43
2^-43
constexpr double TWO_N23
2^-23
constexpr double GPS_L1_CA_CODE_PERIOD_S
GPS L1 C/A code period [seconds].
Definition GPS_L1_CA.h:37
constexpr double TWO_P16
2^16
constexpr double PI_TWO_N43
Pi*2^-43.
constexpr double TWO_P14
2^14
constexpr double GPS_L1_FREQ_HZ
L1 [Hz].
Definition GPS_L1_CA.h:34
constexpr double TWO_N5
2^-5
const std::vector< std::pair< int32_t, int32_t > > ALPHA_0({{69, 8}})
constexpr int32_t GPS_CA_TELEMETRY_RATE_SYMBOLS_SECOND
NAV message bit rate [symbols/s].
Definition GPS_L1_CA.h:65
constexpr double TWO_P12
2^12
constexpr double GPS_L1_CA_CODE_RATE_CPS
GPS L1 C/A code rate [chips/s].
Definition GPS_L1_CA.h:35
constexpr int32_t GPS_SUBFRAME_MS
Subframe duration [seconds].
Definition GPS_L1_CA.h:70
constexpr double TWO_N31
2^-31
constexpr int32_t GPS_WORD_LENGTH
CRC + GPS WORD (-2 -1 0 ... 29) Bits = 4 bytes.
Definition GPS_L1_CA.h:66
constexpr double TWO_N55
2^-55
constexpr uint32_t GPS_L1_CA_CODE_PERIOD_MS
GPS L1 C/A code period [ms].
Definition GPS_L1_CA.h:39
constexpr double TWO_N19
2^-19
constexpr double TWO_N24
2^-24
constexpr double GPS_L1_CA_CODE_LENGTH_CHIPS
GPS L1 C/A code length [chips].
Definition GPS_L1_CA.h:36
constexpr int32_t GPS_SUBFRAME_BITS
Number of bits per subframe in the NAV message [bits].
Definition GPS_L1_CA.h:68
const std::vector< std::pair< int32_t, int32_t > > T_OA({{69, 8}})
constexpr double TWO_N27
2^-27
constexpr double TWO_P11
2^11
constexpr uint32_t GPS_L1_CA_OPT_ACQ_FS_SPS
Sampling frequency that maximizes the acquisition SNR while using a non-multiple of chip rate.
Definition GPS_L1_CA.h:53
constexpr int32_t GPS_SUBFRAME_SECONDS
Subframe duration [seconds].
Definition GPS_L1_CA.h:69
constexpr double TWO_N20
2^-20
constexpr double TWO_N21
2^-21
constexpr double GPS_L1_CA_CHIP_PERIOD_S
GPS L1 C/A chip period [seconds].
Definition GPS_L1_CA.h:38
constexpr int32_t GPS_CA_TELEMETRY_RATE_BITS_SECOND
NAV message bit rate [bits/s].
Definition GPS_L1_CA.h:63
constexpr int32_t GPS_WORD_BITS
Number of bits per word in the NAV message [bits].
Definition GPS_L1_CA.h:71
constexpr double TWO_P4
2^4
constexpr double TWO_N38
2^-38
constexpr double TWO_N29
2^-29
constexpr double TWO_N30
2^-30
constexpr double TWO_N50
2^-50
constexpr uint32_t GPS_L1_CA_BIT_PERIOD_MS
GPS L1 C/A bit period [ms].
Definition GPS_L1_CA.h:40
constexpr double TWO_N33
2^-33
constexpr double MAX_TOA_DELAY_MS
Maximum Time-Of-Arrival (TOA) difference between satellites for a receiver operated on Earth surface ...
Definition GPS_L1_CA.h:50