2011-11-22 17:21:54 +00:00
|
|
|
/*!
|
|
|
|
* \file tracking_discriminators.cc
|
2011-12-28 21:36:45 +00:00
|
|
|
* \brief Implementation of a library with a set of code tracking
|
|
|
|
* and carrier tracking discriminators that is used by the tracking algorithms.
|
2012-09-12 15:03:38 +00:00
|
|
|
* \authors <ul>
|
|
|
|
* <li> Javier Arribas, 2011. jarribas(at)cttc.es
|
|
|
|
* <li> Luis Esteve, 2012. luis(at)epsilon-formacion.com
|
|
|
|
* </ul>
|
2011-11-22 17:21:54 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2015-01-08 18:49:59 +00:00
|
|
|
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
|
2011-11-22 17:21:54 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
|
|
|
* GNSS-SDR is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
2015-01-08 18:49:59 +00:00
|
|
|
* (at your option) any later version.
|
2011-11-22 17:21:54 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "tracking_discriminators.h"
|
2013-07-04 13:47:40 +00:00
|
|
|
#include <cmath>
|
2011-11-22 17:21:54 +00:00
|
|
|
|
|
|
|
// All the outputs are in RADIANS
|
2011-12-28 21:36:45 +00:00
|
|
|
/*
|
2011-11-22 17:21:54 +00:00
|
|
|
* FLL four quadrant arctan discriminator:
|
|
|
|
* \f{equation}
|
2016-05-02 21:46:30 +00:00
|
|
|
* \frac{\phi_2-\phi_1}{t_2-t1}=\frac{ATAN2(cross,dot)}{t_1-t_2},
|
2011-11-22 17:21:54 +00:00
|
|
|
* \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].
|
|
|
|
*/
|
|
|
|
|
2015-11-26 17:44:04 +00:00
|
|
|
double fll_four_quadrant_atan(gr_complex prompt_s1, gr_complex prompt_s2, double t1, double t2)
|
2011-11-22 17:21:54 +00:00
|
|
|
{
|
2015-11-26 17:44:04 +00:00
|
|
|
double cross, dot;
|
2013-07-04 13:47:40 +00:00
|
|
|
dot = prompt_s1.real()*prompt_s2.real() + prompt_s1.imag()*prompt_s2.imag();
|
2012-10-18 10:24:41 +00:00
|
|
|
cross = prompt_s1.real()*prompt_s2.imag() - prompt_s2.real()*prompt_s1.imag();
|
2012-01-11 09:01:24 +00:00
|
|
|
return atan2(cross, dot) / (t2-t1);
|
2011-11-22 17:21:54 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 21:36:45 +00:00
|
|
|
|
|
|
|
/*
|
2011-11-22 17:21:54 +00:00
|
|
|
* PLL four quadrant arctan discriminator:
|
|
|
|
* \f{equation}
|
2016-05-02 21:46:30 +00:00
|
|
|
* \phi=ATAN2(Q_{PS},I_{PS}),
|
2011-11-22 17:21:54 +00:00
|
|
|
* \f}
|
|
|
|
* where \f$I_{PS1},Q_{PS1}\f$ are the inphase and quadrature prompt correlator outputs respectively. The output is in [radians].
|
|
|
|
*/
|
2015-11-26 17:44:04 +00:00
|
|
|
double pll_four_quadrant_atan(gr_complex prompt_s1)
|
2011-11-22 17:21:54 +00:00
|
|
|
{
|
2012-10-18 10:24:41 +00:00
|
|
|
return atan2(prompt_s1.imag(), prompt_s1.real());
|
2011-11-22 17:21:54 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 21:36:45 +00:00
|
|
|
|
|
|
|
/*
|
2011-11-22 17:21:54 +00:00
|
|
|
* PLL Costas loop two quadrant arctan discriminator:
|
|
|
|
* \f{equation}
|
2016-05-02 21:46:30 +00:00
|
|
|
* \phi=ATAN\left(\frac{Q_{PS}}{I_{PS}}\right),
|
2011-11-22 17:21:54 +00:00
|
|
|
* \f}
|
|
|
|
* where \f$I_{PS1},Q_{PS1}\f$ are the inphase and quadrature prompt correlator outputs respectively. The output is in [radians].
|
|
|
|
*/
|
2015-11-26 17:44:04 +00:00
|
|
|
double pll_cloop_two_quadrant_atan(gr_complex prompt_s1)
|
2011-11-22 17:21:54 +00:00
|
|
|
{
|
2012-10-18 10:24:41 +00:00
|
|
|
if (prompt_s1.real() != 0.0)
|
2011-12-28 21:36:45 +00:00
|
|
|
{
|
2012-10-18 10:24:41 +00:00
|
|
|
return atan(prompt_s1.imag() / prompt_s1.real());
|
2012-01-11 09:01:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
2011-12-28 21:36:45 +00:00
|
|
|
}
|
2011-11-22 17:21:54 +00:00
|
|
|
}
|
2011-12-28 21:36:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2011-11-22 17:21:54 +00:00
|
|
|
* DLL Noncoherent Early minus Late envelope normalized discriminator:
|
|
|
|
* \f{equation}
|
2016-05-02 21:46:30 +00:00
|
|
|
* error=\frac{1}{2}\frac{E-L}{E+L},
|
2011-11-22 17:21:54 +00:00
|
|
|
* \f}
|
2012-08-28 13:38:33 +00:00
|
|
|
* 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].
|
2011-11-22 17:21:54 +00:00
|
|
|
*/
|
2015-11-26 17:44:04 +00:00
|
|
|
double dll_nc_e_minus_l_normalized(gr_complex early_s1, gr_complex late_s1)
|
2011-11-22 17:21:54 +00:00
|
|
|
{
|
2015-11-26 17:44:04 +00:00
|
|
|
double P_early, P_late;
|
2012-01-11 09:01:24 +00:00
|
|
|
P_early = std::abs(early_s1);
|
|
|
|
P_late = std::abs(late_s1);
|
2015-11-22 08:00:24 +00:00
|
|
|
if( P_early + P_late == 0.0 )
|
2015-11-30 09:18:09 +00:00
|
|
|
{
|
|
|
|
return 0.0;
|
|
|
|
}
|
2015-11-22 08:00:24 +00:00
|
|
|
else
|
2015-11-30 09:18:09 +00:00
|
|
|
{
|
|
|
|
return 0.5 * (P_early - P_late) / ((P_early + P_late));
|
|
|
|
}
|
2011-11-22 17:21:54 +00:00
|
|
|
}
|
2012-08-28 13:38:33 +00:00
|
|
|
|
|
|
|
/*
|
2012-09-12 15:03:38 +00:00
|
|
|
* DLL Noncoherent Very Early Minus Late Power (VEMLP) normalized discriminator, using the outputs
|
|
|
|
* of four correlators, Very Early (VE), Early (E), Late (L) and Very Late (VL):
|
2012-08-28 13:38:33 +00:00
|
|
|
* \f{equation}
|
|
|
|
* error=\frac{E-L}{E+L},
|
|
|
|
* \f}
|
|
|
|
* where \f$E=\sqrt{I_{VE}^2+Q_{VE}^2+I_{E}^2+Q_{E}^2}\f$ and
|
|
|
|
* \f$L=\sqrt{I_{VL}^2+Q_{VL}^2+I_{L}^2+Q_{L}^2}\f$ . The output is in [chips].
|
|
|
|
*/
|
2015-11-26 17:44:04 +00:00
|
|
|
double dll_nc_vemlp_normalized(gr_complex very_early_s1, gr_complex early_s1, gr_complex late_s1, gr_complex very_late_s1)
|
2012-08-28 13:38:33 +00:00
|
|
|
{
|
2015-11-26 17:44:04 +00:00
|
|
|
double P_early, P_late;
|
2013-07-04 13:47:40 +00:00
|
|
|
P_early = std::sqrt(std::norm(very_early_s1) + std::norm(early_s1));
|
|
|
|
P_late = std::sqrt(std::norm(very_late_s1) + std::norm(late_s1));
|
2015-11-30 09:18:09 +00:00
|
|
|
if( P_early + P_late == 0.0 )
|
|
|
|
{
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return (P_early - P_late) / ((P_early + P_late));
|
|
|
|
}
|
2012-08-28 13:38:33 +00:00
|
|
|
}
|