GNSS-SDR  0.0.21
An Open Source GNSS Software Defined Receiver
dll_pll_veml_tracking_fpga.h
Go to the documentation of this file.
1 /*!
2  * \file dll_pll_veml_tracking_fpga.h
3  * \brief Implementation of a code DLL + carrier PLL tracking block using an FPGA.
4  * \author Marc Majoral, 2019. marc.majoral(at)cttc.es
5  * \author Javier Arribas, 2019. jarribas(at)cttc.es
6  *
7  * -----------------------------------------------------------------------------
8  *
9  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
10  * This file is part of GNSS-SDR.
11  *
12  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
13  * SPDX-License-Identifier: GPL-3.0-or-later
14  *
15  * -----------------------------------------------------------------------------
16  */
17 
18 #ifndef GNSS_SDR_DLL_PLL_VEML_TRACKING_FPGA_H
19 #define GNSS_SDR_DLL_PLL_VEML_TRACKING_FPGA_H
20 
21 #include "bit_synchronizer.h"
22 #include "dll_pll_conf_fpga.h"
23 #include "exponential_smoother.h"
24 #include "gnss_block_interface.h"
25 #include "tracking_FLL_PLL_filter.h" // for PLL/FLL filter
26 #include "tracking_loop_filter.h" // for DLL filter
27 #include <boost/circular_buffer.hpp>
28 #include <gnuradio/block.h> // for block
29 #include <gnuradio/gr_complex.h> // for gr_complex
30 #include <gnuradio/types.h> // for gr_vector_int, gr_vector...
31 #include <pmt/pmt.h> // for pmt_t
32 #include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
33 #include <cstddef> // for size_t
34 #include <cstdint> // for int32_t
35 #include <fstream> // for string, ofstream
36 #include <memory> // for std::shared_ptr
37 #include <string> // for string
38 #include <typeinfo> // for typeid
39 #include <utility> // for pair
40 
41 /** \addtogroup Tracking
42  * \{ */
43 /** \addtogroup Tracking_gnuradio_blocks
44  * \{ */
45 
46 
48 class Gnss_Synchro;
50 
51 using dll_pll_veml_tracking_fpga_sptr = gnss_shared_ptr<dll_pll_veml_tracking_fpga>;
52 
53 dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_);
54 
55 
56 /*!
57  * \brief This class implements a code DLL + carrier PLL tracking block.
58  */
59 class dll_pll_veml_tracking_fpga : public gr::block
60 {
61 public:
62  /*!
63  * \brief Destructor
64  */
66 
67  /*!
68  * \brief Set the channel number and configure some multicorrelator parameters
69  */
70  void set_channel(uint32_t channel, const std::string &device_io_name);
71 
72  /*!
73  * \brief This function is used with two purposes:
74  * 1 -> To set the gnss_synchro
75  * 2 -> A set_gnss_synchro command with a valid PRN is received when the system is going to run
76  * acquisition with that PRN. We can use this command to pre-initialize tracking parameters and
77  * variables before the actual acquisition process takes place. In this way we minimize the
78  * latency between acquisition and tracking once the acquisition has been made.
79  */
80  void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro);
81 
82  /*!
83  * \brief This function starts the tracking process
84  */
85  void start_tracking();
86 
87  /*!
88  * \brief This function sets a flag that makes general_work to stop in order to finish the tracking process.
89  */
90  void stop_tracking();
91 
92  /*!
93  * \brief General Work
94  */
95  int general_work(int noutput_items, gr_vector_int &ninput_items,
96  gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
97 
98  /*!
99  * \brief This function disables the HW multicorrelator in the FPGA in order to stop the tracking process
100  */
101  void reset();
102 
103 private:
104  friend dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_);
105  explicit dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_);
106 
107  void msg_handler_telemetry_to_trk(const pmt::pmt_t &msg);
108  bool cn0_and_tracking_lock_status(double coh_integration_time_s);
109  bool acquire_secondary();
110  void do_correlation_step();
111  void run_dll_pll();
112  void check_carrier_phase_coherent_initialization();
113  void update_tracking_vars();
114  void clear_tracking_vars();
115  void save_correlation_results();
116  void log_data();
117  void configure_bit_synchronizer();
118  int32_t save_matfile() const;
119 
120  Dll_Pll_Conf_Fpga d_trk_parameters;
121  HistogramBitSynchronizer d_bit_sync;
122  Exponential_Smoother d_cn0_smoother;
123  Exponential_Smoother d_carrier_lock_test_smoother;
124 
125  Gnss_Synchro *d_acquisition_gnss_synchro;
126 
127  Tracking_loop_filter d_code_loop_filter;
128 
129  Tracking_FLL_PLL_filter d_carrier_loop_filter;
130 
131  volk_gnsssdr::vector<float> d_local_code_shift_chips;
132  volk_gnsssdr::vector<gr_complex> d_correlator_outs;
133  volk_gnsssdr::vector<gr_complex> d_Prompt_Data;
134  volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
135 
136  boost::circular_buffer<float> d_dll_filt_history;
137  boost::circular_buffer<std::pair<double, double>> d_code_ph_history;
138  boost::circular_buffer<std::pair<double, double>> d_carr_ph_history;
139  boost::circular_buffer<gr_complex> d_Prompt_circular_buffer;
140 
141  std::string d_systemName;
142  std::string d_signal_type;
143  std::string d_secondary_code_string;
144  std::string d_data_secondary_code_string;
145  std::string d_signal_pretty_name;
146  std::string d_dump_filename;
147 
148  std::ofstream d_dump_file;
149 
150  std::shared_ptr<Fpga_Multicorrelator_8sc> d_multicorrelator_fpga;
151 
152  boost::condition_variable d_m_condition;
153 
154  boost::mutex d_mutex;
155 
156  const size_t int_type_hash_code = typeid(int).hash_code();
157 
158  double d_signal_carrier_freq;
159  double d_code_period;
160  double d_code_chip_rate;
161  double d_code_phase_step_chips;
162  double d_code_phase_rate_step_chips;
163  double d_carrier_phase_step_rad;
164  double d_carrier_phase_rate_step_rad;
165  double d_acq_code_phase_samples;
166  double d_acq_carrier_doppler_hz;
167  double d_rem_code_phase_samples;
168  double d_rem_code_phase_samples_prev;
169  double d_current_correlation_time_s;
170  double d_carr_phase_error_hz;
171  double d_carr_freq_error_hz;
172  double d_carr_error_filt_hz;
173  double d_code_error_chips;
174  double d_code_error_filt_chips;
175  double d_code_freq_chips;
176  double d_carrier_doppler_hz;
177  double d_acc_carrier_phase_rad;
178  double d_rem_code_phase_chips;
179  double d_T_chip_seconds;
180  double d_T_prn_seconds;
181  double d_T_prn_samples;
182  double d_K_blk_samples;
183  double d_carrier_lock_test;
184  double d_CN0_SNV_dB_Hz;
185  double d_carrier_lock_threshold;
186 
187  gr_complex *d_Very_Early;
188  gr_complex *d_Early;
189  gr_complex *d_Prompt;
190  gr_complex *d_Late;
191  gr_complex *d_Very_Late;
192 
193  gr_complex d_VE_accu;
194  gr_complex d_E_accu;
195  gr_complex d_P_accu;
196  gr_complex d_P_accu_old;
197  gr_complex d_L_accu;
198  gr_complex d_VL_accu;
199  gr_complex d_P_data_accu;
200 
201  uint64_t d_sample_counter;
202  uint64_t d_acq_sample_stamp;
203  uint64_t d_sample_counter_next;
204  int64_t d_bit_sync_target_epoch{};
205 
206  float *d_prompt_data_shift;
207  float d_rem_carr_phase_rad;
208 
209  int32_t d_symbols_per_bit;
210  int32_t d_state;
211  int32_t d_extend_correlation_symbols_count;
212  int32_t d_current_symbol;
213  int32_t d_current_data_symbol;
214  int32_t d_current_integration_length_samples;
215  int32_t d_cn0_estimation_counter;
216  int32_t d_carrier_lock_fail_counter;
217  int32_t d_code_lock_fail_counter;
218  int32_t d_correlation_length_ms;
219  int32_t d_n_correlator_taps;
220  int32_t d_next_integration_length_samples;
221  int32_t d_extend_fpga_integration_periods;
222 
223  uint32_t d_channel;
224  uint32_t d_secondary_code_length;
225  uint32_t d_data_secondary_code_length;
226  uint32_t d_code_length_chips;
227  uint32_t d_code_samples_per_chip; // All signals have 1 sample per chip code except Gal. E1 which has 2 (CBOC disabled) or 12 (CBOC enabled)
228  uint32_t d_fpga_integration_period;
229  uint32_t d_current_fpga_integration_period;
230 
231  bool d_veml;
232  bool d_cloop;
233  bool d_secondary;
234  bool d_enable_extended_integration;
235  bool d_dump;
236  bool d_dump_mat;
237  bool d_pull_in_transitory;
238  bool d_corrected_doppler;
239  bool d_interchange_iq;
240  bool d_acc_carrier_phase_initialized;
241  bool d_worker_is_done;
242  bool d_extended_correlation_in_fpga;
243  bool d_current_extended_correlation_in_fpga;
244  bool d_stop_tracking;
245  bool d_sc_demodulate_enabled;
246  bool d_Flag_PLL_180_deg_phase_locked;
247  bool d_use_histogram_bit_sync;
248  bool d_wait_for_bit_edge{false};
249 };
250 
251 
252 /** \} */
253 /** \} */
254 #endif // GNSS_SDR_DLL_PLL_VEML_TRACKING_FPGA_H
void stop_tracking()
This function sets a flag that makes general_work to stop in order to finish the tracking process...
Histogram-based navigation data bit synchronizer.
void set_channel(uint32_t channel, const std::string &device_io_name)
Set the channel number and configure some multicorrelator parameters.
This class implements a code DLL + carrier PLL tracking block.
void reset()
This function disables the HW multicorrelator in the FPGA in order to stop the tracking process...
Class that contains all the configuration parameters for generic tracking block based on a DLL and a ...
This class implements a hybrid FLL and PLL filter for tracking carrier loop.
This is the class that contains the information that is shared by the processing blocks.
Definition: gnss_synchro.h:38
This interface represents a GNSS block.
Class that implements a first-order exponential smoother.
~dll_pll_veml_tracking_fpga()
Destructor.
Histogram-based bit-edge synchronizer for GNSS prompt correlator outputs.
void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro)
This function is used with two purposes: 1 -> To set the gnss_synchro 2 -> A set_gnss_synchro command...
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
General Work.
void start_tracking()
This function starts the tracking process.
Class that implements carrier wipe-off and correlators.
Generic 1st to 3rd order loop filter implementation.
This class implements a generic 1st, 2nd or 3rd order loop filter.
Interface of a hybrid FLL and PLL filter for tracking carrier loop.
Class that implements an exponential smoother.