summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom2009-10-07 11:02:44 -0700
committerTom2009-10-07 11:02:44 -0700
commit3b7c8a448cbd53b394cc405357ad0831096066f5 (patch)
treeac2f3c5460dd77a68e9fff34bb2e7917640b07cb
parent1f8e1248f70c4165e4a88b1bac9e9dec903cd668 (diff)
downloadgnuradio-3b7c8a448cbd53b394cc405357ad0831096066f5.tar.gz
gnuradio-3b7c8a448cbd53b394cc405357ad0831096066f5.tar.bz2
gnuradio-3b7c8a448cbd53b394cc405357ad0831096066f5.zip
Clipping the rate of the clock recovery helps track large changes.
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc28
-rw-r--r--gnuradio-examples/grc/demod/pam_timing.grc142
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 62282fd6a..35fe2a886 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<float> &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<float>(d_taps_per_filter, 0);
+ //ourtaps[i] = std::vector<float>(d_taps_per_filter, 0);
+ ourtaps[d_nfilters-1-i] = std::vector<float>(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 ab34677fa..21fb63abe 100644
--- a/gnuradio-examples/grc/demod/pam_timing.grc
+++ b/gnuradio-examples/grc/demod/pam_timing.grc
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='ASCII'?>
<flow_graph>
- <timestamp>Tue Oct 6 22:05:15 2009</timestamp>
+ <timestamp>Wed Oct 7 11:00:26 2009</timestamp>
<block>
<key>options</key>
<param>
@@ -820,54 +820,42 @@
</param>
</block>
<block>
- <key>variable_slider</key>
+ <key>gr_pfb_clock_sync_ccf</key>
<param>
<key>id</key>
- <value>alpha</value>
+ <value>gr_pfb_clock_sync_ccf_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
- <key>label</key>
- <value>Alpha</value>
- </param>
- <param>
- <key>value</key>
- <value>0</value>
- </param>
- <param>
- <key>min</key>
- <value>0</value>
- </param>
- <param>
- <key>max</key>
- <value>1</value>
+ <key>sps</key>
+ <value>spb</value>
</param>
<param>
- <key>num_steps</key>
- <value>1000</value>
+ <key>alpha</key>
+ <value>alpha</value>
</param>
<param>
- <key>style</key>
- <value>wx.SL_HORIZONTAL</value>
+ <key>beta</key>
+ <value>beta</value>
</param>
<param>
- <key>converver</key>
- <value>float_converter</value>
+ <key>taps</key>
+ <value>rrctaps</value>
</param>
<param>
- <key>grid_pos</key>
- <value></value>
+ <key>filter_size</key>
+ <value>nfilts</value>
</param>
<param>
- <key>notebook</key>
- <value></value>
+ <key>init_phase</key>
+ <value>14</value>
</param>
<param>
<key>_coordinate</key>
- <value>(757, -1)</value>
+ <value>(346, 773)</value>
</param>
<param>
<key>_rotation</key>
@@ -875,42 +863,22 @@
</param>
</block>
<block>
- <key>gr_pfb_clock_sync_ccf</key>
+ <key>variable</key>
<param>
<key>id</key>
- <value>gr_pfb_clock_sync_ccf_0</value>
+ <value>rrctaps</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
- <key>sps</key>
- <value>spb</value>
- </param>
- <param>
- <key>alpha</key>
- <value>alpha</value>
- </param>
- <param>
- <key>beta</key>
- <value>beta</value>
- </param>
- <param>
- <key>taps</key>
- <value>rrctaps</value>
- </param>
- <param>
- <key>filter_size</key>
- <value>nfilts</value>
- </param>
- <param>
- <key>init_phase</key>
- <value>14</value>
+ <key>value</key>
+ <value>firdes.root_raised_cosine(nfilts,1.0,1.0/(spb*nfilts), .35, 11*spb*nfilts)</value>
</param>
<param>
<key>_coordinate</key>
- <value>(346, 773)</value>
+ <value>(110, 830)</value>
</param>
<param>
<key>_rotation</key>
@@ -921,7 +889,7 @@
<key>variable_slider</key>
<param>
<key>id</key>
- <value>interpratio</value>
+ <value>beta</value>
</param>
<param>
<key>_enabled</key>
@@ -929,19 +897,19 @@
</param>
<param>
<key>label</key>
- <value></value>
+ <value>Beta</value>
</param>
<param>
<key>value</key>
- <value>1</value>
+ <value>10e-3</value>
</param>
<param>
<key>min</key>
- <value>0</value>
+ <value>0.0</value>
</param>
<param>
<key>max</key>
- <value>2</value>
+ <value>0.1</value>
</param>
<param>
<key>num_steps</key>
@@ -965,30 +933,62 @@
</param>
<param>
<key>_coordinate</key>
- <value>(232, 921)</value>
+ <value>(871, 0)</value>
</param>
<param>
<key>_rotation</key>
- <value>180</value>
+ <value>0</value>
</param>
</block>
<block>
- <key>variable</key>
+ <key>variable_slider</key>
<param>
<key>id</key>
- <value>rrctaps</value>
+ <value>alpha</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
+ <key>label</key>
+ <value>Alpha</value>
+ </param>
+ <param>
<key>value</key>
- <value>firdes.root_raised_cosine(nfilts,1.0,1.0/(spb*nfilts), .35, 11*spb*nfilts)</value>
+ <value>2</value>
+ </param>
+ <param>
+ <key>min</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>max</key>
+ <value>10</value>
+ </param>
+ <param>
+ <key>num_steps</key>
+ <value>1000</value>
+ </param>
+ <param>
+ <key>style</key>
+ <value>wx.SL_HORIZONTAL</value>
+ </param>
+ <param>
+ <key>converver</key>
+ <value>float_converter</value>
+ </param>
+ <param>
+ <key>grid_pos</key>
+ <value></value>
+ </param>
+ <param>
+ <key>notebook</key>
+ <value></value>
</param>
<param>
<key>_coordinate</key>
- <value>(110, 830)</value>
+ <value>(757, -1)</value>
</param>
<param>
<key>_rotation</key>
@@ -999,7 +999,7 @@
<key>variable_slider</key>
<param>
<key>id</key>
- <value>beta</value>
+ <value>interpratio</value>
</param>
<param>
<key>_enabled</key>
@@ -1007,19 +1007,19 @@
</param>
<param>
<key>label</key>
- <value>Beta</value>
+ <value></value>
</param>
<param>
<key>value</key>
- <value>0</value>
+ <value>1.001</value>
</param>
<param>
<key>min</key>
- <value>0.0</value>
+ <value>0</value>
</param>
<param>
<key>max</key>
- <value>0.1</value>
+ <value>2</value>
</param>
<param>
<key>num_steps</key>
@@ -1043,11 +1043,11 @@
</param>
<param>
<key>_coordinate</key>
- <value>(871, 0)</value>
+ <value>(757, 133)</value>
</param>
<param>
<key>_rotation</key>
- <value>0</value>
+ <value>180</value>
</param>
</block>
<connection>