diff options
Diffstat (limited to 'gnuradio-core/src')
6 files changed, 85 insertions, 42 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); }; diff --git a/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc b/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc index 49bbb8d36..89ea4a232 100644 --- a/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc +++ b/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc @@ -35,7 +35,7 @@ #define M_TWOPI (2*M_PI) #define VERBOSE_MM 0 // Used for debugging symbol timing loop -#define VERBOSE_COSTAS 0 // Used for debugging phase and frequency tracking +#define VERBOSE_COSTAS 1 // Used for debugging phase and frequency tracking // Public constructor @@ -265,8 +265,6 @@ gr_mpsk_receiver_cc::phase_error_tracking(gr_complex sample) // Make phase and frequency corrections based on sampled value phase_error = (*this.*d_phase_error_detector)(sample); - - phase_error = gr_branchless_clip(phase_error, 1.0); d_freq += d_beta*phase_error; // adjust frequency based on error d_phase += d_freq + d_alpha*phase_error; // adjust phase based on error diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk.py b/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk.py index 3147bfa2a..ac2e9323f 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk.py @@ -255,16 +255,34 @@ class dbpsk_demod(gr.hier_block2): self._mm_omega = self._samples_per_symbol self._mm_gain_omega = .25 * self._mm_gain_mu * self._mm_gain_mu self._costas_beta = 0.25 * self._costas_alpha * self._costas_alpha - fmin = -0.1 - fmax = 0.1 + fmin = -0.25 + fmax = 0.25 - self.receiver=gr.mpsk_receiver_cc(arity, 0, - self._costas_alpha, self._costas_beta, - fmin, fmax, - self._mm_mu, self._mm_gain_mu, - self._mm_omega, self._mm_gain_omega, - self._mm_omega_relative_limit) - + #self.receiver=gr.mpsk_receiver_cc(arity, 0, + # self._costas_alpha, self._costas_beta, + # fmin, fmax, + # self._mm_mu, self._mm_gain_mu, + # self._mm_omega, self._mm_gain_omega, + # self._mm_omega_relative_limit) + + self.clock_recov = gr.costas_loop_cc(self._costas_alpha, + self._costas_beta, + fmax, fmin, arity) + if 0: + self.time_recov = gr.clock_recovery_mm_cc(self._mm_omega, + self._mm_gain_omega, + self._mm_mu, + self._mm_gain_mu, + self._mm_omega_relative_limit) + else: + nfilts = 8 + ntaps = nfilts*ntaps + taps = gr.firdes.root_raised_cosine( + nfilts, 1.0, 0.25/nfilts, self._excess_bw, ntaps) + self.time_recov = gr.pfb_clock_sync_ccf(self._mm_omega, + self._mm_gain_mu, + taps, nfilts) + # Do differential decoding based on phase change of symbols self.diffdec = gr.diff_phasor_cc() @@ -288,7 +306,9 @@ class dbpsk_demod(gr.hier_block2): self._setup_logging() # Connect and Initialize base class - self.connect(self, self.pre_scaler, self.agc, self.rrc_filter, self.receiver, + self.connect(self, self.pre_scaler, self.agc, #self.rrc_filter, self.receiver, + #self.clock_recov, + self.time_recov, self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self) def samples_per_symbol(self): diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk.py b/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk.py index 8c15d2173..34e6581bf 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk.py @@ -255,16 +255,32 @@ class dqpsk_demod(gr.hier_block2): self._mm_omega = self._samples_per_symbol self._mm_gain_omega = .25 * self._mm_gain_mu * self._mm_gain_mu self._costas_beta = 0.25 * self._costas_alpha * self._costas_alpha - fmin = -0.025 - fmax = 0.025 + fmin = -0.25 + fmax = 0.25 + + #self.receiver=gr.mpsk_receiver_cc(arity, pi/4.0, + # self._costas_alpha, self._costas_beta, + # fmin, fmax, + # self._mm_mu, self._mm_gain_mu, + # self._mm_omega, self._mm_gain_omega, + # self._mm_omega_relative_limit) + self.clock_recov = gr.costas_loop_cc(self._costas_alpha, + self._costas_beta, + fmax, fmin, arity) + if 0: + self.time_recov = gr.clock_recovery_mm_cc(self._mm_omega, + self._mm_gain_omega, + self._mm_mu, + self._mm_gain_mu, + self._mm_omega_relative_limit) + else: + ntaps = 32*ntaps + taps = gr.firdes.root_raised_cosine( + 32, 1.0, 0.25/32.0, self._excess_bw, ntaps) + self.time_recov = gr.pfb_clock_sync_ccf(self._mm_omega, + self._mm_gain_mu, + taps) - self.receiver=gr.mpsk_receiver_cc(arity, pi/4.0, - self._costas_alpha, self._costas_beta, - fmin, fmax, - self._mm_mu, self._mm_gain_mu, - self._mm_omega, self._mm_gain_omega, - self._mm_omega_relative_limit) - # Perform Differential decoding on the constellation self.diffdec = gr.diff_phasor_cc() @@ -288,7 +304,8 @@ class dqpsk_demod(gr.hier_block2): self._setup_logging() # Connect & Initialize base class - self.connect(self, self.pre_scaler, self.agc, self.rrc_filter, self.receiver, + self.connect(self, self.pre_scaler, self.agc, #self.rrc_filter, #self.receiver, + self.clock_recov, self.time_recov, self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self) def samples_per_symbol(self): |