mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-30 23:03:05 +00:00 
			
		
		
		
	Adding documentation and improving code formatting.
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@103 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
		| @@ -1,11 +1,13 @@ | ||||
| /*! | ||||
|  * \file gps_l1_ca_dll_fll_pll_tracking.cc | ||||
|  * \brief code DLL + carrier FLL/PLL tracking | ||||
|  * \brief Implementation of an adapter of a code DLL + carrier FLL/PLL tracking | ||||
|  * loop for GPS L1 C/A to a TrackingInterface | ||||
|  * \author Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * This file implements the code Delay Locked Loop (DLL) + carrier Phase Locked Loop (PLL) helped with a carrier Frequency Locked Loop (FLL) stage | ||||
|  * according to the algorithms described in [1] | ||||
|  * [1] E.D. Kaplan and C. Hegarty, Understanding GPS. Principles and | ||||
|  * This file implements the code Delay Locked Loop (DLL) + carrier Phase | ||||
|  * Locked Loop (PLL) helped with a carrier Frequency Locked Loop (FLL) | ||||
|  * according to the algorithms described in: | ||||
|  * E.D. Kaplan and C. Hegarty, Understanding GPS. Principles and | ||||
|  * Applications, Second Edition, Artech House Publishers, 2005. | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
| @@ -40,18 +42,21 @@ | ||||
|   #include <boost/math/special_functions/round.hpp> | ||||
| #endif | ||||
| #include <gnuradio/gr_io_signature.h> | ||||
|  | ||||
| #include <glog/log_severity.h> | ||||
| #include <glog/logging.h> | ||||
|  | ||||
| using google::LogMessage; | ||||
|  | ||||
| GpsL1CaDllFllPllTracking::GpsL1CaDllFllPllTracking( | ||||
|         ConfigurationInterface* configuration, std::string role, | ||||
|         unsigned int in_streams, unsigned int out_streams, | ||||
|         ConfigurationInterface* configuration, | ||||
|         std::string role, | ||||
|         unsigned int in_streams, unsigned int | ||||
|         out_streams, | ||||
|         gr_msg_queue_sptr queue) : | ||||
|     role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_( | ||||
|             queue) | ||||
|         role_(role), | ||||
|         in_streams_(in_streams), | ||||
|         out_streams_(out_streams), | ||||
|         queue_(queue) | ||||
| { | ||||
|  | ||||
|     DLOG(INFO) << "role " << role; | ||||
|   | ||||
| @@ -1,11 +1,13 @@ | ||||
| /*! | ||||
|  * \file gps_l1_ca_dll_fll_pll_tracking.h | ||||
|  * \brief code DLL + carrier FLL/PLL tracking | ||||
|  * \brief Interface of an adapter of a code DLL + carrier FLL/PLL tracking | ||||
|  * loop for GPS L1 C/A to a TrackingInterface | ||||
|  * \author Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * This file implements the code Delay Locked Loop (DLL) + carrier Phase Locked Loop (PLL) helped with a carrier Frequency Locked Loop (FLL) stage | ||||
|  * according to the algorithms described in [1] | ||||
|  * [1] E.D. Kaplan and C. Hegarty, Understanding GPS. Principles and | ||||
|  * This is the interface of a code Delay Locked Loop (DLL) + carrier | ||||
|  * Phase Locked Loop (PLL) helped with a carrier Frequency Locked Loop (FLL) | ||||
|  * according to the algorithms described in: | ||||
|  * E.D. Kaplan and C. Hegarty, Understanding GPS. Principles and | ||||
|  * Applications, Second Edition, Artech House Publishers, 2005. | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|   | ||||
| @@ -1,12 +1,14 @@ | ||||
| /*! | ||||
|  * \file gps_l1_ca_dll_pll_tracking.cc | ||||
|  * \brief code DLL + carrier PLL | ||||
|  * \brief Implementation of an adapter of a DLL+PLL tracking loop block | ||||
|  * for GPS L1 C/A to a TrackingInterface | ||||
|  * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com | ||||
|  *         Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * Code DLL + carrier PLL according to the algorithms described in [1] | ||||
|  * [1] K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, | ||||
|  * A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach, Birkha user, 2007 | ||||
|  * Code DLL + carrier PLL according to the algorithms described in: | ||||
|  * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, | ||||
|  * A Software-Defined GPS and Galileo Receiver. A Single-Frequency | ||||
|  * Approach, Birkhauser, 2007 | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  * | ||||
| @@ -40,7 +42,6 @@ | ||||
|   #include <boost/math/special_functions/round.hpp> | ||||
| #endif | ||||
| #include <gnuradio/gr_io_signature.h> | ||||
|  | ||||
| #include <glog/log_severity.h> | ||||
| #include <glog/logging.h> | ||||
|  | ||||
| @@ -50,8 +51,8 @@ GpsL1CaDllPllTracking::GpsL1CaDllPllTracking( | ||||
|         ConfigurationInterface* configuration, std::string role, | ||||
|         unsigned int in_streams, unsigned int out_streams, | ||||
|         gr_msg_queue_sptr queue) : | ||||
|     role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_( | ||||
|             queue) | ||||
|         role_(role), in_streams_(in_streams), out_streams_(out_streams), | ||||
|         queue_(queue) | ||||
| { | ||||
|  | ||||
|     DLOG(INFO) << "role " << role; | ||||
| @@ -82,22 +83,22 @@ GpsL1CaDllPllTracking::GpsL1CaDllPllTracking( | ||||
|     std::string default_dump_filename = "./track_ch"; | ||||
|     dump_filename = configuration->property(role + ".dump_filename", | ||||
|             default_dump_filename); //unused! | ||||
|     #ifdef GNSS_SDR_USE_BOOST_ROUND | ||||
| #ifdef GNSS_SDR_USE_BOOST_ROUND | ||||
|     vector_length = round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); | ||||
|     #else | ||||
| #else | ||||
|     vector_length = std::round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); | ||||
|     #endif | ||||
| #endif | ||||
|     //################# MAKE TRACKING GNURadio object ################### | ||||
|     if (item_type.compare("gr_complex") == 0) | ||||
|     { | ||||
|         item_size_ = sizeof(gr_complex); | ||||
|         tracking_ = gps_l1_ca_dll_pll_make_tracking_cc(satellite_, f_if, | ||||
|                 fs_in, vector_length, queue_, dump, dump_filename, pll_bw_hz,dll_bw_hz,early_late_space_chips); | ||||
|     } | ||||
|         { | ||||
|             item_size_ = sizeof(gr_complex); | ||||
|             tracking_ = gps_l1_ca_dll_pll_make_tracking_cc(satellite_, f_if, | ||||
|                     fs_in, vector_length, queue_, dump, dump_filename, pll_bw_hz,dll_bw_hz,early_late_space_chips); | ||||
|         } | ||||
|     else | ||||
|     { | ||||
|         LOG_AT_LEVEL(WARNING) << item_type << " unknown tracking item type."; | ||||
|     } | ||||
|         { | ||||
|             LOG_AT_LEVEL(WARNING) << item_type << " unknown tracking item type."; | ||||
|         } | ||||
|  | ||||
|     DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; | ||||
| } | ||||
| @@ -111,7 +112,7 @@ void GpsL1CaDllPllTracking::start_tracking() | ||||
|     tracking_->start_tracking(); | ||||
| } | ||||
|  | ||||
| /*! | ||||
| /* | ||||
|  * Set satellite ID | ||||
|  */ | ||||
| void GpsL1CaDllPllTracking::set_satellite(unsigned int satellite) | ||||
| @@ -121,7 +122,7 @@ void GpsL1CaDllPllTracking::set_satellite(unsigned int satellite) | ||||
|     DLOG(INFO) << "satellite set to " << satellite_; | ||||
| } | ||||
|  | ||||
| /*! | ||||
| /* | ||||
|  * Set tracking channel unique ID | ||||
|  */ | ||||
| void GpsL1CaDllPllTracking::set_channel(unsigned int channel) | ||||
| @@ -130,7 +131,7 @@ void GpsL1CaDllPllTracking::set_channel(unsigned int channel) | ||||
|     tracking_->set_channel(channel); | ||||
| } | ||||
|  | ||||
| /*! | ||||
| /* | ||||
|  * Set tracking channel internal queue | ||||
|  */ | ||||
| void GpsL1CaDllPllTracking::set_channel_queue( | ||||
| @@ -141,21 +142,24 @@ void GpsL1CaDllPllTracking::set_channel_queue( | ||||
|     tracking_->set_channel_queue(channel_internal_queue_); | ||||
|  | ||||
| } | ||||
| /*! | ||||
|  | ||||
| /* | ||||
|  * Set acquisition code phase in samples | ||||
|  */ | ||||
| void GpsL1CaDllPllTracking::set_prn_code_phase(signed int phase_samples) | ||||
| { | ||||
|     return tracking_->set_acq_code_phase((float)phase_samples); | ||||
| } | ||||
| /*! | ||||
|  | ||||
| /* | ||||
|  * Set acquisition Doppler frequency in Hz. | ||||
|  */ | ||||
| void GpsL1CaDllPllTracking::set_doppler_freq_shift(float doppler_freq_hz) | ||||
| { | ||||
|     return tracking_->set_acq_doppler(doppler_freq_hz); | ||||
| } | ||||
| /*! | ||||
|  | ||||
| /* | ||||
|  * Set acquisition sample stamp in samples, in order to detect the delay between acquisition and tracking | ||||
|  */ | ||||
| void GpsL1CaDllPllTracking::set_acq_sample_stamp( | ||||
| @@ -163,6 +167,7 @@ void GpsL1CaDllPllTracking::set_acq_sample_stamp( | ||||
| { | ||||
|     return tracking_->set_acq_sample_stamp(sample_stamp); | ||||
| } | ||||
|  | ||||
| void GpsL1CaDllPllTracking::connect(gr_top_block_sptr top_block) | ||||
| { | ||||
|     //nothing to connect, now the tracking uses gr_sync_decimator | ||||
|   | ||||
| @@ -1,12 +1,14 @@ | ||||
| /*! | ||||
|  * \file gps_l1_ca_dll_pll_tracking.h | ||||
|  * \brief code DLL + carrier PLL | ||||
|  * \brief  Interface of an adapter of a DLL+PLL tracking loop block | ||||
|  * for GPS L1 C/A to a TrackingInterface | ||||
|  * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com | ||||
|  *         Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * Code DLL + carrier PLL according to the algorithms described in [1] | ||||
|  * [1] K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, | ||||
|  * A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach, Birkha user, 2007 | ||||
|  * Code DLL + carrier PLL according to the algorithms described in: | ||||
|  * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, | ||||
|  * A Software-Defined GPS and Galileo Receiver. A Single-Frequency | ||||
|  * Approach, Birkha user, 2007 | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  * | ||||
| @@ -76,14 +78,37 @@ public: | ||||
|     gr_basic_block_sptr get_left_block(); | ||||
|     gr_basic_block_sptr get_right_block(); | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set satellite ID | ||||
|      */ | ||||
|     void set_satellite(unsigned int satellite); | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set tracking channel unique ID | ||||
|      */ | ||||
|     void set_channel(unsigned int channel); | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set acquisition code phase in samples | ||||
|      */ | ||||
|     void set_prn_code_phase(signed int phase_samples); | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set acquisition Doppler frequency in Hz. | ||||
|      */ | ||||
|     void set_doppler_freq_shift(float doppler_freq_hz); | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set tracking channel internal queue | ||||
|      */ | ||||
|     void set_channel_queue(concurrent_queue<int> *channel_internal_queue); | ||||
|  | ||||
|     void start_tracking(); | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set acquisition sample stamp in samples, in order to detect | ||||
|      * the delay between acquisition and tracking | ||||
|      */ | ||||
|     void set_acq_sample_stamp(unsigned long int sample_stamp); | ||||
|  | ||||
| private: | ||||
|   | ||||
| @@ -1,11 +1,12 @@ | ||||
| /*! | ||||
|  * \file gps_l1_ca_dll_fll_pll_tracking_cc.cc | ||||
|  * \brief code DLL + carrier FLL/PLL tracking | ||||
|  * \brief Implementation of a code DLL + carrier FLL/PLL tracking block | ||||
|  * \author Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * This file implements the code Delay Locked Loop (DLL) + carrier Phase Locked Loop (PLL) helped with a carrier Frequency Locked Loop (FLL) stage | ||||
|  * according to the algorithms described in [1] | ||||
|  * [1] E.D. Kaplan and C. Hegarty, Understanding GPS. Principles and | ||||
|  * This file implements the code Delay Locked Loop (DLL) + carrier | ||||
|  * Phase Locked Loop (PLL) helped with a carrier Frequency Locked Loop (FLL) | ||||
|  * according to the algorithms described in: | ||||
|  * E.D. Kaplan and C. Hegarty, Understanding GPS. Principles and | ||||
|  * Applications, Second Edition, Artech House Publishers, 2005. | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
| @@ -39,16 +40,13 @@ | ||||
| #include "tracking_discriminators.h" | ||||
| #include "CN_estimators.h" | ||||
| #include "tracking_FLL_PLL_filter.h" | ||||
|  | ||||
| #include "control_message_factory.h" | ||||
| #include <boost/lexical_cast.hpp> | ||||
| #include <iostream> | ||||
| #include <sstream> | ||||
| #include <cmath> | ||||
| #include "math.h" | ||||
|  | ||||
| #include <gnuradio/gr_io_signature.h> | ||||
|  | ||||
| #include <glog/log_severity.h> | ||||
| #include <glog/logging.h> | ||||
|  | ||||
| @@ -124,7 +122,7 @@ gps_l1_ca_dll_fll_pll_tracking_cc::gps_l1_ca_dll_fll_pll_tracking_cc(unsigned in | ||||
|  | ||||
| void gps_l1_ca_dll_fll_pll_tracking_cc::start_tracking(){ | ||||
|  | ||||
| 	/*! | ||||
| 	/* | ||||
| 	 *  correct the code phase according to the delay between acq and trk | ||||
| 	 */ | ||||
| 	unsigned long int acq_trk_diff_samples; | ||||
| @@ -242,7 +240,7 @@ gps_l1_ca_dll_fll_pll_tracking_cc::~gps_l1_ca_dll_fll_pll_tracking_cc() { | ||||
|     delete[] d_Prompt_buffer; | ||||
| } | ||||
|  | ||||
| /*! Tracking signal processing | ||||
| /* Tracking signal processing | ||||
|  * Notice that this is a class derived from gr_sync_decimator, so each of the ninput_items has vector_length samples | ||||
|  */ | ||||
|  | ||||
| @@ -268,7 +266,7 @@ int gps_l1_ca_dll_fll_pll_tracking_cc::general_work (int noutput_items, gr_vecto | ||||
| 	d_Late=gr_complex(0,0); | ||||
|  | ||||
| 	if (d_enable_tracking==true){ | ||||
| 		/*! | ||||
| 		/* | ||||
| 		 * Receiver signal alignment | ||||
| 		 */ | ||||
| 	    if (d_pull_in==true) | ||||
| @@ -329,7 +327,7 @@ int gps_l1_ca_dll_fll_pll_tracking_cc::general_work (int noutput_items, gr_vecto | ||||
| 			d_Late += bb_signal_sample*d_late_code[i]; | ||||
| 		} | ||||
|  | ||||
| 		/*! | ||||
| 		/* | ||||
| 		 * DLL, FLL, and PLL discriminators | ||||
| 		 */ | ||||
| 		// Compute DLL error | ||||
|   | ||||
| @@ -1,12 +1,12 @@ | ||||
| /*! | ||||
|  * \file gps_l1_ca_dll_fll_pll_tracking_cc.h | ||||
|  * \brief code DLL + carrier FLL/PLL tracking | ||||
|  * \brief Interface of a code DLL + carrier FLL/PLL tracking block | ||||
|  * \author Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * This file implements the code Delay Locked Loop (DLL) + | ||||
|  * carrier Phase Locked Loop (PLL) helped with a carrier Frequency Locked Loop (FLL) stage | ||||
|  * according to the algorithms described in [1] | ||||
|  * [1] E.D. Kaplan and C. Hegarty, Understanding GPS. Principles and | ||||
|  * This is the interface of a  code Delay Locked Loop (DLL) + | ||||
|  * carrier Phase Locked Loop (PLL) helped with a carrier Frequency Locked | ||||
|  * Loop (FLL) according to the algorithms described in: | ||||
|  * E.D. Kaplan and C. Hegarty, Understanding GPS. Principles and | ||||
|  * Applications, Second Edition, Artech House Publishers, 2005. | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|   | ||||
| @@ -1,12 +1,13 @@ | ||||
| /*! | ||||
|  * \file gps_l1_ca_dll_pll_tracking_cc.cc | ||||
|  * \brief code DLL + carrier PLL | ||||
|  * \brief Implementation of a code DLL + carrier PLL tracking block | ||||
|  * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com | ||||
|  *         Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * Code DLL + carrier PLL according to the algorithms described in [1] | ||||
|  * Code DLL + carrier PLL according to the algorithms described in: | ||||
|  * [1] K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, | ||||
|  * A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach, Birkha user, 2007 | ||||
|  * A Software-Defined GPS and Galileo Receiver. A Single-Frequency | ||||
|  * Approach, Birkha user, 2007 | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  * | ||||
| @@ -139,7 +140,7 @@ gps_l1_ca_dll_pll_tracking_cc::gps_l1_ca_dll_pll_tracking_cc(unsigned int satell | ||||
| } | ||||
|  | ||||
| void gps_l1_ca_dll_pll_tracking_cc::start_tracking(){ | ||||
| 	/*! | ||||
| 	/* | ||||
| 	 *  correct the code phase according to the delay between acq and trk | ||||
| 	 */ | ||||
| 	unsigned long int acq_trk_diff_samples; | ||||
| @@ -270,7 +271,7 @@ gps_l1_ca_dll_pll_tracking_cc::~gps_l1_ca_dll_pll_tracking_cc() { | ||||
|     delete[] d_Prompt_buffer; | ||||
| } | ||||
|  | ||||
| /*! Tracking signal processing | ||||
| /* Tracking signal processing | ||||
|  * Notice that this is a class derived from gr_sync_decimator, so each of the ninput_items has vector_length samples | ||||
|  */ | ||||
|  | ||||
| @@ -295,7 +296,7 @@ int gps_l1_ca_dll_pll_tracking_cc::general_work (int noutput_items, gr_vector_in | ||||
| 	d_Late=gr_complex(0,0); | ||||
|  | ||||
| 	if (d_enable_tracking==true){ | ||||
| 		/*! | ||||
| 		/* | ||||
| 		 * Receiver signal alignment | ||||
| 		 */ | ||||
| 	    if (d_pull_in==true) | ||||
|   | ||||
| @@ -1,12 +1,13 @@ | ||||
| /*! | ||||
|  * \file gps_l1_ca_dll_pll_tracking_cc.h | ||||
|  * \brief code DLL + carrier PLL | ||||
|  * \brief Interface of a code DLL + carrier PLL tracking block | ||||
|  * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com | ||||
|  *         Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * Code DLL + carrier PLL according to the algorithms described in [1] | ||||
|  * [1] K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, | ||||
|  * A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach, Birkha user, 2007 | ||||
|  * Code DLL + carrier PLL according to the algorithms described in: | ||||
|  * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, | ||||
|  * A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach, | ||||
|  * Birkhauser, 2007 | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  * | ||||
|   | ||||
| @@ -1,25 +1,18 @@ | ||||
| /*! | ||||
|  * \file CN_estimators.cc | ||||
|  * \brief Library with a set of Carrier to Noise estimators and lock detectors. | ||||
|  * SNV_CN0 is a Carrier-to-Noise (CN0) estimator based on the Signal-to-Noise Variance (SNV) estimator [1]. | ||||
|  * | ||||
|  * \brief Implementation of a library with a set of Carrier to Noise | ||||
|  * estimators and lock detectors. SNV_CN0 is a Carrier-to-Noise (CN0) estimator | ||||
|  * based on the Signal-to-Noise Variance (SNV) estimator [1]. | ||||
|  * Carrier lock detector using normalised estimate of the cosine | ||||
|  * of twice the carrier phase error [2]. | ||||
|  * | ||||
|  * | ||||
|  * [1] Marco Pini, Emanuela Falletti and Maurizio Fantino, "Performance | ||||
|  * Evaluation of C/N0 Estimators using a Real Time GNSS Software Receiver," | ||||
|  * IEEE 10th International Symposium on Spread Spectrum Techniques and | ||||
|  * Applications, pp.28-30, August 2008. | ||||
|  * | ||||
|  * | ||||
|  * | ||||
|  * [2] Van Dierendonck, A.J. (1996), Global Positioning System: Theory and | ||||
|  * Applications, | ||||
|  * Volume I, Chapter 8: GPS Receivers, AJ Systems, Los Altos, CA 94024. | ||||
|  * Inc.: 329-407. | ||||
|  * | ||||
|  * | ||||
|  * \author Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * | ||||
| @@ -52,7 +45,7 @@ | ||||
| #include <gnuradio/gr_complex.h> | ||||
| #include <math.h> | ||||
|  | ||||
| /*! | ||||
| /* | ||||
|  * Signal-to-Noise (SNR) (\f$\rho\f$) estimator using the Signal-to-Noise Variance (SNV) estimator: | ||||
|  * \f{equation} | ||||
|  * 	\hat{\rho}=\frac{\hat{P}_s}{\hat{P}_n}=\frac{\hat{P}_s}{\hat{P}_{tot}-\hat{P}_s}, | ||||
| @@ -66,36 +59,37 @@ | ||||
|  * 	CN0_{dB}=10*log(\hat{\rho})+10*log(\frac{f_s}{2})-10*log(L_{PRN}), | ||||
|  * \f} | ||||
|  * where \f$f_s\f$ is the sampling frequency and \f$L_{PRN}\f$ is the PRN sequence length. | ||||
|  * | ||||
|  */ | ||||
| float gps_l1_ca_CN0_SNV(gr_complex* Prompt_buffer, int length, long fs_in) | ||||
| { | ||||
| 	// estimate CN0 using buffered values | ||||
| 	   // MATLAB CODE | ||||
| 	   //Psig=((1/N)*sum(abs(imag(x((n-N+1):n)))))^2; | ||||
| 	   //Ptot=(1/N)*sum(abs(x((n-N+1):n)).^2); | ||||
| 	   //SNR_SNV(count)=Psig/(Ptot-Psig); | ||||
| 	   //CN0_SNV_dB=10*log10(SNR_SNV)+10*log10(BW)-10*log10(PRN_length); | ||||
| 	float SNR, SNR_dB_Hz; | ||||
| 	float tmp_abs_I,tmp_abs_Q; | ||||
| 	float Psig,Ptot; | ||||
| 	//float M2,M4; | ||||
| 	Psig=0; | ||||
| 	Ptot=0; | ||||
| 	for (int i=0;i<length;i++) | ||||
| 	{ | ||||
| 		tmp_abs_I=std::abs(Prompt_buffer[i].imag()); | ||||
| 		tmp_abs_Q=std::abs(Prompt_buffer[i].real()); | ||||
| 		Psig+=tmp_abs_I; | ||||
| 		Ptot+=Prompt_buffer[i].imag()*Prompt_buffer[i].imag()+Prompt_buffer[i].real()*Prompt_buffer[i].real(); | ||||
| 	} | ||||
| 	Psig=Psig/(float)length; | ||||
| 	Psig=Psig*Psig; | ||||
| 	SNR=Psig/(Ptot/(float)length-Psig); | ||||
| 	SNR_dB_Hz=10*log10(SNR)+10*log10(fs_in/2)-10*log10(GPS_L1_CA_CODE_LENGTH_CHIPS); | ||||
| 	return SNR_dB_Hz; | ||||
|     // estimate CN0 using buffered values | ||||
|     // MATLAB CODE | ||||
|     //Psig=((1/N)*sum(abs(imag(x((n-N+1):n)))))^2; | ||||
|     //Ptot=(1/N)*sum(abs(x((n-N+1):n)).^2); | ||||
|     //SNR_SNV(count)=Psig/(Ptot-Psig); | ||||
|     //CN0_SNV_dB=10*log10(SNR_SNV)+10*log10(BW)-10*log10(PRN_length); | ||||
|     float SNR, SNR_dB_Hz; | ||||
|     float tmp_abs_I,tmp_abs_Q; | ||||
|     float Psig,Ptot; | ||||
|     //float M2,M4; | ||||
|     Psig=0; | ||||
|     Ptot=0; | ||||
|     for (int i=0;i<length;i++) | ||||
|         { | ||||
|             tmp_abs_I=std::abs(Prompt_buffer[i].imag()); | ||||
|             tmp_abs_Q=std::abs(Prompt_buffer[i].real()); | ||||
|             Psig+=tmp_abs_I; | ||||
|             Ptot+=Prompt_buffer[i].imag()*Prompt_buffer[i].imag()+Prompt_buffer[i].real()*Prompt_buffer[i].real(); | ||||
|         } | ||||
|     Psig=Psig/(float)length; | ||||
|     Psig=Psig*Psig; | ||||
|     SNR=Psig/(Ptot/(float)length-Psig); | ||||
|     SNR_dB_Hz=10*log10(SNR)+10*log10(fs_in/2)-10*log10(GPS_L1_CA_CODE_LENGTH_CHIPS); | ||||
|     return SNR_dB_Hz; | ||||
| } | ||||
|  | ||||
| /*! | ||||
| /* | ||||
|  * The Carrier Phase Lock Detector block uses the normalised estimate of the cosine of twice the carrier phase error is given by | ||||
|  * \f{equation} | ||||
|  * 	C2\phi=\frac{NBD}{NBP}, | ||||
| @@ -104,38 +98,37 @@ float gps_l1_ca_CN0_SNV(gr_complex* Prompt_buffer, int length, long fs_in) | ||||
|  *  \f$NBP=\sum^{N-1}_{i=0}Im(Pc(i))^2-\sum^{N-1}_{i=0}Re(Pc(i))^2\f$, and | ||||
|  *  \f$Pc(i)\f$ is the prompt correlator output for the sample index i. | ||||
|  */ | ||||
|  | ||||
| float carrier_lock_detector(gr_complex* Prompt_buffer, int length) | ||||
| { | ||||
| 	/*! | ||||
| 	 * \todo Code lock detector | ||||
| 	 */ | ||||
| 	// estimate using buffered values | ||||
| 	   // MATLAB CODE | ||||
| 	   // lock detector operation | ||||
| 	   //NBD=sum(abs(imag(x((n-N+1):n))))^2 + sum(abs(real(x((n-N+1):n))))^2; | ||||
| 	   //NBP=sum(imag(x((n-N+1):n)).^2) - sum(real(x((n-N+1):n)).^2); | ||||
| 	   //LOCK(count)=NBD/NBP; | ||||
| 	float tmp_abs_I,tmp_abs_Q; | ||||
| 	float tmp_sum_abs_I,tmp_sum_abs_Q; | ||||
| 	float tmp_sum_sqr_I,tmp_sum_sqr_Q; | ||||
| 	tmp_sum_abs_I=0; | ||||
| 	tmp_sum_abs_Q=0; | ||||
| 	tmp_sum_sqr_I=0; | ||||
| 	tmp_sum_sqr_Q=0; | ||||
| 	float NBD,NBP; | ||||
| 	for (int i=0;i<length;i++) | ||||
| 	{ | ||||
| 		tmp_abs_I=std::abs(Prompt_buffer[i].imag()); | ||||
| 		tmp_abs_Q=std::abs(Prompt_buffer[i].real()); | ||||
| 		tmp_sum_abs_I+=tmp_abs_I; | ||||
| 		tmp_sum_abs_Q+=tmp_abs_Q; | ||||
| 		tmp_sum_sqr_I+=(Prompt_buffer[i].imag()*Prompt_buffer[i].imag()); | ||||
| 		tmp_sum_sqr_Q+=(Prompt_buffer[i].real()*Prompt_buffer[i].real()); | ||||
| 	} | ||||
| 	NBD=tmp_sum_abs_I*tmp_sum_abs_I+tmp_sum_abs_Q*tmp_sum_abs_Q; | ||||
| 	NBP=tmp_sum_sqr_I-tmp_sum_sqr_Q; | ||||
| 	return NBD/NBP; | ||||
|     /*! | ||||
|      * \todo Code lock detector | ||||
|      */ | ||||
|     // estimate using buffered values | ||||
|     // MATLAB CODE | ||||
|     // lock detector operation | ||||
|     //NBD=sum(abs(imag(x((n-N+1):n))))^2 + sum(abs(real(x((n-N+1):n))))^2; | ||||
|     //NBP=sum(imag(x((n-N+1):n)).^2) - sum(real(x((n-N+1):n)).^2); | ||||
|     //LOCK(count)=NBD/NBP; | ||||
|     float tmp_abs_I,tmp_abs_Q; | ||||
|     float tmp_sum_abs_I,tmp_sum_abs_Q; | ||||
|     float tmp_sum_sqr_I,tmp_sum_sqr_Q; | ||||
|     tmp_sum_abs_I=0; | ||||
|     tmp_sum_abs_Q=0; | ||||
|     tmp_sum_sqr_I=0; | ||||
|     tmp_sum_sqr_Q=0; | ||||
|     float NBD,NBP; | ||||
|     for (int i=0;i<length;i++) | ||||
|         { | ||||
|             tmp_abs_I=std::abs(Prompt_buffer[i].imag()); | ||||
|             tmp_abs_Q=std::abs(Prompt_buffer[i].real()); | ||||
|             tmp_sum_abs_I+=tmp_abs_I; | ||||
|             tmp_sum_abs_Q+=tmp_abs_Q; | ||||
|             tmp_sum_sqr_I+=(Prompt_buffer[i].imag()*Prompt_buffer[i].imag()); | ||||
|             tmp_sum_sqr_Q+=(Prompt_buffer[i].real()*Prompt_buffer[i].real()); | ||||
|         } | ||||
|     NBD=tmp_sum_abs_I*tmp_sum_abs_I+tmp_sum_abs_Q*tmp_sum_abs_Q; | ||||
|     NBP=tmp_sum_sqr_I-tmp_sum_sqr_Q; | ||||
|     return NBD/NBP; | ||||
|  | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,10 +1,9 @@ | ||||
| /*! | ||||
|  * \file CN_estimators.h | ||||
|  * \brief Library with a set of Carrier to Noise estimators and lock detectors | ||||
|  * \brief Interface of a library with a set of Carrier to Noise | ||||
|  * estimators and lock detectors. | ||||
|  * \author Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * Library with a set of Carrier to Noise estimators and lock detectors | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  * | ||||
|  * Copyright (C) 2010-2011  (see AUTHORS file for a list of contributors) | ||||
| @@ -35,8 +34,43 @@ | ||||
|  | ||||
| #include <gnuradio/gr_complex.h> | ||||
|  | ||||
| /*! brief SNV_CN0 is a Carrier-to-Noise (CN0) estimator | ||||
|  * based on the Signal-to-Noise Variance (SNV) estimator | ||||
|  * | ||||
|  * Signal-to-Noise (SNR) (\f$\rho\f$) estimator using the Signal-to-Noise Variance (SNV) estimator: | ||||
|  * \f{equation} | ||||
|  * 	\hat{\rho}=\frac{\hat{P}_s}{\hat{P}_n}=\frac{\hat{P}_s}{\hat{P}_{tot}-\hat{P}_s}, | ||||
|  * \f} | ||||
|  *  where \f$\hat{P}_s=\left(\frac{1}{N}\sum^{N-1}_{i=0}|Re(Pc(i))|\right)^2\f$ is the estimation of the signal power, | ||||
|  * \f$\hat{P}_{tot}=\frac{1}{N}\sum^{N-1}_{i=0}|Pc(i)|^2\f$ is the estimator of the total power, \f$|\cdot|\f$ is the absolute value, | ||||
|  * \f$Re(\cdot)\f$ stands for the real part of the value, and \f$Pc(i)\f$ is the prompt correlator output for the sample index i. | ||||
|  * | ||||
|  * The SNR value is converted to CN0 [dB-Hz], taking to account the receiver bandwidth and the PRN code gain, using the following formula: | ||||
|  * \f{equation} | ||||
|  * 	CN0_{dB}=10*log(\hat{\rho})+10*log(\frac{f_s}{2})-10*log(L_{PRN}), | ||||
|  * \f} | ||||
|  * where \f$f_s\f$ is the sampling frequency and \f$L_{PRN}\f$ is the PRN sequence length. | ||||
|  * Ref: Marco Pini, Emanuela Falletti and Maurizio Fantino, "Performance | ||||
|  * Evaluation of C/N0 Estimators using a Real Time GNSS Software Receiver," | ||||
|  * IEEE 10th International Symposium on Spread Spectrum Techniques and | ||||
|  * Applications, pp.28-30, August 2008. | ||||
|  */ | ||||
| float gps_l1_ca_CN0_SNV(gr_complex* Prompt_buffer, int length, long fs_in); | ||||
|  | ||||
| /*! \brief A carrier lock detector | ||||
|  * | ||||
|  * The Carrier Phase Lock Detector block uses the normalised estimate of the cosine of twice the carrier phase error is given by | ||||
|  * \f{equation} | ||||
|  * 	C2\phi=\frac{NBD}{NBP}, | ||||
|  * \f} | ||||
|  *  where \f$NBD=(\sum^{N-1}_{i=0}|Im(Pc(i))|)^2+(\sum^{N-1}_{i=0}|Re(Pc(i))|)^2\f$, | ||||
|  *  \f$NBP=\sum^{N-1}_{i=0}Im(Pc(i))^2-\sum^{N-1}_{i=0}Re(Pc(i))^2\f$, and | ||||
|  *  \f$Pc(i)\f$ is the prompt correlator output for the sample index i. | ||||
|  * Ref: Van Dierendonck, A.J. (1996), Global Positioning System: Theory and | ||||
|  * Applications, | ||||
|  * Volume I, Chapter 8: GPS Receivers, AJ Systems, Los Altos, CA 94024. | ||||
|  * Inc.: 329-407. | ||||
|  */ | ||||
| float carrier_lock_detector(gr_complex* Prompt_buffer, int length); | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -1,11 +1,12 @@ | ||||
| /*! | ||||
|  * \file tracking_2nd_DLL_filter.cc | ||||
|  * \brief Class that implements 2 order DLL filter for code tracking loop. | ||||
|  * \brief Implementation of a 2nd order DLL filter for code tracking loop. | ||||
|  * \author Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * Class that implements 2 order PLL filter for code tracking loop. The algorithm is described in [1] | ||||
|  * | ||||
|  * [1] K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.~H.~Jensen, A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach, | ||||
|  * Class that implements 2 order PLL filter for code tracking loop. | ||||
|  * The algorithm is described in : | ||||
|  * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.~H.~Jensen, A Software-Defined | ||||
|  * GPS and Galileo Receiver. A Single-Frequency Approach, | ||||
|  * Birkhauser, 2007, Applied and Numerical Harmonic Analysis. | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
| @@ -38,19 +39,19 @@ | ||||
|  | ||||
|  | ||||
| void tracking_2nd_DLL_filter::calculate_lopp_coef(float* tau1,float* tau2, float lbw, float zeta, float k){ | ||||
| 	// Solve natural frequency | ||||
| 	float Wn; | ||||
| 	Wn = lbw*8*zeta / (4*zeta*zeta + 1); | ||||
| 	// solve for t1 & t2 | ||||
| 	*tau1 = k / (Wn * Wn); | ||||
| 	*tau2 = (2.0 * zeta) / Wn; | ||||
|     // Solve natural frequency | ||||
|     float Wn; | ||||
|     Wn = lbw*8*zeta / (4*zeta*zeta + 1); | ||||
|     // solve for t1 & t2 | ||||
|     *tau1 = k / (Wn * Wn); | ||||
|     *tau2 = (2.0 * zeta) / Wn; | ||||
| } | ||||
|  | ||||
| void tracking_2nd_DLL_filter::set_DLL_BW(float dll_bw_hz) | ||||
| { | ||||
| 	//Calculate filter coefficient values | ||||
| 	d_dllnoisebandwidth=dll_bw_hz; | ||||
| 	calculate_lopp_coef(&d_tau1_code, &d_tau2_code, d_dllnoisebandwidth, d_dlldampingratio,1.0);// Calculate filter coefficient values | ||||
|     //Calculate filter coefficient values | ||||
|     d_dllnoisebandwidth=dll_bw_hz; | ||||
|     calculate_lopp_coef(&d_tau1_code, &d_tau2_code, d_dllnoisebandwidth, d_dlldampingratio,1.0);// Calculate filter coefficient values | ||||
| } | ||||
| void tracking_2nd_DLL_filter::initialize(float d_acq_code_phase_samples) | ||||
| { | ||||
| @@ -62,17 +63,17 @@ void tracking_2nd_DLL_filter::initialize(float d_acq_code_phase_samples) | ||||
|  | ||||
| float tracking_2nd_DLL_filter::get_code_nco(float DLL_discriminator) | ||||
| { | ||||
| 	float code_nco; | ||||
| 	code_nco = d_old_code_nco + (d_tau2_code/d_tau1_code)*(DLL_discriminator - d_old_code_error) + DLL_discriminator * (d_pdi_code/d_tau1_code); | ||||
| 	d_old_code_nco   = code_nco; | ||||
| 	d_old_code_error = DLL_discriminator; //[chips] | ||||
| 	return code_nco; | ||||
|     float code_nco; | ||||
|     code_nco = d_old_code_nco + (d_tau2_code/d_tau1_code)*(DLL_discriminator - d_old_code_error) + DLL_discriminator * (d_pdi_code/d_tau1_code); | ||||
|     d_old_code_nco   = code_nco; | ||||
|     d_old_code_error = DLL_discriminator; //[chips] | ||||
|     return code_nco; | ||||
| } | ||||
|  | ||||
| tracking_2nd_DLL_filter::tracking_2nd_DLL_filter () | ||||
| { | ||||
| 	d_pdi_code = 0.001;// Summation interval for code | ||||
| 	d_dlldampingratio=0.7; | ||||
|     d_pdi_code = 0.001;// Summation interval for code | ||||
|     d_dlldampingratio=0.7; | ||||
| } | ||||
|  | ||||
| tracking_2nd_DLL_filter::~tracking_2nd_DLL_filter () | ||||
|   | ||||
| @@ -1,10 +1,12 @@ | ||||
| /*! | ||||
|  * \file tracking_2nd_DLL_filter.h | ||||
|  * \brief Class that implements 2 order DLL filter for code tracking loop. | ||||
|  * \brief Interface of a 2nd order DLL filter for code tracking loop. | ||||
|  * \author Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * Class that implements 2 order PLL filter for code tracking loop. The algorithm is described in: | ||||
|  * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S. H. Jensen, A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach, | ||||
|  * Class that implements a 2nd order PLL filter for code tracking loop. | ||||
|  * The algorithm is described in: | ||||
|  * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S. H. Jensen, | ||||
|  * A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach, | ||||
|  * Birkhauser, 2007, Applied and Numerical Harmonic Analysis. | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|   | ||||
| @@ -1,11 +1,12 @@ | ||||
| /*! | ||||
|  * \file tracking_2nd_PLL_filter.cc | ||||
|  * \brief Class that implements 2 order PLL filter for tracking carrier loop. | ||||
|  * \brief Implementation of a 2nd order PLL filter for tracking carrier loop. | ||||
|  * \author Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * Class that implements 2 order PLL filter for tracking carrier loop. The algorithm is described in [1] | ||||
|  * | ||||
|  * [1] K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.~H.~Jensen, A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach, | ||||
|  * Class that implements 2 order PLL filter for tracking carrier loop. The algorithm | ||||
|  * is described in: | ||||
|  * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.~H.~Jensen, A Software-Defined | ||||
|  * GPS and Galileo Receiver. A Single-Frequency Approach, | ||||
|  * Birkhauser, 2007, Applied and Numerical Harmonic Analysis. | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|   | ||||
| @@ -1,10 +1,12 @@ | ||||
| /*! | ||||
|  * \file tracking_2nd_PLL_filter.h | ||||
|  * \brief Class that implements 2 order PLL filter for carrier tracking loop | ||||
|  * \brief Interface of a 2nd order PLL filter for carrier tracking loop | ||||
|  * \author Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * Class that implements 2 order PLL filter for tracking carrier loop. The algorithm is described in | ||||
|  * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.~H.~Jensen, A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach, | ||||
|  * Class that implements 2 order PLL filter for tracking carrier loop. | ||||
|  * The algorithm is described in | ||||
|  * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H. Jensen, | ||||
|  * A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach, | ||||
|  * Birkhauser, 2007, Applied and Numerical Harmonic Analysis. | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| /*! | ||||
|  * \file tracking_FLL_PLL_filter.cc | ||||
|  * \brief Class that implements hybrid FLL and PLL filter for tracking carrier loop | ||||
|  * \brief Implementation of a hybrid FLL and PLL filter for tracking carrier loop | ||||
|  * \author Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * Class that implements hybrid FLL and PLL filter for tracking carrier loop | ||||
| @@ -36,76 +36,76 @@ | ||||
|  | ||||
| void tracking_FLL_PLL_filter::set_params(float fll_bw_hz,float pll_bw_hz, int order) | ||||
| { | ||||
|     /*! | ||||
|     /* | ||||
|      * Filter design (Kaplan 2nd ed., Pag. 181 Fig. 181) | ||||
|      */ | ||||
| 	d_order=order; | ||||
|     d_order=order; | ||||
|     if (d_order==3) | ||||
|     { | ||||
|     	/*! | ||||
|     	 *  3rd order PLL with 2nd order FLL assist | ||||
|     	 */ | ||||
|         d_pll_b3 = 2.400; | ||||
|         d_pll_a3 = 1.100; | ||||
|         d_pll_a2 = 1.414; | ||||
|         d_pll_w0p = pll_bw_hz/0.7845; | ||||
|         d_pll_w0p2 = d_pll_w0p*d_pll_w0p; | ||||
|         d_pll_w0p3 = d_pll_w0p2*d_pll_w0p; | ||||
|         { | ||||
|             /* | ||||
|              *  3rd order PLL with 2nd order FLL assist | ||||
|              */ | ||||
|             d_pll_b3 = 2.400; | ||||
|             d_pll_a3 = 1.100; | ||||
|             d_pll_a2 = 1.414; | ||||
|             d_pll_w0p = pll_bw_hz/0.7845; | ||||
|             d_pll_w0p2 = d_pll_w0p*d_pll_w0p; | ||||
|             d_pll_w0p3 = d_pll_w0p2*d_pll_w0p; | ||||
|  | ||||
|         d_pll_w0f = fll_bw_hz/0.53; | ||||
|         d_pll_w0f2 = d_pll_w0f*d_pll_w0f; | ||||
|     }else | ||||
|     { | ||||
|     	/*! | ||||
|     	 * 2rd order PLL with 1st order FLL assist | ||||
|     	*/ | ||||
|         d_pll_a2 = 1.414; | ||||
|         d_pll_w0p = pll_bw_hz/0.53; | ||||
|         d_pll_w0p2 = d_pll_w0p*d_pll_w0p; | ||||
|         d_pll_w0f = fll_bw_hz/0.25; | ||||
|     } | ||||
|             d_pll_w0f = fll_bw_hz/0.53; | ||||
|             d_pll_w0f2 = d_pll_w0f*d_pll_w0f; | ||||
|         }else | ||||
|             { | ||||
|                 /* | ||||
|                  * 2nd order PLL with 1st order FLL assist | ||||
|                  */ | ||||
|                 d_pll_a2 = 1.414; | ||||
|                 d_pll_w0p = pll_bw_hz/0.53; | ||||
|                 d_pll_w0p2 = d_pll_w0p*d_pll_w0p; | ||||
|                 d_pll_w0f = fll_bw_hz/0.25; | ||||
|             } | ||||
|  | ||||
| } | ||||
| void tracking_FLL_PLL_filter::initialize(float d_acq_carrier_doppler_hz) | ||||
| { | ||||
| 	if (d_order==3) | ||||
| 	{ | ||||
| 		d_pll_x 		= 2.0*d_acq_carrier_doppler_hz; | ||||
| 		d_pll_w	= 0; | ||||
| 	}else{ | ||||
| 		d_pll_w 		= d_acq_carrier_doppler_hz; | ||||
| 		d_pll_x 		= 0; | ||||
| 	} | ||||
|     if (d_order==3) | ||||
|         { | ||||
|             d_pll_x 		= 2.0*d_acq_carrier_doppler_hz; | ||||
|             d_pll_w	= 0; | ||||
|         }else{ | ||||
|                 d_pll_w 		= d_acq_carrier_doppler_hz; | ||||
|                 d_pll_x 		= 0; | ||||
|         } | ||||
| } | ||||
|  | ||||
| float tracking_FLL_PLL_filter::get_carrier_error(float FLL_discriminator, float PLL_discriminator, float correlation_time_s) | ||||
| { | ||||
| 	float carrier_error_hz; | ||||
| 	if (d_order==3) | ||||
| 	{ | ||||
|     	/*! | ||||
|     	 *  3rd order PLL with 2nd order FLL assist | ||||
|     	 */ | ||||
| 		d_pll_w = d_pll_w + correlation_time_s * (d_pll_w0p3 * PLL_discriminator + d_pll_w0f2 * FLL_discriminator); | ||||
| 	    d_pll_x = d_pll_x + correlation_time_s * (0.5*d_pll_w + d_pll_a2 * d_pll_w0f * FLL_discriminator + d_pll_a3 * d_pll_w0p2 * PLL_discriminator); | ||||
| 		carrier_error_hz  = 0.5*d_pll_x + d_pll_b3 * d_pll_w0p * PLL_discriminator; | ||||
| 	}else | ||||
| 	{ | ||||
|     	/*! | ||||
|     	 * 2rd order PLL with 1st order FLL assist | ||||
|     	*/ | ||||
| 	   float pll_w_new; | ||||
| 	   pll_w_new = d_pll_w + PLL_discriminator*d_pll_w0p2*correlation_time_s + FLL_discriminator*d_pll_w0f*correlation_time_s ; | ||||
| 	   carrier_error_hz = 0.5*(pll_w_new + d_pll_w)+d_pll_a2 * d_pll_w0p*PLL_discriminator; | ||||
| 	   d_pll_w =pll_w_new; | ||||
| 	   /*std::cout<<" d_pll_w = "<<carrier_error_hz<< | ||||
|     float carrier_error_hz; | ||||
|     if (d_order==3) | ||||
|         { | ||||
|             /* | ||||
|              *  3rd order PLL with 2nd order FLL assist | ||||
|              */ | ||||
|             d_pll_w = d_pll_w + correlation_time_s * (d_pll_w0p3 * PLL_discriminator + d_pll_w0f2 * FLL_discriminator); | ||||
|             d_pll_x = d_pll_x + correlation_time_s * (0.5*d_pll_w + d_pll_a2 * d_pll_w0f * FLL_discriminator + d_pll_a3 * d_pll_w0p2 * PLL_discriminator); | ||||
|             carrier_error_hz  = 0.5*d_pll_x + d_pll_b3 * d_pll_w0p * PLL_discriminator; | ||||
|         }else | ||||
|             { | ||||
|                 /* | ||||
|                  * 2nd order PLL with 1st order FLL assist | ||||
|                  */ | ||||
|                 float pll_w_new; | ||||
|                 pll_w_new = d_pll_w + PLL_discriminator*d_pll_w0p2*correlation_time_s + FLL_discriminator*d_pll_w0f*correlation_time_s ; | ||||
|                 carrier_error_hz = 0.5*(pll_w_new + d_pll_w)+d_pll_a2 * d_pll_w0p*PLL_discriminator; | ||||
|                 d_pll_w =pll_w_new; | ||||
|                 /*std::cout<<" d_pll_w = "<<carrier_error_hz<< | ||||
| 			   ", pll_w_new = "<<pll_w_new | ||||
| 			   <<", PLL_discriminator=" <<PLL_discriminator | ||||
| 			   <<" FLL_discriminator ="<<FLL_discriminator | ||||
| 			   <<" correlation_time_s = "<<correlation_time_s<<"\r\n";*/ | ||||
| 	} | ||||
|             } | ||||
|  | ||||
| 	return carrier_error_hz; | ||||
|     return carrier_error_hz; | ||||
|  | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,10 +1,8 @@ | ||||
| /*! | ||||
|  * \file tracking_FLL_PLL_filter.h | ||||
|  * \brief Class that implements hybrid FLL and PLL filter for tracking carrier loop | ||||
|  * \brief Interface of a hybrid FLL and PLL filter for tracking carrier loop | ||||
|  * \author Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * Class that implements hybrid FLL and PLL filter for tracking carrier loop | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  * | ||||
|  * Copyright (C) 2010-2011  (see AUTHORS file for a list of contributors) | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| /*! | ||||
|  * \file tracking_discriminators.cc | ||||
|  * \brief Library with a set of code tracking and carrier tracking discriminators that is used by the tracking algorithms | ||||
|  * \brief Implementation of a library with a set of code tracking | ||||
|  * and carrier tracking discriminators that is used by the tracking algorithms. | ||||
|  * \author Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * | ||||
| @@ -33,7 +34,7 @@ | ||||
| #include <math.h> | ||||
|  | ||||
| //  All the outputs are in RADIANS | ||||
| /*! | ||||
| /* | ||||
|  * FLL four quadrant arctan discriminator: | ||||
|  * \f{equation} | ||||
|  * 	\frac{\phi_2-\phi_1}{t_2-t1}=\frac{ATAN2(cross,dot)}{t_1-t_2}, | ||||
| @@ -45,13 +46,14 @@ | ||||
|  | ||||
| float fll_four_quadrant_atan(gr_complex prompt_s1, gr_complex prompt_s2,float t1, float t2) | ||||
| { | ||||
| 	float cross,dot; | ||||
| 	dot=prompt_s1.imag()*prompt_s2.imag()+prompt_s1.real()*prompt_s2.real(); | ||||
| 	cross=prompt_s1.imag()*prompt_s2.real()-prompt_s2.imag()*prompt_s1.real(); | ||||
| 	return atan2(cross,dot)/(t2-t1); | ||||
|     float cross,dot; | ||||
|     dot=prompt_s1.imag()*prompt_s2.imag()+prompt_s1.real()*prompt_s2.real(); | ||||
|     cross=prompt_s1.imag()*prompt_s2.real()-prompt_s2.imag()*prompt_s1.real(); | ||||
|     return atan2(cross,dot)/(t2-t1); | ||||
| } | ||||
|  | ||||
| /*! | ||||
|  | ||||
| /* | ||||
|  * PLL four quadrant arctan discriminator: | ||||
|  * \f{equation} | ||||
|  * 	\phi=ATAN2(Q_{PS},I_{PS}), | ||||
| @@ -60,27 +62,29 @@ float fll_four_quadrant_atan(gr_complex prompt_s1, gr_complex prompt_s2,float t1 | ||||
|  */ | ||||
| float pll_four_quadrant_atan(gr_complex prompt_s1) | ||||
| { | ||||
| 	return atan2(prompt_s1.real(),prompt_s1.imag()); | ||||
|     return atan2(prompt_s1.real(),prompt_s1.imag()); | ||||
| } | ||||
|  | ||||
| /*! | ||||
|  | ||||
| /* | ||||
|  * PLL Costas loop two quadrant arctan discriminator: | ||||
|  * \f{equation} | ||||
|  * 	\phi=ATAN\left(\frac{Q_{PS}}{I_{PS}}\right), | ||||
|  * \f} | ||||
|  * where \f$I_{PS1},Q_{PS1}\f$ are the inphase and quadrature prompt correlator outputs respectively. The output is in [radians]. | ||||
|  */ | ||||
|  | ||||
| float pll_cloop_two_quadrant_atan(gr_complex prompt_s1) | ||||
| { | ||||
| 	if (prompt_s1.imag()!=0.0) | ||||
| 	{ | ||||
| 		return atan(prompt_s1.real()/prompt_s1.imag()); | ||||
| 	}else{ | ||||
| 		return 0; | ||||
| 	} | ||||
|     if (prompt_s1.imag()!=0.0) | ||||
|         { | ||||
|             return atan(prompt_s1.real()/prompt_s1.imag()); | ||||
|         }else{ | ||||
|                 return 0; | ||||
|         } | ||||
| } | ||||
| /*! | ||||
|  | ||||
|  | ||||
| /* | ||||
|  * DLL Noncoherent Early minus Late envelope normalized discriminator: | ||||
|  * \f{equation} | ||||
|  * 	error=\frac{E-L}{E+L}, | ||||
| @@ -90,8 +94,8 @@ float pll_cloop_two_quadrant_atan(gr_complex prompt_s1) | ||||
|  */ | ||||
| float dll_nc_e_minus_l_normalized(gr_complex early_s1, gr_complex late_s1) | ||||
| { | ||||
| 	float P_early, P_late; | ||||
| 	P_early=std::abs(early_s1); | ||||
| 	P_late=std::abs(late_s1); | ||||
| 	return (P_early-P_late)/((P_early+P_late)); | ||||
|     float P_early, P_late; | ||||
|     P_early=std::abs(early_s1); | ||||
|     P_late=std::abs(late_s1); | ||||
|     return (P_early-P_late)/((P_early+P_late)); | ||||
| } | ||||
|   | ||||
| @@ -1,9 +1,11 @@ | ||||
| /*! | ||||
|  * \file tracking_discriminators.h | ||||
|  * \brief Library with a set of code tracking and carrier tracking disctiminators | ||||
|  * \brief Interface of a library with a set of code tracking and carrier | ||||
|  * tracking discriminators. | ||||
|  * \author Javier Arribas, 2011. jarribas(at)cttc.es | ||||
|  * | ||||
|  * Library with a set of code tracking and carrier tracking disctiminators that is used by the tracking algorithms | ||||
|  * Library with a set of code tracking and carrier tracking discriminators | ||||
|  * that is used by the tracking algorithms. | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  * | ||||
| @@ -35,12 +37,50 @@ | ||||
|  | ||||
| #include <gnuradio/gr_complex.h> | ||||
|  | ||||
| /*! brief FLL four quadrant arctan discriminator | ||||
|  * | ||||
|  * FLL four quadrant arctan discriminator: | ||||
|  * \f{equation} | ||||
|  * 	\frac{\phi_2-\phi_1}{t_2-t1}=\frac{ATAN2(cross,dot)}{t_1-t_2}, | ||||
|  * \f} | ||||
|  * where \f$cross=I_{PS1}Q_{PS2}-I_{PS2}Q_{PS1}\f$ and \f$dot=I_{PS1}I_{PS2}+Q_{PS1}Q_{PS2}\f$, | ||||
|  * \f$I_{PS1},Q_{PS1}\f$ are the inphase and quadrature prompt correlator outputs respectively at sample time \f$t_1\f$, and | ||||
|  * \f$I_{PS2},Q_{PS2}\f$ are the inphase and quadrature prompt correlator outputs respectively at sample time \f$t_2\f$. The output is in [radians/second]. | ||||
|  */ | ||||
| float fll_four_quadrant_atan(gr_complex prompt_s1, gr_complex prompt_s2,float t1, float t2); | ||||
|  | ||||
|  | ||||
| /*! \brief PLL four quadrant arctan discriminator | ||||
|  * | ||||
|  * PLL four quadrant arctan discriminator: | ||||
|  * \f{equation} | ||||
|  * 	\phi=ATAN2(Q_{PS},I_{PS}), | ||||
|  * \f} | ||||
|  * where \f$I_{PS1},Q_{PS1}\f$ are the inphase and quadrature prompt correlator outputs respectively. The output is in [radians]. | ||||
|  */ | ||||
| float pll_four_quadrant_atan(gr_complex prompt_s1); | ||||
|  | ||||
|  | ||||
| /*! \brief PLL Costas loop two quadrant arctan discriminator | ||||
|  * | ||||
|  * PLL Costas loop two quadrant arctan discriminator: | ||||
|  * \f{equation} | ||||
|  * 	\phi=ATAN\left(\frac{Q_{PS}}{I_{PS}}\right), | ||||
|  * \f} | ||||
|  * where \f$I_{PS1},Q_{PS1}\f$ are the inphase and quadrature prompt correlator outputs respectively. The output is in [radians]. | ||||
|  */ | ||||
| float pll_cloop_two_quadrant_atan(gr_complex prompt_s1); | ||||
|  | ||||
|  | ||||
| /*! \brief DLL Noncoherent Early minus Late envelope normalized discriminator | ||||
|  * | ||||
|  * DLL Noncoherent Early minus Late envelope normalized discriminator: | ||||
|  * \f{equation} | ||||
|  * 	error=\frac{E-L}{E+L}, | ||||
|  * \f} | ||||
|  * where \f$E=\sqrt{I_{ES}^2,Q_{ES}^2}\f$ is the Early correlator output absolute value and | ||||
|  * \f$L=\sqrt{I_{LS}^2,Q_{LS}^2}\f$ is the Late correlator output absolute value. The output is in [chips]. | ||||
|  */ | ||||
| float dll_nc_e_minus_l_normalized(gr_complex early_s1, gr_complex late_s1); | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez