From 3b7c8a448cbd53b394cc405357ad0831096066f5 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 7 Oct 2009 11:02:44 -0700 Subject: [PATCH] Clipping the rate of the clock recovery helps track large changes. --- .../src/lib/filter/gr_pfb_clock_sync_ccf.cc | 28 +++- gnuradio-examples/grc/demod/pam_timing.grc | 142 +++++++++--------- 2 files changed, 91 insertions(+), 79 deletions(-) diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc index 62282fd6..35fe2a88 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc @@ -115,13 +115,15 @@ gr_pfb_clock_sync_ccf::set_taps (const std::vector &newtaps, // Partition the filter for(i = 0; i < d_nfilters; i++) { // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - ourtaps[i] = std::vector(d_taps_per_filter, 0); + //ourtaps[i] = std::vector(d_taps_per_filter, 0); + ourtaps[d_nfilters-1-i] = std::vector(d_taps_per_filter, 0); for(j = 0; j < d_taps_per_filter; j++) { - ourtaps[i][j] = tmp_taps[i + j*d_nfilters]; // add taps to channels in reverse order + ourtaps[d_nfilters - 1 - i][j] = tmp_taps[i + j*d_nfilters]; } // Build a filter for each channel and add it's taps to it - ourfilter[i]->set_taps(ourtaps[i]); + //ourfilter[i]->set_taps(ourtaps[i]); + ourfilter[i]->set_taps(ourtaps[d_nfilters-1-i]); } // Set the history to ensure enough input items for each filter @@ -156,26 +158,30 @@ void gr_pfb_clock_sync_ccf::print_taps() { unsigned int i, j; + printf("[ "); for(i = 0; i < d_nfilters; i++) { - printf("filter[%d]: [%.4e, ", i, d_taps[i][0]); + printf("[%.4e, ", d_taps[i][0]); for(j = 1; j < d_taps_per_filter-1; j++) { printf("%.4e,", d_taps[i][j]); } - printf("%.4e]\n", d_taps[i][j]); + printf("%.4e],", d_taps[i][j]); } + printf(" ]\n"); } void gr_pfb_clock_sync_ccf::print_diff_taps() { unsigned int i, j; + printf("[ "); for(i = 0; i < d_nfilters; i++) { - printf("filter[%d]: [%.4e, ", i, d_dtaps[i][0]); + printf("[%.4e, ", d_dtaps[i][0]); for(j = 1; j < d_taps_per_filter-1; j++) { printf("%.4e,", d_dtaps[i][j]); } - printf("%.4e]\n", d_dtaps[i][j]); + printf("%.4e],", d_dtaps[i][j]); } + printf(" ]\n"); } @@ -232,12 +238,15 @@ gr_pfb_clock_sync_ccf::general_work (int noutput_items, // produce output as long as we can and there are enough input samples while((i < noutput_items) && (count < nrequired)) { int filtnum = (int)d_k; + + // FIXME: prevent this from asserting + assert(filtnum < d_nfilters); out[i] = d_filters[filtnum]->filter(&in[count]); error = (out[i] * d_diff_filters[filtnum]->filter(&in[count])).real(); d_k = d_k + d_alpha*error + d_rate; d_rate = d_rate + d_beta*error; - while(d_k >= d_nfilters) { + while(d_k >= (float)d_nfilters) { d_k -= d_nfilters; count++; } @@ -245,6 +254,9 @@ gr_pfb_clock_sync_ccf::general_work (int noutput_items, d_k += d_nfilters; count--; } + + // Keep our rate within a good range + d_rate = gr_branchless_clip(d_rate, 1.5); i++; count += d_sps; diff --git a/gnuradio-examples/grc/demod/pam_timing.grc b/gnuradio-examples/grc/demod/pam_timing.grc index ab34677f..21fb63ab 100644 --- a/gnuradio-examples/grc/demod/pam_timing.grc +++ b/gnuradio-examples/grc/demod/pam_timing.grc @@ -1,6 +1,6 @@ - Tue Oct 6 22:05:15 2009 + Wed Oct 7 11:00:26 2009 options @@ -820,54 +820,42 @@ - variable_slider + gr_pfb_clock_sync_ccf id - alpha + gr_pfb_clock_sync_ccf_0 _enabled True - label - Alpha - - - value - 0 - - - min - 0 - - - max - 1 + sps + spb - num_steps - 1000 + alpha + alpha - style - wx.SL_HORIZONTAL + beta + beta - converver - float_converter + taps + rrctaps - grid_pos - + filter_size + nfilts - notebook - + init_phase + 14 _coordinate - (757, -1) + (346, 773) _rotation @@ -875,42 +863,22 @@ - gr_pfb_clock_sync_ccf + variable id - gr_pfb_clock_sync_ccf_0 + rrctaps _enabled True - sps - spb - - - alpha - alpha - - - beta - beta - - - taps - rrctaps - - - filter_size - nfilts - - - init_phase - 14 + value + firdes.root_raised_cosine(nfilts,1.0,1.0/(spb*nfilts), .35, 11*spb*nfilts) _coordinate - (346, 773) + (110, 830) _rotation @@ -921,7 +889,7 @@ variable_slider id - interpratio + beta _enabled @@ -929,19 +897,19 @@ label - + Beta value - 1 + 10e-3 min - 0 + 0.0 max - 2 + 0.1 num_steps @@ -965,30 +933,62 @@ _coordinate - (232, 921) + (871, 0) _rotation - 180 + 0 - variable + variable_slider id - rrctaps + alpha _enabled True + + label + Alpha + value - firdes.root_raised_cosine(nfilts,1.0,1.0/(spb*nfilts), .35, 11*spb*nfilts) + 2 + + + min + 0 + + + max + 10 + + + num_steps + 1000 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + _coordinate - (110, 830) + (757, -1) _rotation @@ -999,7 +999,7 @@ variable_slider id - beta + interpratio _enabled @@ -1007,19 +1007,19 @@ label - Beta + value - 0 + 1.001 min - 0.0 + 0 max - 0.1 + 2 num_steps @@ -1043,11 +1043,11 @@ _coordinate - (871, 0) + (757, 133) _rotation - 0 + 180 -- 2.30.2