summaryrefslogtreecommitdiff
path: root/gnuradio-core/src
diff options
context:
space:
mode:
authorTom2009-10-06 10:23:47 -0700
committerTom2009-10-06 10:23:47 -0700
commit28bcffdea069764716a769eb3e344c748bc705f6 (patch)
treeb9dc5490d94494d050fc92b52afe475ed83ada6c /gnuradio-core/src
parent271412d1781d875e31e7c851752ffacfedb9c325 (diff)
downloadgnuradio-28bcffdea069764716a769eb3e344c748bc705f6.tar.gz
gnuradio-28bcffdea069764716a769eb3e344c748bc705f6.tar.bz2
gnuradio-28bcffdea069764716a769eb3e344c748bc705f6.zip
wip on clock sync block; exposing set gain function
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc36
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h9
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i1
3 files changed, 27 insertions, 19 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 91cbf74c6..5577e42c8 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
@@ -60,7 +60,7 @@ gr_pfb_clock_sync_ccf::gr_pfb_clock_sync_ccf (float sps, float gain,
// set it here to the fractional difference based on the initial phaes
// assert(init_phase <= 2*M_PI);
float x = init_phase / (2*M_PI); //normalize initial phase
- d_acc = x*(d_nfilters-1);
+ d_acc = 0.5; //x*(d_nfilters-1);
d_last_filter = (int)floor(d_acc);
d_acc = fmodf(d_acc, 1);
d_start_count = 0;
@@ -133,12 +133,22 @@ void
gr_pfb_clock_sync_ccf::create_diff_taps(const std::vector<float> &newtaps,
std::vector<float> &difftaps)
{
+ float maxtap = -1e12;
difftaps.clear();
difftaps.push_back(0); //newtaps[0]);
for(unsigned int i = 1; i < newtaps.size()-1; i++) {
- difftaps.push_back(newtaps[i+1] - newtaps[i-1]);
+ float tap = newtaps[i+1] - newtaps[i-1];
+ if(tap > maxtap) {
+ maxtap = tap;
+ }
+ //maxtap += tap;
+ difftaps.push_back(tap);
}
difftaps.push_back(0);//-newtaps[newtaps.size()-1]);
+
+ for(unsigned int i = 0; i < difftaps.size(); i++) {
+ difftaps[i] /= 1;//maxtap;
+ }
}
void
@@ -219,24 +229,18 @@ gr_pfb_clock_sync_ccf::general_work (int noutput_items,
err[i] = error;
d_acc += d_alpha*error;
- gr_branchless_clip(d_acc, 1);
-
- int newfilter;
- newfilter = (int)((float)d_last_filter + d_acc);
- if(newfilter != (int)d_last_filter)
- d_acc = 0.5;
-
- if(newfilter >= (int)d_nfilters) {
- d_last_filter = newfilter - d_nfilters;
+ if(d_acc >= (int)d_nfilters) {
+ d_acc -= d_nfilters;
count++;
}
- else if(newfilter < 0) {
- d_last_filter = d_nfilters + newfilter;
+ else if(d_acc < 0) {
+ d_acc += d_nfilters-1;
count--;
}
- else {
- d_last_filter = newfilter;
- }
+
+ d_last_filter = (int)floor(d_acc);
+ printf("error: %e d_acc: %e filter: %d\n",
+ error, d_acc, d_last_filter);
i++;
count += d_sps;
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h
index 1a04e55c7..d99bd6fe7 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h
+++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h
@@ -29,9 +29,9 @@
class gr_pfb_clock_sync_ccf;
typedef boost::shared_ptr<gr_pfb_clock_sync_ccf> gr_pfb_clock_sync_ccf_sptr;
gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
- const std::vector<float> &taps,
- unsigned int filter_size=32,
- float init_phase=0);
+ const std::vector<float> &taps,
+ unsigned int filter_size=32,
+ float init_phase=0);
class gr_fir_ccf;
@@ -96,6 +96,9 @@ public:
*/
void print_taps();
void print_diff_taps();
+
+ void set_gain(float gain)
+ { d_alpha = gain; }
int general_work (int noutput_items,
gr_vector_int &ninput_items,
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i
index 729d4a1aa..9defbc7cd 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i
+++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i
@@ -46,4 +46,5 @@ class gr_pfb_clock_sync_ccf : public gr_block
std::vector<float> diff_channel_taps(int channel);
void print_taps();
void print_diff_taps();
+ void set_gain(float gain);
};