[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8481 - gnuradio/branches/developers/cswiger/wip/gr-at
From: |
cswiger |
Subject: |
[Commit-gnuradio] r8481 - gnuradio/branches/developers/cswiger/wip/gr-atsc/src/lib |
Date: |
Thu, 22 May 2008 10:55:59 -0600 (MDT) |
Author: cswiger
Date: 2008-05-22 10:55:59 -0600 (Thu, 22 May 2008)
New Revision: 8481
Modified:
gnuradio/branches/developers/cswiger/wip/gr-atsc/src/lib/atsc_cpll.cc
gnuradio/branches/developers/cswiger/wip/gr-atsc/src/lib/atsc_cpll.h
Log:
Fixed pll, complex in - real out; adjusted agc reference
Modified: gnuradio/branches/developers/cswiger/wip/gr-atsc/src/lib/atsc_cpll.cc
===================================================================
--- gnuradio/branches/developers/cswiger/wip/gr-atsc/src/lib/atsc_cpll.cc
2008-05-22 05:15:53 UTC (rev 8480)
+++ gnuradio/branches/developers/cswiger/wip/gr-atsc/src/lib/atsc_cpll.cc
2008-05-22 16:55:59 UTC (rev 8481)
@@ -29,8 +29,9 @@
#include <atsc_consts.h>
#include <algorithm>
#include "fpll_btloop_coupling.h"
-#include <math.h>
#include <gr_math.h>
+#include <math.h>
+#include <gr_sincos.h>
#define M_TWOPI (2*M_PI)
@@ -48,7 +49,7 @@
* their value also sets the level of the symbols going
* into the equalizer and viterbi decoder.
*/
-static const float CPLL_AGC_REFERENCE = 2.5 * FPLL_BTLOOP_COUPLING_CONST;
+static const float CPLL_AGC_REFERENCE = 1.7675 * FPLL_BTLOOP_COUPLING_CONST;
static const float CPLL_AGC_RATE = 0.25e-6;
@@ -56,8 +57,8 @@
atsc_cpll::atsc_cpll()
: gr_sync_block("atsc_cpll",
gr_make_io_signature(1, 1, sizeof(gr_complex)),
- gr_make_io_signature(1, 1, sizeof(gr_complex))),
- initial_phase(0)
+ gr_make_io_signature(1, 1, sizeof(float))),
+ initial_phase(0), d_phase(0), d_freq(0)
{
initial_freq = 0 - 3e6 + 0.31e6 + 5e3; // a_initial_freq;
agc.set_rate (CPLL_AGC_RATE);
@@ -71,14 +72,14 @@
{
float Fs = 19.2e6;
- float alpha = 1 - exp(-1.0 / Fs / 5e-6);
+ double alpha = 1 - exp(-1.0 / Fs / 5e-6);
- afci.set_taps (alpha);
- afcq.set_taps (alpha);
+ afc.set_taps (alpha);
printf("Setting initial_freq: %f\n",initial_freq);
- nco.set_freq (initial_freq / Fs * 2 * M_PI);
- nco.set_phase (initial_phase);
+ // nco.set_freq (initial_freq / Fs * 2 * M_PI);
+ // nco.set_phase (initial_phase);
+ d_freq = initial_freq / Fs * 2 * M_PI;
}
float
@@ -100,48 +101,36 @@
sample_phase = gr_fast_atan2f(sample.imag(),sample.real());
return mod_2pi(sample_phase-ref_phase);
}
-
+
int
atsc_cpll::work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const gr_complex *in = (const gr_complex *) input_items[0];
- gr_complex *out = (gr_complex *) output_items[0];
+ float *out = (float *) output_items[0];
for (int k = 0; k < noutput_items; k++){
float a_cos, a_sin;
- gr_complex input;
- input = agc.scale (in[k]);
+ gr_complex input = agc.scale (in[k]);
- nco.step (); // increment phase
- nco.sincos (&a_sin, &a_cos); // compute cos and sin
+ // nco.step (); // increment phase
+ // nco.sincos (&a_sin, &a_cos); // compute cos and sin
+ gr_sincosf(d_phase,&a_sin,&a_cos);
gr_complex IQ = input * gr_complex(a_cos,-a_sin);
- out[k] = IQ;
+ out[k] = IQ.real();
- gr_complex filtered_IQ;
- filtered_IQ.real() = afci.filter (IQ.real());
- filtered_IQ.imag() = afcq.filter (IQ.imag());
+ gr_complex filtered_IQ = afc.filter (IQ);
// phase detector
- // float x = atan2 (filtered_Q, filtered_I);
- float x = phase_detector(filtered_IQ, 0);
+ float x = phase_detector(filtered_IQ,0);
- // avoid slamming filter with big transitions
-
- static const float limit = M_PI / 2;
-
- if (x > limit)
- x = limit;
- else if (x < -limit)
- x = -limit;
-
// static const float alpha = 0.037; // Max value
// static const float alpha = 0.005; // takes about 5k samples to pull
in, stddev = 323
// static const float alpha = 0.002; // takes about 15k samples to pull
in, stddev = 69
@@ -149,8 +138,10 @@
static const float alpha = 0.001;
static const float beta = alpha * alpha / 4;
- nco.adjust_phase (alpha * x);
- nco.adjust_freq (beta * x);
+ // nco.adjust_phase (alpha * x);
+ // nco.adjust_freq (beta * x);
+ d_freq = d_freq + beta * x;
+ d_phase = mod_2pi(d_phase + d_freq + alpha * x);
}
Modified: gnuradio/branches/developers/cswiger/wip/gr-atsc/src/lib/atsc_cpll.h
===================================================================
--- gnuradio/branches/developers/cswiger/wip/gr-atsc/src/lib/atsc_cpll.h
2008-05-22 05:15:53 UTC (rev 8480)
+++ gnuradio/branches/developers/cswiger/wip/gr-atsc/src/lib/atsc_cpll.h
2008-05-22 16:55:59 UTC (rev 8481)
@@ -23,7 +23,7 @@
#define INCLUDED_ATSC_CPLL_H
#include <gr_sync_block.h>
-#include <gr_nco.h>
+// #include <gr_nco.h>
#include <gr_single_pole_iir.h>
#include <gri_agc_cc.h>
#include <stdio.h>
@@ -63,16 +63,16 @@
protected:
+ float d_freq,d_phase;
double initial_freq;
double initial_phase;
bool debug_no_update;
- gr_nco<float,float> nco;
+ // gr_nco<float,float> nco;
gri_agc_cc agc; // automatic gain control
- gr_single_pole_iir<float,float,float> afci;
- gr_single_pole_iir<float,float,float> afcq;
+ gr_single_pole_iir<gr_complex,gr_complex,double> afc;
float mod_2pi (float in);
- float phase_detector(gr_complex sample, float ref_phase);
+ float phase_detector(gr_complex sample,float ref_phase);
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8481 - gnuradio/branches/developers/cswiger/wip/gr-atsc/src/lib,
cswiger <=