[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 05/05: digital: applying same fix of the co
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 05/05: digital: applying same fix of the complex M&M clock recovery block as the float vrsion. |
Date: |
Wed, 24 Sep 2014 22:04:58 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch maint
in repository gnuradio.
commit e98373d0d79b3f231248d939101ddfdc650c49d2
Author: Tom Rondeau <address@hidden>
Date: Wed Sep 24 17:32:41 2014 -0400
digital: applying same fix of the complex M&M clock recovery block as the
float vrsion.
---
gr-digital/lib/clock_recovery_mm_cc_impl.cc | 48 +++++++++++++----------
gr-digital/lib/clock_recovery_mm_cc_impl.h | 12 ++----
gr-digital/lib/clock_recovery_mm_ff_impl.cc | 20 +++++++---
gr-digital/lib/clock_recovery_mm_ff_impl.h | 8 ++--
gr-digital/python/digital/qa_clock_recovery_mm.py | 38 +++++++++---------
5 files changed, 67 insertions(+), 59 deletions(-)
diff --git a/gr-digital/lib/clock_recovery_mm_cc_impl.cc
b/gr-digital/lib/clock_recovery_mm_cc_impl.cc
index 124b85e..815589d 100644
--- a/gr-digital/lib/clock_recovery_mm_cc_impl.cc
+++ b/gr-digital/lib/clock_recovery_mm_cc_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005,2006,2010-2012 Free Software Foundation, Inc.
+ * Copyright 2005,2006,2010-2012,2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -36,13 +36,13 @@ namespace gr {
static const int FUDGE = 16;
- clock_recovery_mm_cc::sptr
+ clock_recovery_mm_cc::sptr
clock_recovery_mm_cc::make(float omega, float gain_omega,
float mu, float gain_mu,
float omega_relative_limit)
{
return gnuradio::get_initial_sptr
- (new clock_recovery_mm_cc_impl(omega, gain_omega,
+ (new clock_recovery_mm_cc_impl(omega, gain_omega,
mu, gain_mu,
omega_relative_limit));
}
@@ -51,10 +51,10 @@ namespace gr {
float mu, float
gain_mu,
float
omega_relative_limit)
: block("clock_recovery_mm_cc",
- io_signature::make(1, 1, sizeof(gr_complex)),
- io_signature::make2(1, 2, sizeof(gr_complex), sizeof(float))),
- d_mu(mu), d_omega(omega), d_gain_omega(gain_omega),
- d_omega_relative_limit(omega_relative_limit),
+ io_signature::make(1, 1, sizeof(gr_complex)),
+ io_signature::make2(1, 2, sizeof(gr_complex), sizeof(float))),
+ d_mu(mu), d_omega(omega), d_gain_omega(gain_omega),
+ d_omega_relative_limit(omega_relative_limit),
d_gain_mu(gain_mu), d_last_sample(0), d_interp(new
filter::mmse_fir_interpolator_cc()),
d_verbose(prefs::singleton()->get_bool("clock_recovery_mm_cc",
"verbose", false)),
d_p_2T(0), d_p_1T(0), d_p_0T(0), d_c_2T(0), d_c_1T(0), d_c_0T(0)
@@ -107,6 +107,14 @@ namespace gr {
return gr_complex(real,imag);
}
+ void
+ clock_recovery_mm_cc_impl::set_omega (float omega)
+ {
+ d_omega = omega;
+ d_omega_mid = omega;
+ d_omega_lim = d_omega_relative_limit * omega;
+ }
+
int
clock_recovery_mm_cc_impl::general_work(int noutput_items,
gr_vector_int &ninput_items,
@@ -118,7 +126,7 @@ namespace gr {
float *foptr = (float *)output_items[1];
bool write_foptr = output_items.size() >= 2;
-
+
int ii = 0; // input index
int oo = 0; // output index
int ni = ninput_items[0] - d_interp->ntaps() - FUDGE; // don't use more
input than this
@@ -139,25 +147,25 @@ namespace gr {
d_c_2T = d_c_1T;
d_c_1T = d_c_0T;
d_c_0T = slicer_0deg(d_p_0T);
-
+
x = (d_c_0T - d_c_2T) * conj(d_p_1T);
y = (d_p_0T - d_p_2T) * conj(d_c_1T);
u = y - x;
mm_val = u.real();
out[oo++] = d_p_0T;
-
+
// limit mm_val
mm_val = gr::branchless_clip(mm_val,4.0);
d_omega = d_omega + d_gain_omega * mm_val;
- d_omega = d_omega_mid + gr::branchless_clip(d_omega-d_omega_mid,
d_omega_relative_limit);
+ d_omega = d_omega_mid + gr::branchless_clip(d_omega-d_omega_mid,
d_omega_lim);
d_mu = d_mu + d_omega + d_gain_mu * mm_val;
ii += (int)floor(d_mu);
d_mu -= floor(d_mu);
-
+
// write the error signal to the second output
foptr[oo-1] = mm_val;
-
+
if(ii < 0) // clamp it. This should only happen with bogus input
ii = 0;
}
@@ -172,27 +180,27 @@ namespace gr {
d_c_2T = d_c_1T;
d_c_1T = d_c_0T;
d_c_0T = slicer_0deg(d_p_0T);
-
+
x = (d_c_0T - d_c_2T) * conj(d_p_1T);
y = (d_p_0T - d_p_2T) * conj(d_c_1T);
u = y - x;
mm_val = u.real();
out[oo++] = d_p_0T;
-
+
// limit mm_val
mm_val = gr::branchless_clip(mm_val,1.0);
-
+
d_omega = d_omega + d_gain_omega * mm_val;
- d_omega = d_omega_mid + gr::branchless_clip(d_omega-d_omega_mid,
d_omega_relative_limit);
-
+ d_omega = d_omega_mid + gr::branchless_clip(d_omega-d_omega_mid,
d_omega_lim);
+
d_mu = d_mu + d_omega + d_gain_mu * mm_val;
ii += (int)floor(d_mu);
d_mu -= floor(d_mu);
-
+
if(d_verbose) {
std::cout << d_omega << "\t" << d_mu << std::endl;
}
-
+
if(ii < 0) // clamp it. This should only happen with bogus input
ii = 0;
}
diff --git a/gr-digital/lib/clock_recovery_mm_cc_impl.h
b/gr-digital/lib/clock_recovery_mm_cc_impl.h
index a220835..4597360 100644
--- a/gr-digital/lib/clock_recovery_mm_cc_impl.h
+++ b/gr-digital/lib/clock_recovery_mm_cc_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2011,2012 Free Software Foundation, Inc.
+ * Copyright 2004,2011,2012,2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -52,21 +52,15 @@ namespace gr {
void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; }
void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; }
void set_mu (float mu) { d_mu = mu; }
- void set_omega (float omega) {
- d_omega = omega;
- d_min_omega = omega*(1.0 - d_omega_relative_limit);
- d_max_omega = omega*(1.0 + d_omega_relative_limit);
- d_omega_mid = 0.5*(d_min_omega+d_max_omega);
- }
+ void set_omega (float omega);
private:
float d_mu; // fractional sample position [0.0, 1.0]
float d_omega; // nominal frequency
float d_gain_omega; // gain for adjusting omega
- float d_min_omega; // minimum allowed omega
- float d_max_omega; // maximum allowed omeg
float d_omega_relative_limit; // used to compute min and max omega
float d_omega_mid; // average omega
+ float d_omega_lim; // actual omega clipping limit
float d_gain_mu; // gain for adjusting mu
gr_complex d_last_sample;
diff --git a/gr-digital/lib/clock_recovery_mm_ff_impl.cc
b/gr-digital/lib/clock_recovery_mm_ff_impl.cc
index 0f9bdbe..17377a2 100644
--- a/gr-digital/lib/clock_recovery_mm_ff_impl.cc
+++ b/gr-digital/lib/clock_recovery_mm_ff_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2010-2012 Free Software Foundation, Inc.
+ * Copyright 2004,2010-2012,2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -32,13 +32,13 @@
namespace gr {
namespace digital {
- clock_recovery_mm_ff::sptr
+ clock_recovery_mm_ff::sptr
clock_recovery_mm_ff::make(float omega, float gain_omega,
float mu, float gain_mu,
float omega_relative_limit)
{
return gnuradio::get_initial_sptr
- (new clock_recovery_mm_ff_impl(omega, gain_omega,
+ (new clock_recovery_mm_ff_impl(omega, gain_omega,
mu, gain_mu,
omega_relative_limit));
}
@@ -47,8 +47,8 @@ namespace gr {
float mu, float
gain_mu,
float
omega_relative_limit)
: block("clock_recovery_mm_ff",
- io_signature::make(1, 1, sizeof(float)),
- io_signature::make(1, 1, sizeof(float))),
+ io_signature::make(1, 1, sizeof(float)),
+ io_signature::make(1, 1, sizeof(float))),
d_mu(mu), d_gain_mu(gain_mu), d_gain_omega(gain_omega),
d_omega_relative_limit(omega_relative_limit),
d_last_sample(0), d_interp(new filter::mmse_fir_interpolator_ff())
@@ -83,6 +83,14 @@ namespace gr {
return x < 0 ? -1.0F : 1.0F;
}
+ void
+ clock_recovery_mm_ff_impl::set_omega (float omega)
+ {
+ d_omega = omega;
+ d_omega_mid = omega;
+ d_omega_lim = d_omega_mid * d_omega_relative_limit;
+ }
+
int
clock_recovery_mm_ff_impl::general_work(int noutput_items,
gr_vector_int &ninput_items,
@@ -104,7 +112,7 @@ namespace gr {
d_last_sample = out[oo];
d_omega = d_omega + d_gain_omega * mm_val;
- d_omega = d_omega_mid + gr::branchless_clip(d_omega-d_omega_mid,
d_omega_mid * d_omega_relative_limit);
+ d_omega = d_omega_mid + gr::branchless_clip(d_omega-d_omega_mid,
d_omega_lim);
d_mu = d_mu + d_omega + d_gain_mu * mm_val;
ii += (int)floor(d_mu);
diff --git a/gr-digital/lib/clock_recovery_mm_ff_impl.h
b/gr-digital/lib/clock_recovery_mm_ff_impl.h
index 85fb932..eee4403 100644
--- a/gr-digital/lib/clock_recovery_mm_ff_impl.h
+++ b/gr-digital/lib/clock_recovery_mm_ff_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2011,2012 Free Software Foundation, Inc.
+ * Copyright 2004,2011,2012,2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -52,10 +52,7 @@ namespace gr {
void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; }
void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; }
void set_mu (float mu) { d_mu = mu; }
- void set_omega (float omega){
- d_omega = omega;
- d_omega_mid = omega;
- }
+ void set_omega (float omega);
private:
float d_mu; // fractional sample position [0.0, 1.0]
@@ -64,6 +61,7 @@ namespace gr {
float d_gain_omega; // gain for adjusting omega
float d_omega_relative_limit; // used to compute min and max omega
float d_omega_mid; // average omega
+ float d_omega_lim; // actual omega clipping limit
float d_last_sample;
filter::mmse_fir_interpolator_ff *d_interp;
diff --git a/gr-digital/python/digital/qa_clock_recovery_mm.py
b/gr-digital/python/digital/qa_clock_recovery_mm.py
index 23c8a53..878ea25 100755
--- a/gr-digital/python/digital/qa_clock_recovery_mm.py
+++ b/gr-digital/python/digital/qa_clock_recovery_mm.py
@@ -1,24 +1,24 @@
#!/usr/bin/env python
#
# Copyright 2011-2013 Free Software Foundation, Inc.
-#
+#
# This file is part of GNU Radio
-#
+#
# GNU Radio is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
-#
+#
# GNU Radio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with GNU Radio; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
-#
+#
import random
import cmath
@@ -44,14 +44,14 @@ class test_clock_recovery_mm(gr_unittest.TestCase):
self.test = digital.clock_recovery_mm_cc(omega, gain_omega,
mu, gain_mu,
omega_rel_lim)
-
+
data = 100*[complex(1, 1),]
self.src = blocks.vector_source_c(data, False)
self.snk = blocks.vector_sink_c()
self.tb.connect(self.src, self.test, self.snk)
self.tb.run()
-
+
expected_result = 100*[complex(0.99972, 0.99972)] # doesn't quite get
to 1.0
dst_data = self.snk.data()
@@ -64,7 +64,7 @@ class test_clock_recovery_mm(gr_unittest.TestCase):
#print expected_result
#print dst_data
-
+
self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 5)
@@ -79,14 +79,14 @@ class test_clock_recovery_mm(gr_unittest.TestCase):
self.test = digital.clock_recovery_mm_ff(omega, gain_omega,
mu, gain_mu,
omega_rel_lim)
-
+
data = 100*[1,]
self.src = blocks.vector_source_f(data, False)
self.snk = blocks.vector_sink_f()
self.tb.connect(self.src, self.test, self.snk)
self.tb.run()
-
+
expected_result = 100*[0.9997, ] # doesn't quite get to 1.0
dst_data = self.snk.data()
@@ -99,7 +99,7 @@ class test_clock_recovery_mm(gr_unittest.TestCase):
#print expected_result
#print dst_data
-
+
self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 4)
@@ -108,20 +108,20 @@ class test_clock_recovery_mm(gr_unittest.TestCase):
omega = 2
gain_omega = 0.01
mu = 0.25
- gain_mu = 0.1
+ gain_mu = 0.01
omega_rel_lim = 0.0001
self.test = digital.clock_recovery_mm_cc(omega, gain_omega,
mu, gain_mu,
omega_rel_lim)
-
+
data = 1000*[complex(1, 1), complex(1, 1), complex(-1, -1),
complex(-1, -1)]
self.src = blocks.vector_source_c(data, False)
self.snk = blocks.vector_sink_c()
self.tb.connect(self.src, self.test, self.snk)
self.tb.run()
-
+
expected_result = 1000*[complex(-1.2, -1.2), complex(1.2, 1.2)]
dst_data = self.snk.data()
@@ -131,10 +131,10 @@ class test_clock_recovery_mm(gr_unittest.TestCase):
len_d = len(dst_data)
expected_result = expected_result[len_e - Ncmp:]
dst_data = dst_data[len_d - Ncmp:]
-
+
#print expected_result
#print dst_data
-
+
self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 1)
@@ -149,14 +149,14 @@ class test_clock_recovery_mm(gr_unittest.TestCase):
self.test = digital.clock_recovery_mm_ff(omega, gain_omega,
mu, gain_mu,
omega_rel_lim)
-
+
data = 1000*[1, 1, -1, -1]
self.src = blocks.vector_source_f(data, False)
self.snk = blocks.vector_sink_f()
self.tb.connect(self.src, self.test, self.snk)
self.tb.run()
-
+
expected_result = 1000*[-1.2, 1.2]
dst_data = self.snk.data()
@@ -169,7 +169,7 @@ class test_clock_recovery_mm(gr_unittest.TestCase):
#print expected_result
#print dst_data
-
+
self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 1)