From 4d029d8965022ac0de8488380a62e487a894b9f7 Mon Sep 17 00:00:00 2001 From: Alexander Chemeris Date: Sat, 19 Apr 2014 17:25:00 +0400 Subject: UmTRX: Manually set Tx gain stages for the best signal quality. New UHD versions support split configuration of Tx gain stages. We utilize this to set the gain configuration, optimal for the Tx signal quality. From our measurements, VGA1 must be 18dB plus-minus one and VGA2 is the best when 23dB or lower. Signed-off-by: Tom Tsou --- Transceiver52M/UHDDevice.cpp | 45 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp index c9b71e1..0bb994e 100644 --- a/Transceiver52M/UHDDevice.cpp +++ b/Transceiver52M/UHDDevice.cpp @@ -48,6 +48,11 @@ */ #define UHD_RESTART_TIMEOUT 1.0 +/* + * UmTRX specific settings + */ +#define UMTRX_VGA1_DEF -18 + enum uhd_dev_type { USRP1, USRP2, @@ -449,9 +454,25 @@ void uhd_device::init_gains() { uhd::gain_range_t range; - range = usrp_dev->get_tx_gain_range(); - tx_gain_min = range.start(); - tx_gain_max = range.stop(); + if (dev_type == UMTRX) { + std::vector gain_stages = usrp_dev->get_tx_gain_names(0); + if (gain_stages[0] == "VGA") { + LOG(WARNING) << "Update your UHD version for a proper Tx gain support"; + } + if (gain_stages[0] == "VGA" || gain_stages[0] == "PA") { + range = usrp_dev->get_tx_gain_range(); + tx_gain_min = range.start(); + tx_gain_max = range.stop(); + } else { + range = usrp_dev->get_tx_gain_range("VGA2"); + tx_gain_min = UMTRX_VGA1_DEF + range.start(); + tx_gain_max = UMTRX_VGA1_DEF + range.stop(); + } + } else { + range = usrp_dev->get_tx_gain_range(); + tx_gain_min = range.start(); + tx_gain_max = range.stop(); + } range = usrp_dev->get_rx_gain_range(); rx_gain_min = range.start(); @@ -542,7 +563,23 @@ double uhd_device::setTxGain(double db, size_t chan) return 0.0f; } - usrp_dev->set_tx_gain(db, chan); + if (dev_type == UMTRX) { + std::vector gain_stages = usrp_dev->get_tx_gain_names(0); + if (gain_stages[0] == "VGA" || gain_stages[0] == "PA") { + usrp_dev->set_tx_gain(db, chan); + } else { + // New UHD versions support split configuration of + // Tx gain stages. We utilize this to set the gain + // configuration, optimal for the Tx signal quality. + // From our measurements, VGA1 must be 18dB plus-minus + // one and VGA2 is the best when 23dB or lower. + usrp_dev->set_tx_gain(UMTRX_VGA1_DEF, "VGA1", chan); + usrp_dev->set_tx_gain(db-UMTRX_VGA1_DEF, "VGA2", chan); + } + } else { + usrp_dev->set_tx_gain(db, chan); + } + tx_gains[chan] = usrp_dev->get_tx_gain(chan); LOG(INFO) << "Set TX gain to " << tx_gains[chan] << "dB"; -- cgit v1.2.3