Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updates to the calc_loop_gains function, the math was/is a bit wrong.

The implementation is now equivalent to the old calc_loop_coef function but the documentation is still incorrect.
  • Loading branch information...
commit f808820800211a2a7080bb523a3f71da9db18504 1 parent d728a5e
@fnoble fnoble authored
Showing with 11 additions and 1 deletion.
  1. +2 −0  include/track.h
  2. +9 −1 src/track.c
View
2  include/track.h
@@ -39,6 +39,8 @@ typedef struct {
double sat_vel[3];
} navigation_measurement_t;
+void calc_loop_gains(double bw, double zeta, double k, double sample_freq,
+ double *pgain, double *igain);
void calc_navigation_measurement(u8 n_channels, channel_measurement_t meas[],
navigation_measurement_t nav_meas[],
View
10 src/track.c
@@ -86,6 +86,9 @@
* B-Y. Chung, C. Chien, H. Samueli, and R. Jain.
* IEEE Journal on Selected Areas in Communications, 11:1096–1107, 1993.
*
+ * \todo This math is all wrong, these slides show the analysis we want:
+ * http://www.compdsp.com/presentations/Jacobsen/abineau_dpll_analysis.pdf
+ *
* \param bw The loop noise bandwidth, \f$B_L\f$.
* \param zeta The damping ratio, \f$\zeta\f$.
* \param k The loop gain, \f$k\f$.
@@ -95,16 +98,21 @@
* \param igain Where to store the calculated integral gain, \f$k_i\f$.
*/
void calc_loop_gains(double bw, double zeta, double k, double sample_freq,
- double *pgain, double *igain) {
+ double *pgain, double *igain)
+{
/* Find the natural frequency. */
double omega_n = bw*8*zeta / (4*zeta*zeta + 1);
/* Some intermmediate values. */
+/*
double T = 1. / sample_freq;
double denominator = k*(4 + 4*zeta*omega_n*T + omega_n*omega_n*T*T);
*pgain = 8*zeta*omega_n*T / denominator;
*igain = 4*omega_n*omega_n*T*T / denominator;
+*/
+ *igain = omega_n * omega_n / (k * sample_freq);
+ *pgain = 2.0 * zeta * omega_n / k;
}
/** Phase discriminator for a Costas loop.
Please sign in to comment.
Something went wrong with that request. Please try again.