summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-05-12 15:21:22 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-05-12 15:21:22 +0200
commit1deec1418cd49e27bc2f7ddd6cd22ac6607642b3 (patch)
tree51f77ad85aac16fec86478bef6c430fd96596ed8
parentd34574c9688791a83c0b18f501546228bcb40ccb (diff)
downloaddabmod-1deec1418cd49e27bc2f7ddd6cd22ac6607642b3.tar.gz
dabmod-1deec1418cd49e27bc2f7ddd6cd22ac6607642b3.tar.bz2
dabmod-1deec1418cd49e27bc2f7ddd6cd22ac6607642b3.zip
DPD: Set RX gain and frequency, add gain to RX and config
-rw-r--r--dpd/dpd.ini3
-rw-r--r--src/ConfigParser.cpp1
-rw-r--r--src/OutputUHD.cpp70
-rw-r--r--src/OutputUHD.h1
-rw-r--r--src/OutputUHDFeedback.cpp10
5 files changed, 56 insertions, 29 deletions
diff --git a/dpd/dpd.ini b/dpd/dpd.ini
index 906827b..625df73 100644
--- a/dpd/dpd.ini
+++ b/dpd/dpd.ini
@@ -1,6 +1,8 @@
[remotecontrol]
telnet=1
telnetport=2121
+zmqctrl=1
+zmqctrlendpoint=tcp://127.0.0.1:9400
[log]
syslog=0
@@ -32,6 +34,7 @@ pps_source=none
behaviour_refclk_lock_lost=ignore
max_gps_holdover_time=600
dpd_port=50055
+rxgain=10
[delaymanagement]
; Use synchronous=1 so that the USRP time is set. This works
diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp
index 8892642..459811f 100644
--- a/src/ConfigParser.cpp
+++ b/src/ConfigParser.cpp
@@ -218,6 +218,7 @@ static void parse_configfile(
}
outputuhd_conf.txgain = pt.get("uhdoutput.txgain", 0.0);
+ outputuhd_conf.rxgain = pt.get("uhdoutput.rxgain", 0.0);
outputuhd_conf.frequency = pt.get<double>("uhdoutput.frequency", 0);
std::string chan = pt.get<std::string>("uhdoutput.channel", "");
outputuhd_conf.dabMode = mod_settings.dabMode;
diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp
index 5e9e17c..f764fb8 100644
--- a/src/OutputUHD.cpp
+++ b/src/OutputUHD.cpp
@@ -80,6 +80,36 @@ void uhd_msg_handler(uhd::msg::type_t type, const std::string &msg)
}
}
+static void tune_usrp_to(
+ uhd::usrp::multi_usrp::sptr usrp,
+ double lo_offset,
+ double frequency)
+{
+ if (lo_offset != 0.0) {
+ etiLog.level(info) << std::fixed << std::setprecision(3) <<
+ "OutputUHD:Setting freq to " << frequency <<
+ " with LO offset " << lo_offset << "...";
+
+ const auto tr = uhd::tune_request_t(frequency, lo_offset);
+ uhd::tune_result_t result = usrp->set_tx_freq(tr);
+
+ etiLog.level(debug) << "OutputUHD:" <<
+ std::fixed << std::setprecision(0) <<
+ " Target RF: " << result.target_rf_freq <<
+ " Actual RF: " << result.actual_rf_freq <<
+ " Target DSP: " << result.target_dsp_freq <<
+ " Actual DSP: " << result.actual_dsp_freq;
+ }
+ else {
+ //set the centre frequency
+ etiLog.level(info) << std::fixed << std::setprecision(3) <<
+ "OutputUHD:Setting freq to " << frequency << "...";
+ usrp->set_tx_freq(frequency);
+ }
+
+ usrp->set_rx_freq(frequency);
+}
+
// Check function for GPS TIMELOCK sensor from the ODR LEA-M8F board GPSDO
bool check_gps_timelock(uhd::usrp::multi_usrp::sptr usrp)
{
@@ -165,6 +195,7 @@ OutputUHD::OutputUHD(
/* register the parameters that can be remote controlled */
RC_ADD_PARAMETER(txgain, "UHD analog daughterboard TX gain");
+ RC_ADD_PARAMETER(rxgain, "UHD analog daughterboard RX gain for DPD feedback");
RC_ADD_PARAMETER(freq, "UHD transmission frequency");
RC_ADD_PARAMETER(muting, "Mute the output by stopping the transmitter");
RC_ADD_PARAMETER(staticdelay, "Set static delay (uS) between 0 and 96000");
@@ -223,31 +254,14 @@ OutputUHD::OutputUHD(
throw std::runtime_error("Cannot set USRP sample rate. Aborted.");
}
- if (myConf.lo_offset != 0.0) {
- etiLog.level(info) << std::fixed << std::setprecision(3) <<
- "OutputUHD:Setting freq to " << myConf.frequency <<
- " with LO offset " << myConf.lo_offset << "...";
-
- const auto tr = uhd::tune_request_t(myConf.frequency, myConf.lo_offset);
- uhd::tune_result_t result = myUsrp->set_tx_freq(tr);
-
- etiLog.level(debug) << "OutputUHD:" <<
- std::fixed << std::setprecision(0) <<
- " Target RF: " << result.target_rf_freq <<
- " Actual RF: " << result.actual_rf_freq <<
- " Target DSP: " << result.target_dsp_freq <<
- " Actual DSP: " << result.actual_dsp_freq;
- }
- else {
- //set the centre frequency
- etiLog.level(info) << std::fixed << std::setprecision(3) <<
- "OutputUHD:Setting freq to " << myConf.frequency << "...";
- myUsrp->set_tx_freq(myConf.frequency);
- }
+ tune_usrp_to(myUsrp, myConf.lo_offset, myConf.frequency);
myConf.frequency = myUsrp->get_tx_freq();
etiLog.level(info) << std::fixed << std::setprecision(3) <<
- "OutputUHD:Actual frequency: " << myConf.frequency;
+ "OutputUHD:Actual TX frequency: " << myConf.frequency;
+
+ etiLog.level(info) << std::fixed << std::setprecision(3) <<
+ "OutputUHD:Actual RX frequency: " << myUsrp->get_tx_freq();
myUsrp->set_tx_gain(myConf.txgain);
MDEBUG("OutputUHD:Actual TX Gain: %f ...\n", myUsrp->get_tx_gain());
@@ -284,6 +298,9 @@ OutputUHD::OutputUHD(
SetDelayBuffer(myConf.dabMode);
+ myUsrp->set_rx_gain(myConf.rxgain);
+ MDEBUG("OutputUHD:Actual RX Gain: %f ...\n", myUsrp->get_rx_gain());
+
uhdFeedback.setup(myUsrp, myConf.dpdFeedbackServerPort, myConf.sampleRate);
MDEBUG("OutputUHD:UHD ready.\n");
@@ -910,9 +927,13 @@ void OutputUHD::set_parameter(const string& parameter, const string& value)
ss >> myConf.txgain;
myUsrp->set_tx_gain(myConf.txgain);
}
+ else if (parameter == "rxgain") {
+ ss >> myConf.rxgain;
+ myUsrp->set_rx_gain(myConf.rxgain);
+ }
else if (parameter == "freq") {
ss >> myConf.frequency;
- myUsrp->set_tx_freq(myConf.frequency);
+ tune_usrp_to(myUsrp, myConf.lo_offset, myConf.frequency);
myConf.frequency = myUsrp->get_tx_freq();
}
else if (parameter == "muting") {
@@ -951,6 +972,9 @@ const string OutputUHD::get_parameter(const string& parameter) const
if (parameter == "txgain") {
ss << myConf.txgain;
}
+ else if (parameter == "rxgain") {
+ ss << myConf.rxgain;
+ }
else if (parameter == "freq") {
ss << myConf.frequency;
}
diff --git a/src/OutputUHD.h b/src/OutputUHD.h
index 1246fc5..c966c7e 100644
--- a/src/OutputUHD.h
+++ b/src/OutputUHD.h
@@ -189,6 +189,7 @@ struct OutputUHDConfig {
double frequency = 0.0;
double lo_offset = 0.0;
double txgain = 0.0;
+ double rxgain = 0.0;
bool enableSync = false;
bool muteNoTimestamps = false;
unsigned dabMode = 0;
diff --git a/src/OutputUHDFeedback.cpp b/src/OutputUHDFeedback.cpp
index 9e3aab2..788b0a9 100644
--- a/src/OutputUHDFeedback.cpp
+++ b/src/OutputUHDFeedback.cpp
@@ -153,9 +153,6 @@ void OutputUHDFeedback::ReceiveBurstThread()
const double usrp_time = m_usrp->get_time_now().get_real_secs();
const double cmd_time = cmd.time_spec.get_real_secs();
- etiLog.level(debug) <<
- "RX stream command ts=" << std::fixed << cmd_time << " Delta=" << cmd_time - usrp_time;
-
rxStream->issue_stream_cmd(cmd);
uhd::rx_metadata_t md;
@@ -173,9 +170,10 @@ void OutputUHDFeedback::ReceiveBurstThread()
burstRequest.rx_second = md.time_spec.get_full_secs();
burstRequest.rx_pps = md.time_spec.get_frac_secs() * 16384000.0;
- etiLog.level(debug) << "Read " << samples_read << " RX feedback samples "
- << "at time " << std::fixed << burstRequest.tx_second << "." <<
- burstRequest.tx_pps / 16384000.0;
+ etiLog.level(debug) << "DPD: acquired " << samples_read << " RX feedback samples " <<
+ "at time " << burstRequest.tx_second << " + " <<
+ std::fixed << burstRequest.tx_pps / 16384000.0 <<
+ " Delta=" << cmd_time - usrp_time;
burstRequest.state = BurstRequestState::Acquired;