1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-12-02 22:58:07 +00:00

Changed the "CN_estimators" library name by the more informative "lock_detectors". The CN0 estimators for GPS L1 C/A and Galileo E1 have been unified

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@254 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
Carles Fernandez
2012-10-21 09:54:37 +00:00
parent 3628453c52
commit 1aea9db69f
11 changed files with 63 additions and 121 deletions

View File

@@ -1,7 +1,7 @@
project : build-dir ../../../../build ;
obj tracking_discriminators : tracking_discriminators.cc ;
obj CN_estimators : CN_estimators.cc ;
obj lock_detectors : lock_detectors.cc ;
obj tracking_FLL_PLL_filter : tracking_FLL_PLL_filter.cc ;
obj tracking_2nd_PLL_filter : tracking_2nd_PLL_filter.cc ;
obj tracking_2nd_DLL_filter : tracking_2nd_DLL_filter.cc ;

View File

@@ -1,7 +1,6 @@
/*!
* \file CN_estimators.cc
* \brief Implementation of a library with a set of Carrier to Noise
* estimators and lock detectors.
* \file lock_detectors.cc
* \brief Implementation of a library with a set of code and carrier phase lock detectors.
*
* SNV_CN0 is a Carrier-to-Noise (CN0) estimator
* based on the Signal-to-Noise Variance (SNV) estimator [1].
@@ -46,7 +45,8 @@
*
* -------------------------------------------------------------------------
*/
#include "CN_estimators.h"
#include "lock_detectors.h"
#include "GPS_L1_CA.h"
#include "Galileo_E1.h"
#include <gnuradio/gr_complex.h>
@@ -68,73 +68,28 @@
* 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)
float cn0_svn_estimator(gr_complex* Prompt_buffer, int length, long fs_in, double code_length)
{
// estimate CN0 using buffered values
// MATLAB CODE
// 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_real;
float Psig, Ptot;
Psig = 0;
Ptot = 0;
float SNR = 0;
float SNR_dB_Hz = 0;
float Psig = 0;
float Ptot = 0;
for (int i=0; i<length; i++)
{
tmp_abs_real = std::abs(Prompt_buffer[i].real());
Psig += tmp_abs_real;
Psig += std::abs(Prompt_buffer[i].real());
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;
}
/*
* 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.
*
*/
float galileo_e1_CN0_SNV(gr_complex* Prompt_buffer, int length, long fs_in)
{
// estimate CN0 using buffered values
// MATLAB CODE
// 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_real;
float Psig, Ptot;
Psig = 0;
Ptot = 0;
for (int i=0; i<length; i++)
{
tmp_abs_real= std::abs(Prompt_buffer[i].real());
Psig += tmp_abs_real;
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(Galileo_E1_B_CODE_LENGTH_CHIPS);
Ptot = Ptot / (float)length;
SNR = Psig / (Ptot - Psig);
SNR_dB_Hz = 10 * log10(SNR) + 10 * log10(fs_in/2) - 10 * log10((float)code_length);
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
* The estimate of the cosine of twice the carrier phase error is given by
* \f{equation}
* \cos(2\phi)=\frac{NBD}{NBP},
* \f}
@@ -144,15 +99,10 @@ float galileo_e1_CN0_SNV(gr_complex* Prompt_buffer, int length, long fs_in)
*/
float carrier_lock_detector(gr_complex* Prompt_buffer, int length)
{
/*
* carrier lock detector
*/
// estimate using buffered values
float tmp_sum_I, tmp_sum_Q;
tmp_sum_I = 0;
tmp_sum_Q = 0;
float NBD,NBP;
float tmp_sum_I = 0;
float tmp_sum_Q = 0;
float NBD = 0;
float NBP = 0;
for (int i=0; i<length; i++)
{
tmp_sum_I += Prompt_buffer[i].real();
@@ -162,4 +112,3 @@ float carrier_lock_detector(gr_complex* Prompt_buffer, int length)
NBD = tmp_sum_I*tmp_sum_I - tmp_sum_Q*tmp_sum_Q;
return NBD/NBP;
}

View File

@@ -1,7 +1,6 @@
/*!
* \file CN_estimators.h
* \brief Interface of a library with a set of Carrier to Noise
* estimators and lock detectors.
* \file lock_detectors.h
* \brief Interface of a library with a set of code and carrier phase lock detectors.
*
* SNV_CN0 is a Carrier-to-Noise (CN0) estimator
* based on the Signal-to-Noise Variance (SNV) estimator [1].
@@ -23,7 +22,7 @@
* </ul>
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
@@ -46,33 +45,12 @@
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_CN_ESTIMATORS_H_
#define GNSS_SDR_CN_ESTIMATORS_H_
#ifndef GNSS_SDR_LOCK_DETECTORS_H_
#define GNSS_SDR_LOCK_DETECTORS_H_
#include <gnuradio/gr_complex.h>
/*! \brief CN0_SNV 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 CN0_SNV is a Carrier-to-Noise (CN0) estimator
* based on the Signal-to-Noise Variance (SNV) estimator
*
@@ -94,11 +72,13 @@ float gps_l1_ca_CN0_SNV(gr_complex* Prompt_buffer, int length, long fs_in);
* IEEE 10th International Symposium on Spread Spectrum Techniques and
* Applications, pp.28-30, August 2008.
*/
float galileo_e1_CN0_SNV(gr_complex* Prompt_buffer, int length, long fs_in);
float cn0_svn_estimator(gr_complex* Prompt_buffer, int length, long fs_in, double code_length);
/*! \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
* The Carrier Phase Lock Detector block uses the estimate of the cosine of twice the carrier phase error is given by
* \f{equation}
* C2\phi=\frac{NBD}{NBP},
* \f}