From a5ee5af754abd66a7d7751868e0dcea8c8299264 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 6 Mar 2010 17:11:58 -0500 Subject: Improved performance of FLL using a more robust error term. --- .../src/lib/general/gr_fll_band_edge_cc.cc | 27 ++++++++++++---------- .../src/lib/general/gr_fll_band_edge_cc.h | 8 +++++-- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.cc b/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.cc index 030e45ddf..7f2c468b7 100644 --- a/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.cc +++ b/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.cc @@ -53,7 +53,7 @@ gr_fll_band_edge_cc_sptr gr_make_fll_band_edge_cc (float samps_per_sym, float ro } -static int ios[] = {sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(float)}; +static int ios[] = {sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(gr_complex)}; static std::vector iosig(ios, ios+sizeof(ios)/sizeof(int)); gr_fll_band_edge_cc::gr_fll_band_edge_cc (float samps_per_sym, float rolloff, int filter_size, float alpha, float beta) @@ -83,10 +83,11 @@ gr_fll_band_edge_cc::~gr_fll_band_edge_cc () void gr_fll_band_edge_cc::set_alpha(float alpha) { - float eta = sqrt(2.0)/2.0; - float theta = alpha; - d_alpha = (4*eta*theta) / (1.0 + 2.0*eta*theta + theta*theta); - d_beta = (4*theta*theta) / (1.0 + 2.0*eta*theta + theta*theta); + //float eta = sqrt(2.0)/2.0; + //float theta = alpha; + //d_alpha = (4*eta*theta) / (1.0 + 2.0*eta*theta + theta*theta); + //d_beta = (4*theta*theta) / (1.0 + 2.0*eta*theta + theta*theta); + d_alpha = alpha; } void @@ -160,11 +161,12 @@ gr_fll_band_edge_cc::work (int noutput_items, const gr_complex *in = (const gr_complex *) input_items[0]; gr_complex *out = (gr_complex *) output_items[0]; - float *frq, *phs, *err; + float *frq, *phs; + gr_complex *err; if(output_items.size() > 2) { frq = (float *) output_items[1]; phs = (float *) output_items[2]; - err = (float *) output_items[3]; + err = (gr_complex *) output_items[3]; } if (d_updated) { @@ -174,16 +176,17 @@ gr_fll_band_edge_cc::work (int noutput_items, int i; gr_complex nco_out; - float out_upper, out_lower; + gr_complex out_upper, out_lower; float error; + float avg_k = 0.1; for(i = 0; i < noutput_items; i++) { nco_out = gr_expj(d_phase); out[i] = in[i] * nco_out; - out_upper = norm(d_filter_upper->filter(&out[i])); - out_lower = norm(d_filter_lower->filter(&out[i])); - error = out_lower - out_upper; - d_error = 0.01*error + 0.99*d_error; // average error + out_upper = (d_filter_upper->filter(&out[i])); + out_lower = (d_filter_lower->filter(&out[i])); + error = -real((out_upper + out_lower) * conj(out_upper - out_lower)); + d_error = avg_k*error + avg_k*d_error; // average error d_freq = d_freq + d_beta * d_error; d_phase = d_phase + d_freq + d_alpha * d_error; diff --git a/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.h b/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.h index 09baf7fde..178e18f3e 100644 --- a/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.h +++ b/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.h @@ -45,8 +45,12 @@ class gri_fft_complex; * (e.g., rolloff factor) of the modulated signal. The placement in frequency of the band-edges * is determined by the oversampling ratio (number of samples per symbol) and the excess bandwidth. * The size of the filters should be fairly large so as to average over a number of symbols. - * The FLL works by calculating the power in both the upper and lower bands and comparing them. The - * difference in power between the filters is proportional to the frequency offset. + * + * The FLL works by filtering the upper and lower band edges into x_u(t) and x_l(t), respectively. + * These are combined to form cc(t) = x_u(t) + x_l(t) and ss(t) = x_u(t) - x_l(t). Combining + * these to form the signal e(t) = Re{cc(t) \times ss(t)^*} (where ^* is the complex conjugate) + * provides an error signal at the DC term that is directly proportional to the carrier frequency. + * We then make a second-order loop using the error signal that is the running average of e(t). * * In theory, the band-edge filter is the derivative of the matched filter in frequency, * (H_be(f) = \frac{H(f)}{df}. In practice, this comes down to a quarter sine wave at the point -- cgit From 5b0fbc73d7e35b617df517a5182c00731f4c66d7 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 6 Mar 2010 17:12:46 -0500 Subject: Using better defaults for new FLL implementation. --- gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py | 14 +++++++------- gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py b/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py index a5c5fa164..7830874d1 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py @@ -38,7 +38,7 @@ _def_gray_code = True _def_verbose = False _def_log = False -_def_freq_alpha = 4e-3 +_def_freq_alpha = 0.010 _def_costas_alpha = 0.1 _def_timing_alpha = 0.100 _def_timing_beta = 0.010 @@ -226,7 +226,7 @@ class dbpsk2_demod(gr.hier_block2): self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw self._freq_alpha = freq_alpha - self._freq_beta = 0.25*self._freq_alpha**2 + self._freq_beta = 0.10*self._freq_alpha self._costas_alpha = costas_alpha self._timing_alpha = timing_alpha self._timing_beta = _def_timing_beta @@ -308,11 +308,11 @@ class dbpsk2_demod(gr.hier_block2): print "bits per symbol: %d" % self.bits_per_symbol() print "Gray code: %s" % self._gray_code print "RRC roll-off factor: %.2f" % self._excess_bw - print "FLL gain: %.2f" % self._freq_alpha - print "Costas Loop alpha: %.2f" % self._costas_alpha - print "Costas Loop beta: %.2f" % self._costas_beta - print "Timing alpha gain: %.2f" % self._timing_alpha - print "Timing beta gain: %.2f" % self._timing_beta + print "FLL gain: %.2e" % self._freq_alpha + print "Costas Loop alpha: %.2e" % self._costas_alpha + print "Costas Loop beta: %.2e" % self._costas_beta + print "Timing alpha gain: %.2e" % self._timing_alpha + print "Timing beta gain: %.2e" % self._timing_beta print "Timing max dev: %.2f" % self._timing_max_dev def _setup_logging(self): diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py b/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py index 96cf0144f..b09978fb9 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py @@ -38,7 +38,7 @@ _def_gray_code = True _def_verbose = False _def_log = False -_def_freq_alpha = 4e-3 +_def_freq_alpha = 0.010 _def_costas_alpha = 0.01 _def_timing_alpha = 0.100 _def_timing_beta = 0.010 -- cgit From ff876f7cc310bbdf1c5d05f85daba0afdb33561a Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 6 Mar 2010 17:15:33 -0500 Subject: Fixing how new pick_bitrate is used. --- gnuradio-examples/python/digital/benchmark_qt_rx2.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gnuradio-examples/python/digital/benchmark_qt_rx2.py b/gnuradio-examples/python/digital/benchmark_qt_rx2.py index d6338f853..4de15e480 100755 --- a/gnuradio-examples/python/digital/benchmark_qt_rx2.py +++ b/gnuradio-examples/python/digital/benchmark_qt_rx2.py @@ -268,6 +268,7 @@ class my_top_block(gr.top_block): (self._bitrate, self._samples_per_symbol, self._decim) = \ pick_rx_bitrate(options.bitrate, self._demod_class.bits_per_symbol(), \ + options.samples_per_symbol, options.decim, \ adc_rate, self.u.get_decim_rates()) self.u.set_decim(self._decim) -- cgit From ebd5449ebf8c08f78cada720eb47769bdfaa4bde Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 6 Mar 2010 17:16:19 -0500 Subject: Small fixes for loopback with new code. --- gnuradio-examples/python/digital/benchmark_loopback.py | 5 +++++ gnuradio-examples/python/digital/benchmark_qt_loopback2.py | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/gnuradio-examples/python/digital/benchmark_loopback.py b/gnuradio-examples/python/digital/benchmark_loopback.py index 4cc4a7bee..47e4f2028 100755 --- a/gnuradio-examples/python/digital/benchmark_loopback.py +++ b/gnuradio-examples/python/digital/benchmark_loopback.py @@ -44,6 +44,11 @@ class my_top_block(gr.top_block): noise_power = power_in_signal/SNR noise_voltage = math.sqrt(noise_power) + # With new interface, sps does not get set by default, but + # in the loopback, we don't recalculate it; so just force it here + if(options.samples_per_symbol == None): + options.samples_per_symbol = 2 + self.txpath = transmit_path(mod_class, options) self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate) self.rxpath = receive_path(demod_class, rx_callback, options) diff --git a/gnuradio-examples/python/digital/benchmark_qt_loopback2.py b/gnuradio-examples/python/digital/benchmark_qt_loopback2.py index 1cb95198e..1f236fd7f 100755 --- a/gnuradio-examples/python/digital/benchmark_qt_loopback2.py +++ b/gnuradio-examples/python/digital/benchmark_qt_loopback2.py @@ -223,6 +223,11 @@ class my_top_block(gr.top_block): self._noise_voltage = self.get_noise_voltage(self._snr_dB) + # With new interface, sps does not get set by default, but + # in the loopback, we don't recalculate it; so just force it here + if(options.samples_per_symbol == None): + options.samples_per_symbol = 2 + self.txpath = transmit_path(mod_class, options) self.throttle = gr.throttle(gr.sizeof_gr_complex, self.sample_rate()) self.rxpath = receive_path(demod_class, rx_callback, options) @@ -269,6 +274,7 @@ class my_top_block(gr.top_block): self.phase_recov = self.rxpath.packet_receiver._demodulator.phase_recov self.time_recov = self.rxpath.packet_receiver._demodulator.time_recov self.freq_recov.set_alpha(self._gain_freq) + self.freq_recov.set_beta(self._gain_freq/10.0) self.phase_recov.set_alpha(self._gain_phase) self.phase_recov.set_beta(0.25*self._gain_phase*self._gain_phase) self.time_recov.set_alpha(self._gain_clock) @@ -367,6 +373,7 @@ class my_top_block(gr.top_block): self._gain_freq = gain_freq #self._gain_freq_beta = .25 * self._gain_freq * self._gain_freq self.rxpath.packet_receiver._demodulator.freq_recov.set_alpha(self._gain_freq) + self.rxpath.packet_receiver._demodulator.freq_recov.set_beta(self._gain_freq/10.0) #self.rxpath.packet_receiver._demodulator.freq_recov.set_beta(self._gain_fre_beta) -- cgit From 1ba78b5f4c6bc2468b6fb798f41837a8ab2be89b Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 6 Mar 2010 17:17:29 -0500 Subject: Changing FLL parameter range for use with new code. --- gnuradio-examples/grc/demod/digital_freq_lock.grc | 210 ++++++++++---------- gnuradio-examples/grc/demod/pam_sync.grc | 222 +++++++++++----------- 2 files changed, 216 insertions(+), 216 deletions(-) diff --git a/gnuradio-examples/grc/demod/digital_freq_lock.grc b/gnuradio-examples/grc/demod/digital_freq_lock.grc index 37ee8123e..36037febb 100644 --- a/gnuradio-examples/grc/demod/digital_freq_lock.grc +++ b/gnuradio-examples/grc/demod/digital_freq_lock.grc @@ -1,6 +1,6 @@ - Fri Jan 29 18:10:00 2010 + Sat Mar 6 17:17:12 2010 options @@ -980,54 +980,50 @@ - variable_slider + root_raised_cosine_filter id - alpha + root_raised_cosine_filter_0 _enabled True - label - Freq Alpha - - - value - 0 + type + interp_fir_filter_ccf - min - 0 + decim + 1 - max - 0.001 + interp + spb_gen - num_steps - 1000 + gain + 2*spb_gen - style - wx.SL_HORIZONTAL + samp_rate + 1.0 - converver - float_converter + sym_rate + 1./spb_gen - grid_pos - + alpha + rolloff - notebook - + ntaps + 44 _coordinate - (552, 4) + (978, 157) _rotation @@ -1035,105 +1031,81 @@ - variable_slider + gr_fll_band_edge_cc id - beta + gr_fll_band_edge_cc_0 _enabled True - label - Freq Beta - - - value - 0 - - - min - 0.0 - - - max - 0.0001 + type + cc - num_steps - 1000 + samps_per_sym + spb_gen - style - wx.SL_HORIZONTAL + rolloff + rolloff - converver - float_converter + filter_size + 44 - grid_pos - + alpha + alpha - notebook - + beta + beta _coordinate - (668, 5) + (874, 664) _rotation - 180 + 0 - root_raised_cosine_filter + gr_channel_model id - root_raised_cosine_filter_0 + gr_channel_model_0 _enabled True - type - interp_fir_filter_ccf - - - decim - 1 - - - interp - spb_gen + noise_voltage + noise_amp - gain - 2*spb_gen + freq_offset + freq_offset - samp_rate + epsilon 1.0 - sym_rate - 1./spb_gen - - - alpha - rolloff + taps + 1.0 - ntaps - 44 + seed + 42 _coordinate - (978, 157) + (618, 376) _rotation @@ -1141,81 +1113,109 @@ - gr_fll_band_edge_cc + variable_slider id - gr_fll_band_edge_cc_0 + beta _enabled True - type - cc + label + Freq Beta - samps_per_sym - spb_gen + value + 0 - rolloff - rolloff + min + 0.0 - filter_size - 44 + max + 0.01 - alpha - alpha + num_steps + 1000 - beta - beta + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + _coordinate - (874, 664) + (668, 5) _rotation - 0 + 180 - gr_channel_model + variable_slider id - gr_channel_model_0 + alpha _enabled True - noise_voltage - noise_amp + label + Freq Alpha - freq_offset - freq_offset + value + 0 - epsilon - 1.0 + min + 0 - taps - 1.0 + max + 0.1 - seed - 42 + num_steps + 1000 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + _coordinate - (618, 376) + (552, 4) _rotation diff --git a/gnuradio-examples/grc/demod/pam_sync.grc b/gnuradio-examples/grc/demod/pam_sync.grc index 80a7aef0c..8571995a5 100644 --- a/gnuradio-examples/grc/demod/pam_sync.grc +++ b/gnuradio-examples/grc/demod/pam_sync.grc @@ -1,6 +1,6 @@ - Mon Feb 1 18:58:32 2010 + Sat Mar 6 17:17:22 2010 options @@ -709,116 +709,6 @@ 0 - - variable_slider - - id - freq_beta - - - _enabled - True - - - label - Freq Beta - - - value - 0 - - - min - 0.0 - - - max - 0.0001 - - - num_steps - 1000 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (836, 9) - - - _rotation - 180 - - - - variable_slider - - id - freq_alpha - - - _enabled - True - - - label - Freq Alpha - - - value - 0 - - - min - 0 - - - max - 0.001 - - - num_steps - 1000 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (734, 10) - - - _rotation - 0 - - variable_slider @@ -1621,6 +1511,116 @@ 0 + + variable_slider + + id + freq_alpha + + + _enabled + True + + + label + Freq Alpha + + + value + 0 + + + min + 0 + + + max + 0.1 + + + num_steps + 1000 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (734, 10) + + + _rotation + 0 + + + + variable_slider + + id + freq_beta + + + _enabled + True + + + label + Freq Beta + + + value + 0 + + + min + 0.0 + + + max + 0.01 + + + num_steps + 1000 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (836, 9) + + + _rotation + 180 + + random_source_x_0 gr_uchar_to_float_0 -- cgit