aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/example.ini6
-rw-r--r--src/ConfigParser.cpp2
-rw-r--r--src/output/SDR.cpp8
-rw-r--r--src/output/SDRDevice.h3
-rw-r--r--src/output/Soapy.cpp28
-rw-r--r--src/output/Soapy.h4
-rw-r--r--src/output/UHD.cpp23
-rw-r--r--src/output/UHD.h4
8 files changed, 72 insertions, 6 deletions
diff --git a/doc/example.ini b/doc/example.ini
index b94825c..7f4d3e5 100644
--- a/doc/example.ini
+++ b/doc/example.ini
@@ -239,6 +239,9 @@ txgain=40
;frequency=234208000
channel=13C
+; Override automatic analog frontend bandwidth calculation. Units: Hz
+;bandwidth=2000000
+
; Some USRP boards/frontends support setting an LO offset that has the
; effect of shifting DC out of the signal bandwidth. This should also
; improve IQ imbalance effects, because the mirror will centered on another
@@ -297,6 +300,9 @@ txgain=40
channel=13C
;lo_offset=2048000
+; Override automatic analog frontend bandwidth calculation. Units: Hz
+;bandwidth=2000000
+
; You can set what TX antenna to use. This will depend on the
; SDR device you are using.
;tx_antenna=
diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp
index 21f2c23..9813663 100644
--- a/src/ConfigParser.cpp
+++ b/src/ConfigParser.cpp
@@ -235,6 +235,7 @@ static void parse_configfile(
sdr_device_config.rx_antenna = pt.Get("uhdoutput.rx_antenna", "RX2");
sdr_device_config.rxgain = pt.GetReal("uhdoutput.rxgain", 0.0);
sdr_device_config.frequency = pt.GetReal("uhdoutput.frequency", 0);
+ sdr_device_config.bandwidth = pt.GetReal("uhdoutput.bandwidth", 0);
std::string chan = pt.Get("uhdoutput.channel", "");
sdr_device_config.dabMode = mod_settings.dabMode;
@@ -287,6 +288,7 @@ static void parse_configfile(
outputsoapy_conf.tx_antenna = pt.Get("soapyoutput.tx_antenna", "");
outputsoapy_conf.lo_offset = pt.GetReal("soapyoutput.lo_offset", 0.0);
outputsoapy_conf.frequency = pt.GetReal("soapyoutput.frequency", 0);
+ outputsoapy_conf.bandwidth = pt.GetReal("soapyoutput.bandwidth", 0);
std::string chan = pt.Get("soapyoutput.channel", "");
outputsoapy_conf.dabMode = mod_settings.dabMode;
diff --git a/src/output/SDR.cpp b/src/output/SDR.cpp
index 23a947b..bacb281 100644
--- a/src/output/SDR.cpp
+++ b/src/output/SDR.cpp
@@ -75,6 +75,7 @@ SDR::SDR(SDRDeviceConfig& config, std::shared_ptr<SDRDevice> device) :
RC_ADD_PARAMETER(txgain, "TX gain");
RC_ADD_PARAMETER(rxgain, "RX gain for DPD feedback");
+ RC_ADD_PARAMETER(bandwidth, "Analog front-end bandwidth");
RC_ADD_PARAMETER(freq, "Transmission frequency");
RC_ADD_PARAMETER(muting, "Mute the output by stopping the transmitter");
RC_ADD_PARAMETER(temp, "Temperature in degrees C of the device");
@@ -376,6 +377,10 @@ void SDR::set_parameter(const string& parameter, const string& value)
ss >> m_config.rxgain;
m_device->set_rxgain(m_config.rxgain);
}
+ else if (parameter == "bandwidth") {
+ ss >> m_config.bandwidth;
+ m_device->set_bandwidth(m_config.bandwidth);
+ }
else if (parameter == "freq") {
ss >> m_config.frequency;
m_device->tune(m_config.lo_offset, m_config.frequency);
@@ -409,6 +414,9 @@ const string SDR::get_parameter(const string& parameter) const
else if (parameter == "rxgain") {
ss << m_config.rxgain;
}
+ else if (parameter == "bandwidth") {
+ ss << m_config.bandwidth;
+ }
else if (parameter == "freq") {
ss << m_config.frequency;
}
diff --git a/src/output/SDRDevice.h b/src/output/SDRDevice.h
index 90a1123..a1a488f 100644
--- a/src/output/SDRDevice.h
+++ b/src/output/SDRDevice.h
@@ -63,6 +63,7 @@ struct SDRDeviceConfig {
double txgain = 0.0;
double rxgain = 0.0;
bool enableSync = false;
+ double bandwidth = 0.0;
// When working with timestamps, mute the frames that
// do not have a timestamp
@@ -124,6 +125,8 @@ class SDRDevice {
virtual double get_real_secs(void) const = 0;
virtual void set_rxgain(double rxgain) = 0;
virtual double get_rxgain(void) const = 0;
+ virtual void set_bandwidth(double bandwidth) = 0;
+ virtual double get_bandwidth(void) const = 0;
virtual size_t receive_frame(
complexf *buf,
size_t num_samples,
diff --git a/src/output/Soapy.cpp b/src/output/Soapy.cpp
index 8c84b84..4846279 100644
--- a/src/output/Soapy.cpp
+++ b/src/output/Soapy.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Her Majesty the
Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2018
+ Copyright (C) 2019
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -90,15 +90,23 @@ Soapy::Soapy(SDRDeviceConfig& config) :
std::fixed << std::setprecision(3) <<
m_conf.frequency / 1000.0 << " kHz.";
+ if (m_conf.bandwidth > 0) {
+ m_device->setBandwidth(SOAPY_SDR_TX, 0, m_conf.bandwidth);
+ m_device->setBandwidth(SOAPY_SDR_RX, 0, m_conf.bandwidth);
+ etiLog.level(info) << "SoapySDR:Actual TX bandwidth: " <<
+ std::fixed << std::setprecision(2) <<
+ m_device->getBandwidth(SOAPY_SDR_TX, 0);
+ }
+
m_device->setGain(SOAPY_SDR_TX, 0, m_conf.txgain);
- etiLog.level(info) << "SoapySDR:Actual tx gain: " <<
+ etiLog.level(info) << "SoapySDR:Actual TX gain: " <<
std::fixed << std::setprecision(2) <<
m_device->getGain(SOAPY_SDR_TX, 0);
if (not m_conf.tx_antenna.empty()) {
m_device->setAntenna(SOAPY_SDR_TX, 0, m_conf.tx_antenna);
}
- etiLog.level(info) << "SoapySDR:Actual tx antenna: " <<
+ etiLog.level(info) << "SoapySDR:Actual TX antenna: " <<
m_device->getAntenna(SOAPY_SDR_TX, 0);
if (m_device->hasHardwareTime()) {
@@ -157,6 +165,20 @@ double Soapy::get_txgain(void) const
return m_device->getGain(SOAPY_SDR_TX, 0);
}
+void Soapy::set_bandwidth(double bandwidth)
+{
+ m_conf.bandwidth = bandwidth;
+ if (not m_device) throw runtime_error("Soapy device not set up");
+ m_device->setBandwidth(SOAPY_SDR_TX, 0, m_conf.bandwidth);
+ m_device->setBandwidth(SOAPY_SDR_RX, 0, m_conf.bandwidth);
+}
+
+double Soapy::get_bandwidth(void) const
+{
+ if (not m_device) throw runtime_error("Soapy device not set up");
+ return m_device->getBandwidth(SOAPY_SDR_TX, 0);
+}
+
SDRDevice::RunStatistics Soapy::get_run_statistics(void) const
{
RunStatistics rs;
diff --git a/src/output/Soapy.h b/src/output/Soapy.h
index 9feb0b8..4ee53ca 100644
--- a/src/output/Soapy.h
+++ b/src/output/Soapy.h
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Her Majesty the
Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2018
+ Copyright (C) 2019
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -63,6 +63,8 @@ class Soapy : public Output::SDRDevice
virtual double get_tx_freq(void) const override;
virtual void set_txgain(double txgain) override;
virtual double get_txgain(void) const override;
+ virtual void set_bandwidth(double bandwidth) override;
+ virtual double get_bandwidth(void) const override;
virtual void transmit_frame(const struct FrameData& frame) override;
virtual RunStatistics get_run_statistics(void) const override;
virtual double get_real_secs(void) const override;
diff --git a/src/output/UHD.cpp b/src/output/UHD.cpp
index c6c500b..e85e66f 100644
--- a/src/output/UHD.cpp
+++ b/src/output/UHD.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Her Majesty the
Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2018
+ Copyright (C) 2019
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -193,6 +193,15 @@ UHD::UHD(SDRDeviceConfig& config) :
throw std::runtime_error("Cannot set USRP sample rate. Aborted.");
}
+ if (m_conf.bandwidth > 0) {
+ m_usrp->set_tx_bandwidth(m_conf.bandwidth);
+ m_usrp->set_rx_bandwidth(m_conf.bandwidth);
+
+ etiLog.level(info) << "OutputUHD:Actual TX bandwidth: " <<
+ std::fixed << std::setprecision(2) <<
+ m_usrp->get_tx_bandwidth();
+ }
+
tune(m_conf.lo_offset, m_conf.frequency);
m_conf.frequency = m_usrp->get_tx_freq();
@@ -294,6 +303,18 @@ double UHD::get_txgain(void) const
return m_usrp->get_tx_gain();
}
+void UHD::set_bandwidth(double bandwidth)
+{
+ m_usrp->set_tx_bandwidth(bandwidth);
+ m_usrp->set_rx_bandwidth(bandwidth);
+ m_conf.bandwidth = m_usrp->get_tx_bandwidth();
+}
+
+double UHD::get_bandwidth(void) const
+{
+ return m_usrp->get_tx_bandwidth();
+}
+
void UHD::transmit_frame(const struct FrameData& frame)
{
const double tx_timeout = 20.0;
diff --git a/src/output/UHD.h b/src/output/UHD.h
index f42b6e8..29867fb 100644
--- a/src/output/UHD.h
+++ b/src/output/UHD.h
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Her Majesty the
Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2018
+ Copyright (C) 2019
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -77,6 +77,8 @@ class UHD : public Output::SDRDevice
virtual double get_tx_freq(void) const override;
virtual void set_txgain(double txgain) override;
virtual double get_txgain(void) const override;
+ virtual void set_bandwidth(double bandwidth) override;
+ virtual double get_bandwidth(void) const override;
virtual void transmit_frame(const struct FrameData& frame) override;
virtual RunStatistics get_run_statistics(void) const override;
virtual double get_real_secs(void) const override;