This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
pespin gerrit-no-reply at lists.osmocom.orgpespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-trx/+/18723 )
Change subject: UHDDevice: Compute TxGain on UHD API based on expected Tx output power
......................................................................
UHDDevice: Compute TxGain on UHD API based on expected Tx output power
Right now, according to a few measurements taken on B210, we expect the
Tx Gain at UHD level to relate 1:1 with the slope in Tx output power
given a specific band.
If more fine-grained results are wanted or some device doesn't follow a
1:1 slope relationship, functions TxGain2TxPower and TxPower2TxGain need
to be adapted/improved.
Change-Id: I6f432465dce5c6ec1f1bc4653f6149efb18c3f43
---
M Transceiver52M/device/uhd/UHDDevice.cpp
M Transceiver52M/device/uhd/UHDDevice.h
2 files changed, 58 insertions(+), 47 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/23/18723/1
diff --git a/Transceiver52M/device/uhd/UHDDevice.cpp b/Transceiver52M/device/uhd/UHDDevice.cpp
index 1897b87..d38ed21 100644
--- a/Transceiver52M/device/uhd/UHDDevice.cpp
+++ b/Transceiver52M/device/uhd/UHDDevice.cpp
@@ -208,12 +208,23 @@
}
#endif
+/* So far measurements done for B210 show really close to linear relationship
+ * between gain and real output power, so we simply adjust the measured offset
+ */
+static double TxGain2TxPower(dev_band_desc& desc, double tx_gain_db)
+{
+ return desc.nom_out_tx_power - (desc.nom_uhd_tx_gain - tx_gain_db);
+}
+static double TxPower2TxGain(dev_band_desc& desc, double tx_power_dbm)
+{
+ return desc.nom_uhd_tx_gain - (desc.nom_out_tx_power - tx_power_dbm);
+}
+
uhd_device::uhd_device(size_t tx_sps, size_t rx_sps,
InterfaceType iface, size_t chan_num, double lo_offset,
const std::vector<std::string>& tx_paths,
const std::vector<std::string>& rx_paths)
: RadioDevice(tx_sps, rx_sps, iface, chan_num, lo_offset, tx_paths, rx_paths),
- tx_gain_min(0.0), tx_gain_max(0.0),
rx_gain_min(0.0), rx_gain_max(0.0),
band((enum gsm_band)0), tx_spp(0), rx_spp(0),
started(false), aligned(false), drop_cnt(0),
@@ -252,6 +263,7 @@
void uhd_device::init_gains()
{
+ double tx_gain_min, tx_gain_max;
uhd::gain_range_t range;
if (dev_type == UMTRX) {
@@ -316,37 +328,6 @@
LOGC(DDEV, INFO) << "Rates configured for " << desc.str;
}
-double uhd_device::setTxGain(double db, size_t chan)
-{
- if (chan >= tx_gains.size()) {
- LOGC(DDEV, ALERT) << "Requested non-existent channel" << chan;
- return 0.0f;
- }
-
- if (dev_type == UMTRX) {
- std::vector<std::string> 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);
-
- LOGC(DDEV, INFO) << "Set TX gain to " << tx_gains[chan] << "dB (asked for " << db << "dB)";
-
- return tx_gains[chan];
-}
-
double uhd_device::setRxGain(double db, size_t chan)
{
if (chan >= rx_gains.size()) {
@@ -372,14 +353,50 @@
return rx_gains[chan];
}
-double uhd_device::getTxGain(size_t chan)
-{
+double uhd_device::setPowerAttenuation(int atten, size_t chan) {
+ double db;
+ dev_band_desc desc;
+
+ if (chan >= tx_gains.size()) {
+ LOGC(DDEV, ALERT) << "Requested non-existent channel" << chan;
+ return 0.0f;
+ }
+
+ get_dev_band_desc(desc);
+ db = TxPower2TxGain(desc, desc.nom_out_tx_power - atten);
+
+ if (dev_type == UMTRX) {
+ std::vector<std::string> 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);
+
+ LOGC(DDEV, INFO) << "Set TX gain to " << tx_gains[chan] << "dB (asked for " << db << "dB)";
+
+ return desc.nom_out_tx_power - TxGain2TxPower(desc, tx_gains[chan]);
+}
+double uhd_device::getPowerAttenuation(size_t chan) {
+ dev_band_desc desc;
if (chan >= tx_gains.size()) {
LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
return 0.0f;
}
- return tx_gains[chan];
+ get_dev_band_desc(desc);
+ return desc.nom_out_tx_power - TxGain2TxPower(desc, tx_gains[chan]);
}
int uhd_device::getNominalTxPower(size_t chan)
@@ -1003,7 +1020,6 @@
{
uint16_t req_arfcn;
enum gsm_band req_band;
- dev_band_desc desc;
if (chan >= tx_freqs.size()) {
LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
@@ -1032,12 +1048,6 @@
return false;
band = req_band;
-
- /* Update Max Tx Gain */
- get_dev_band_desc(desc);
- tx_gain_max = desc.nom_uhd_tx_gain;
- LOGCHAN(chan, DDEV, INFO) << "Updating max Gain to " << tx_gain_max
- << " dB based on GSM band information";
return true;
}
diff --git a/Transceiver52M/device/uhd/UHDDevice.h b/Transceiver52M/device/uhd/UHDDevice.h
index d87caf2..2c428ca 100644
--- a/Transceiver52M/device/uhd/UHDDevice.h
+++ b/Transceiver52M/device/uhd/UHDDevice.h
@@ -101,6 +101,9 @@
double maxRxGain(void) { return rx_gain_max; }
double minRxGain(void) { return rx_gain_min; }
+ double setPowerAttenuation(int atten, size_t chan);
+ double getPowerAttenuation(size_t chan = 0);
+
int getNominalTxPower(size_t chan = 0);
double getTxFreq(size_t chan);
@@ -131,10 +134,9 @@
};
private:
- double setTxGain(double db, size_t chan);
- double getTxGain(size_t chan = 0);
- double maxTxGain(void) { return tx_gain_max; }
- double minTxGain(void) { return tx_gain_min; }
+ double setTxGain(double db, size_t chan) {OSMO_ASSERT(false); return 0.0f; }
+ double getTxGain(size_t chan = 0) { OSMO_ASSERT(false); return 0.0f; };
+ double maxTxGain(void) { OSMO_ASSERT(false); return 0.0f; };
uhd::usrp::multi_usrp::sptr usrp_dev;
uhd::tx_streamer::sptr tx_stream;
@@ -144,7 +146,6 @@
double tx_rate, rx_rate;
- double tx_gain_min, tx_gain_max;
double rx_gain_min, rx_gain_max;
std::vector<double> tx_gains, rx_gains;
--
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/18723
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: I6f432465dce5c6ec1f1bc4653f6149efb18c3f43
Gerrit-Change-Number: 18723
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200608/958a5d94/attachment.htm>