From 4220097f99c37632d06de436fdd20772aad46fda Mon Sep 17 00:00:00 2001 From: Jason Abele Date: Thu, 29 Jul 2010 13:38:29 -0700 Subject: Fixes gain range for rfx400 vs other rfx --- host/lib/usrp/dboard/db_rfx.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'host') diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index 914ca5e19..664b406d9 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -65,6 +66,10 @@ static const prop_names_t rfx_rx_antennas = list_of("TX/RX")("RX2"); static const uhd::dict rfx_tx_gain_ranges; //empty static const uhd::dict rfx_rx_gain_ranges = map_list_of + ("PGA0", gain_range_t(0, 70, float(0.022))) +; + +static const uhd::dict rfx400_rx_gain_ranges = map_list_of ("PGA0", gain_range_t(0, 45, float(0.022))) ; @@ -88,6 +93,7 @@ public: private: freq_range_t _freq_range; + uhd::dict _rx_gain_ranges; uhd::dict _div2; double _rx_lo_freq, _tx_lo_freq; std::string _rx_ant; @@ -166,6 +172,14 @@ rfx_xcvr::rfx_xcvr( _div2[dboard_iface::UNIT_RX] = rx_div2; _div2[dboard_iface::UNIT_TX] = tx_div2; + if(this->get_rx_id() == 0x0024) { //RFX400 + _rx_gain_ranges = rfx400_rx_gain_ranges; + } + else { + _rx_gain_ranges = rfx_rx_gain_ranges; + } + + //enable the clocks that we need this->get_iface()->set_clock_enabled(dboard_iface::UNIT_TX, true); this->get_iface()->set_clock_enabled(dboard_iface::UNIT_RX, true); @@ -193,8 +207,8 @@ rfx_xcvr::rfx_xcvr( set_tx_lo_freq((_freq_range.min + _freq_range.max)/2.0); set_rx_ant("RX2"); - BOOST_FOREACH(const std::string &name, rfx_rx_gain_ranges.keys()){ - set_rx_gain(rfx_rx_gain_ranges[name].min, name); + BOOST_FOREACH(const std::string &name, _rx_gain_ranges.keys()){ + set_rx_gain(_rx_gain_ranges[name].min, name); } } @@ -247,7 +261,7 @@ void rfx_xcvr::set_tx_gain(float, const std::string &name){ } void rfx_xcvr::set_rx_gain(float gain, const std::string &name){ - assert_has(rfx_rx_gain_ranges.keys(), name, "rfx rx gain name"); + assert_has(_rx_gain_ranges.keys(), name, "rfx rx gain name"); if(name == "PGA0"){ float dac_volts = rx_pga0_gain_to_dac_volts(gain); _rx_gains[name] = gain; @@ -402,12 +416,12 @@ void rfx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_GAIN_RANGE: - assert_has(rfx_rx_gain_ranges.keys(), name, "rfx rx gain name"); - val = rfx_rx_gain_ranges[name]; + assert_has(_rx_gain_ranges.keys(), name, "rfx rx gain name"); + val = _rx_gain_ranges[name]; return; case SUBDEV_PROP_GAIN_NAMES: - val = prop_names_t(rfx_rx_gain_ranges.keys()); + val = prop_names_t(_rx_gain_ranges.keys()); return; case SUBDEV_PROP_FREQ: -- cgit v1.2.3 From a809e3c250bb1e096c2753ea00123b4f40b9ec4f Mon Sep 17 00:00:00 2001 From: Jason Abele Date: Thu, 29 Jul 2010 13:38:29 -0700 Subject: Fixes gain range for rfx400 vs other rfx --- host/docs/dboards.rst | 2 +- host/lib/usrp/dboard/db_rfx.cpp | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) (limited to 'host') diff --git a/host/docs/dboards.rst b/host/docs/dboards.rst index 9c496ebee..b85164d04 100644 --- a/host/docs/dboards.rst +++ b/host/docs/dboards.rst @@ -45,7 +45,7 @@ The user may set the receive antenna to be TX/RX or RX2. However, when using an RFX board in full-duplex mode, the receive antenna will always be set to RX2, regardless of the settings. -Recieve Gains: **PGA0**, Range: 0-45dB +Recieve Gains: **PGA0**, Range: 0-70dB (except RFX400 range is 0-45dB) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ XCVR 2450 diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index 914ca5e19..664b406d9 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -65,6 +66,10 @@ static const prop_names_t rfx_rx_antennas = list_of("TX/RX")("RX2"); static const uhd::dict rfx_tx_gain_ranges; //empty static const uhd::dict rfx_rx_gain_ranges = map_list_of + ("PGA0", gain_range_t(0, 70, float(0.022))) +; + +static const uhd::dict rfx400_rx_gain_ranges = map_list_of ("PGA0", gain_range_t(0, 45, float(0.022))) ; @@ -88,6 +93,7 @@ public: private: freq_range_t _freq_range; + uhd::dict _rx_gain_ranges; uhd::dict _div2; double _rx_lo_freq, _tx_lo_freq; std::string _rx_ant; @@ -166,6 +172,14 @@ rfx_xcvr::rfx_xcvr( _div2[dboard_iface::UNIT_RX] = rx_div2; _div2[dboard_iface::UNIT_TX] = tx_div2; + if(this->get_rx_id() == 0x0024) { //RFX400 + _rx_gain_ranges = rfx400_rx_gain_ranges; + } + else { + _rx_gain_ranges = rfx_rx_gain_ranges; + } + + //enable the clocks that we need this->get_iface()->set_clock_enabled(dboard_iface::UNIT_TX, true); this->get_iface()->set_clock_enabled(dboard_iface::UNIT_RX, true); @@ -193,8 +207,8 @@ rfx_xcvr::rfx_xcvr( set_tx_lo_freq((_freq_range.min + _freq_range.max)/2.0); set_rx_ant("RX2"); - BOOST_FOREACH(const std::string &name, rfx_rx_gain_ranges.keys()){ - set_rx_gain(rfx_rx_gain_ranges[name].min, name); + BOOST_FOREACH(const std::string &name, _rx_gain_ranges.keys()){ + set_rx_gain(_rx_gain_ranges[name].min, name); } } @@ -247,7 +261,7 @@ void rfx_xcvr::set_tx_gain(float, const std::string &name){ } void rfx_xcvr::set_rx_gain(float gain, const std::string &name){ - assert_has(rfx_rx_gain_ranges.keys(), name, "rfx rx gain name"); + assert_has(_rx_gain_ranges.keys(), name, "rfx rx gain name"); if(name == "PGA0"){ float dac_volts = rx_pga0_gain_to_dac_volts(gain); _rx_gains[name] = gain; @@ -402,12 +416,12 @@ void rfx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_GAIN_RANGE: - assert_has(rfx_rx_gain_ranges.keys(), name, "rfx rx gain name"); - val = rfx_rx_gain_ranges[name]; + assert_has(_rx_gain_ranges.keys(), name, "rfx rx gain name"); + val = _rx_gain_ranges[name]; return; case SUBDEV_PROP_GAIN_NAMES: - val = prop_names_t(rfx_rx_gain_ranges.keys()); + val = prop_names_t(_rx_gain_ranges.keys()); return; case SUBDEV_PROP_FREQ: -- cgit v1.2.3 From 94e7cec66a2d3efe6be5f12455644c4547b61a9c Mon Sep 17 00:00:00 2001 From: Jason Abele Date: Mon, 2 Aug 2010 17:40:30 -0700 Subject: Propogate gain range into RX pga0 helper for RFX boards --- host/lib/usrp/dboard/db_rfx.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'host') diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index 664b406d9..b6b44199a 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -241,10 +241,10 @@ void rfx_xcvr::set_tx_ant(const std::string &ant){ /*********************************************************************** * Gain Handling **********************************************************************/ -static float rx_pga0_gain_to_dac_volts(float &gain){ +static float rx_pga0_gain_to_dac_volts(float &gain, float range){ //voltage level constants (negative slope) static const float max_volts = float(.2), min_volts = float(1.2); - static const float slope = (max_volts-min_volts)/45; + static const float slope = (max_volts-min_volts)/(range); //calculate the voltage for the aux dac float dac_volts = std::clip(gain*slope + min_volts, max_volts, min_volts); @@ -263,7 +263,8 @@ void rfx_xcvr::set_tx_gain(float, const std::string &name){ void rfx_xcvr::set_rx_gain(float gain, const std::string &name){ assert_has(_rx_gain_ranges.keys(), name, "rfx rx gain name"); if(name == "PGA0"){ - float dac_volts = rx_pga0_gain_to_dac_volts(gain); + float dac_volts = rx_pga0_gain_to_dac_volts(gain, + (_rx_gain_ranges["PGA0"].max - _rx_gain_ranges["PGA0"].min)); _rx_gains[name] = gain; //write the new voltage to the aux dac -- cgit v1.2.3