From 8eb2b6842570af606c797d1bc8da55bb27487b99 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 25 Feb 2017 12:05:34 +0100 Subject: Add ability to set UHD LO offset --- src/DabMod.cpp | 1 + src/OutputUHD.cpp | 26 +++++++++++++++++++++++--- src/OutputUHD.h | 1 + 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/DabMod.cpp b/src/DabMod.cpp index 37db71a..741ac73 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -503,6 +503,7 @@ int launch_modulator(int argc, char* argv[]) throw std::runtime_error("Configuration error"); } + outputuhd_conf.lo_offset = pt.get("uhdoutput.lo_offset", 0); outputuhd_conf.refclk_src = pt.get("uhdoutput.refclk_source", "internal"); outputuhd_conf.pps_src = pt.get("uhdoutput.pps_source", "none"); diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp index 7f880e0..072b63a 100644 --- a/src/OutputUHD.cpp +++ b/src/OutputUHD.cpp @@ -221,9 +221,29 @@ OutputUHD::OutputUHD( throw std::runtime_error("Cannot set USRP sample rate. Aborted."); } - //set the centre frequency - MDEBUG("OutputUHD:Setting freq to %f...\n", myConf.frequency); - myUsrp->set_tx_freq(myConf.frequency); + if (myConf.lo_offset != 0.0) { + etiLog.log(info, "OutputUHD:Setting freq to %f with LO offset %f...\n", + myConf.frequency, 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(info) << "OutputUHD: " << std::fixed << + "Target RF: " << result.target_rf_freq << + "Actual RF: " << result.actual_rf_freq << + "Target DSP: " << result.target_dsp_freq << + "Actual DSP: " << result.actual_dsp_freq; + + if (result.clipped_rf_freq != result.target_rf_freq) { + etiLog.level(warn) << + "OutputUHD: clipped RF frequency " << std::fixed << + " different from target"; + } + } + else { + //set the centre frequency + etiLog.log(info, "OutputUHD:Setting freq to %f...\n", myConf.frequency); + myUsrp->set_tx_freq(myConf.frequency); + } myConf.frequency = myUsrp->get_tx_freq(); MDEBUG("OutputUHD:Actual frequency: %f\n", myConf.frequency); diff --git a/src/OutputUHD.h b/src/OutputUHD.h index e477e47..cbf159f 100644 --- a/src/OutputUHD.h +++ b/src/OutputUHD.h @@ -182,6 +182,7 @@ struct OutputUHDConfig { long masterClockRate = 32768000; unsigned sampleRate = 2048000; double frequency = 0.0; + double lo_offset = 0.0; double txgain = 0.0; bool enableSync = false; bool muteNoTimestamps = false; -- cgit v1.2.3