diff options
author | Tom Rondeau | 2010-03-13 20:15:37 -0500 |
---|---|---|
committer | Tom Rondeau | 2010-03-13 20:15:37 -0500 |
commit | d7aa018010c828b2bedf0e3974c9d11d41088258 (patch) | |
tree | 360fd7ea680279a8512f69f0aab2cbf31b4c6ebb | |
parent | 52ae8be371d71f8c0817b2a88593ff6c378b9613 (diff) | |
parent | 1ba78b5f4c6bc2468b6fb798f41837a8ab2be89b (diff) | |
download | gnuradio-d7aa018010c828b2bedf0e3974c9d11d41088258.tar.gz gnuradio-d7aa018010c828b2bedf0e3974c9d11d41088258.tar.bz2 gnuradio-d7aa018010c828b2bedf0e3974c9d11d41088258.zip |
Merge branch 'digital' of git@gnuradio.org:trondeau into digital
Conflicts:
gnuradio-examples/python/digital/benchmark_qt_rx2.py
9 files changed, 258 insertions, 239 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<int> 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 diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py b/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py index 1d1bfc298..135b38e1f 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 81dccc2eb..f852a324c 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 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 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Fri Jan 29 18:10:00 2010</timestamp> + <timestamp>Sat Mar 6 17:17:12 2010</timestamp> <block> <key>options</key> <param> @@ -980,54 +980,50 @@ </param> </block> <block> - <key>variable_slider</key> + <key>root_raised_cosine_filter</key> <param> <key>id</key> - <value>alpha</value> + <value>root_raised_cosine_filter_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Freq Alpha</value> - </param> - <param> - <key>value</key> - <value>0</value> + <key>type</key> + <value>interp_fir_filter_ccf</value> </param> <param> - <key>min</key> - <value>0</value> + <key>decim</key> + <value>1</value> </param> <param> - <key>max</key> - <value>0.001</value> + <key>interp</key> + <value>spb_gen</value> </param> <param> - <key>num_steps</key> - <value>1000</value> + <key>gain</key> + <value>2*spb_gen</value> </param> <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> + <key>samp_rate</key> + <value>1.0</value> </param> <param> - <key>converver</key> - <value>float_converter</value> + <key>sym_rate</key> + <value>1./spb_gen</value> </param> <param> - <key>grid_pos</key> - <value></value> + <key>alpha</key> + <value>rolloff</value> </param> <param> - <key>notebook</key> - <value></value> + <key>ntaps</key> + <value>44</value> </param> <param> <key>_coordinate</key> - <value>(552, 4)</value> + <value>(978, 157)</value> </param> <param> <key>_rotation</key> @@ -1035,105 +1031,81 @@ </param> </block> <block> - <key>variable_slider</key> + <key>gr_fll_band_edge_cc</key> <param> <key>id</key> - <value>beta</value> + <value>gr_fll_band_edge_cc_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Freq Beta</value> - </param> - <param> - <key>value</key> - <value>0</value> - </param> - <param> - <key>min</key> - <value>0.0</value> - </param> - <param> - <key>max</key> - <value>0.0001</value> + <key>type</key> + <value>cc</value> </param> <param> - <key>num_steps</key> - <value>1000</value> + <key>samps_per_sym</key> + <value>spb_gen</value> </param> <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> + <key>rolloff</key> + <value>rolloff</value> </param> <param> - <key>converver</key> - <value>float_converter</value> + <key>filter_size</key> + <value>44</value> </param> <param> - <key>grid_pos</key> - <value></value> + <key>alpha</key> + <value>alpha</value> </param> <param> - <key>notebook</key> - <value></value> + <key>beta</key> + <value>beta</value> </param> <param> <key>_coordinate</key> - <value>(668, 5)</value> + <value>(874, 664)</value> </param> <param> <key>_rotation</key> - <value>180</value> + <value>0</value> </param> </block> <block> - <key>root_raised_cosine_filter</key> + <key>gr_channel_model</key> <param> <key>id</key> - <value>root_raised_cosine_filter_0</value> + <value>gr_channel_model_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>interp_fir_filter_ccf</value> - </param> - <param> - <key>decim</key> - <value>1</value> - </param> - <param> - <key>interp</key> - <value>spb_gen</value> + <key>noise_voltage</key> + <value>noise_amp</value> </param> <param> - <key>gain</key> - <value>2*spb_gen</value> + <key>freq_offset</key> + <value>freq_offset</value> </param> <param> - <key>samp_rate</key> + <key>epsilon</key> <value>1.0</value> </param> <param> - <key>sym_rate</key> - <value>1./spb_gen</value> - </param> - <param> - <key>alpha</key> - <value>rolloff</value> + <key>taps</key> + <value>1.0</value> </param> <param> - <key>ntaps</key> - <value>44</value> + <key>seed</key> + <value>42</value> </param> <param> <key>_coordinate</key> - <value>(978, 157)</value> + <value>(618, 376)</value> </param> <param> <key>_rotation</key> @@ -1141,81 +1113,109 @@ </param> </block> <block> - <key>gr_fll_band_edge_cc</key> + <key>variable_slider</key> <param> <key>id</key> - <value>gr_fll_band_edge_cc_0</value> + <value>beta</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>cc</value> + <key>label</key> + <value>Freq Beta</value> </param> <param> - <key>samps_per_sym</key> - <value>spb_gen</value> + <key>value</key> + <value>0</value> </param> <param> - <key>rolloff</key> - <value>rolloff</value> + <key>min</key> + <value>0.0</value> </param> <param> - <key>filter_size</key> - <value>44</value> + <key>max</key> + <value>0.01</value> </param> <param> - <key>alpha</key> - <value>alpha</value> + <key>num_steps</key> + <value>1000</value> </param> <param> - <key>beta</key> - <value>beta</value> + <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>(874, 664)</value> + <value>(668, 5)</value> </param> <param> <key>_rotation</key> - <value>0</value> + <value>180</value> </param> </block> <block> - <key>gr_channel_model</key> + <key>variable_slider</key> <param> <key>id</key> - <value>gr_channel_model_0</value> + <value>alpha</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>noise_voltage</key> - <value>noise_amp</value> + <key>label</key> + <value>Freq Alpha</value> </param> <param> - <key>freq_offset</key> - <value>freq_offset</value> + <key>value</key> + <value>0</value> </param> <param> - <key>epsilon</key> - <value>1.0</value> + <key>min</key> + <value>0</value> </param> <param> - <key>taps</key> - <value>1.0</value> + <key>max</key> + <value>0.1</value> </param> <param> - <key>seed</key> - <value>42</value> + <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>(618, 376)</value> + <value>(552, 4)</value> </param> <param> <key>_rotation</key> 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 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Mon Feb 1 18:58:32 2010</timestamp> + <timestamp>Sat Mar 6 17:17:22 2010</timestamp> <block> <key>options</key> <param> @@ -713,116 +713,6 @@ <key>variable_slider</key> <param> <key>id</key> - <value>freq_beta</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>Freq Beta</value> - </param> - <param> - <key>value</key> - <value>0</value> - </param> - <param> - <key>min</key> - <value>0.0</value> - </param> - <param> - <key>max</key> - <value>0.0001</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>(836, 9)</value> - </param> - <param> - <key>_rotation</key> - <value>180</value> - </param> - </block> - <block> - <key>variable_slider</key> - <param> - <key>id</key> - <value>freq_alpha</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>Freq Alpha</value> - </param> - <param> - <key>value</key> - <value>0</value> - </param> - <param> - <key>min</key> - <value>0</value> - </param> - <param> - <key>max</key> - <value>0.001</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>(734, 10)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_slider</key> - <param> - <key>id</key> <value>phase_alpha</value> </param> <param> @@ -1621,6 +1511,116 @@ <value>0</value> </param> </block> + <block> + <key>variable_slider</key> + <param> + <key>id</key> + <value>freq_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Freq Alpha</value> + </param> + <param> + <key>value</key> + <value>0</value> + </param> + <param> + <key>min</key> + <value>0</value> + </param> + <param> + <key>max</key> + <value>0.1</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>(734, 10)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_slider</key> + <param> + <key>id</key> + <value>freq_beta</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Freq Beta</value> + </param> + <param> + <key>value</key> + <value>0</value> + </param> + <param> + <key>min</key> + <value>0.0</value> + </param> + <param> + <key>max</key> + <value>0.01</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>(836, 9)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> <connection> <source_block_id>random_source_x_0</source_block_id> <sink_block_id>gr_uchar_to_float_0</sink_block_id> 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) diff --git a/gnuradio-examples/python/digital/benchmark_qt_rx2.py b/gnuradio-examples/python/digital/benchmark_qt_rx2.py index 3285d8e4a..4de15e480 100755 --- a/gnuradio-examples/python/digital/benchmark_qt_rx2.py +++ b/gnuradio-examples/python/digital/benchmark_qt_rx2.py @@ -268,7 +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, + options.samples_per_symbol, options.decim, \ adc_rate, self.u.get_decim_rates()) self.u.set_decim(self._decim) |