From 5eb35d758f7bf08b821479d11a8784689eef239c Mon Sep 17 00:00:00 2001 From: jcorgan Date: Wed, 31 Dec 2008 22:19:48 +0000 Subject: For USRP2, implement auto scaling of TX pipeline such that [-1.0 1.0] input to usrp2.sink_32fc results in full-scale DAC outputs, regardless of interpolation rate. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10182 221aa14e-8319-0410-a670-987f0aec2ac5 --- gr-usrp2/src/usrp2.i | 13 ++++++++++++- gr-usrp2/src/usrp2_sink_base.cc | 6 ++++++ gr-usrp2/src/usrp2_sink_base.h | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'gr-usrp2') diff --git a/gr-usrp2/src/usrp2.i b/gr-usrp2/src/usrp2.i index e85de2082..28944e676 100644 --- a/gr-usrp2/src/usrp2.i +++ b/gr-usrp2/src/usrp2.i @@ -137,6 +137,8 @@ public: bool set_interp(int interp_factor); bool set_scale_iq(int scale_i, int scale_q); int interp(); + %rename(_real_default_tx_scale_iq) default_scale_iq; + void default_scale_iq(int interp, int *scale_i, int *scale_q); %rename(_real_dac_rate) dac_rate; bool dac_rate(long *rate); double gain_min(); @@ -257,7 +259,7 @@ def __freq_range(self): self.freq_max()] def __daughterboard_id(self): - dbid = make_int_ptr(); + dbid = make_int_ptr() r = self._real_daughterboard_id(dbid) if r: result = deref_int_ptr(dbid) @@ -266,6 +268,12 @@ def __daughterboard_id(self): free_int_ptr(dbid) return result +def __default_tx_scale_iq(self, interp): + scale_i = make_int_ptr() + scale_q = make_int_ptr() + self._real_default_tx_scale_iq(interp, scale_i, scale_q) + return (deref_int_ptr(scale_i), deref_int_ptr(scale_q)) + usrp2_source_32fc_sptr.set_center_freq = __set_center_freq usrp2_source_16sc_sptr.set_center_freq = __set_center_freq usrp2_sink_32fc_sptr.set_center_freq = __set_center_freq @@ -296,4 +304,7 @@ usrp2_source_16sc_sptr.daughterboard_id = __daughterboard_id usrp2_sink_32fc_sptr.daughterboard_id = __daughterboard_id usrp2_sink_16sc_sptr.daughterboard_id = __daughterboard_id +usrp2_sink_32fc_sptr.default_scale_iq = __default_tx_scale_iq +usrp2_sink_16sc_sptr.default_scale_iq = __default_tx_scale_iq + %} diff --git a/gr-usrp2/src/usrp2_sink_base.cc b/gr-usrp2/src/usrp2_sink_base.cc index c04914eed..579aaaa4c 100644 --- a/gr-usrp2/src/usrp2_sink_base.cc +++ b/gr-usrp2/src/usrp2_sink_base.cc @@ -64,6 +64,12 @@ usrp2_sink_base::set_interp(int interp_factor) return d_u2->set_tx_interp(interp_factor); } +void +usrp2_sink_base::default_scale_iq(int interp_factor, int *scale_i, int *scale_q) +{ + return d_u2->default_tx_scale_iq(interp_factor, scale_i, scale_q); +} + bool usrp2_sink_base::set_scale_iq(int scale_i, int scale_q) { diff --git a/gr-usrp2/src/usrp2_sink_base.h b/gr-usrp2/src/usrp2_sink_base.h index 0c4fe72c6..fad965623 100644 --- a/gr-usrp2/src/usrp2_sink_base.h +++ b/gr-usrp2/src/usrp2_sink_base.h @@ -55,6 +55,11 @@ public: */ bool set_interp(int interp_factor); + /*! + * \brief Calculate default scale_iq for given interpolation factor + */ + void default_scale_iq(int interpolation_factor, int *scale_i, int *scale_q); + /*! * \brief Set transmit IQ scale factors */ -- cgit