From eefe0ff989243b5af65fc6af0448fa4578fc713e Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 12 May 2017 11:25:39 +0200 Subject: Update DPD readme and add example --- dpd/dpd.ini | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 dpd/dpd.ini (limited to 'dpd/dpd.ini') diff --git a/dpd/dpd.ini b/dpd/dpd.ini new file mode 100644 index 0000000..906827b --- /dev/null +++ b/dpd/dpd.ini @@ -0,0 +1,41 @@ +[remotecontrol] +telnet=1 +telnetport=2121 + +[log] +syslog=0 +filelog=0 +filename=/dev/stderr + +[input] +transport=tcp +source=localhost:9200 + +[modulator] +digital_gain=0.9 +rate=8192000 + +[firfilter] +enabled=0 + +[output] +output=uhd + +[uhdoutput] +device= +master_clock_rate=32768000 +type=b200 +txgain=50 +channel=13C +refclk_source=internal +pps_source=none +behaviour_refclk_lock_lost=ignore +max_gps_holdover_time=600 +dpd_port=50055 + +[delaymanagement] +; Use synchronous=1 so that the USRP time is set. This works +; even in the absence of a reference clk and PPS +synchronous=1 +mutenotimestamps=1 +offset=4.0 -- cgit v1.2.3 From 1deec1418cd49e27bc2f7ddd6cd22ac6607642b3 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 12 May 2017 15:21:22 +0200 Subject: DPD: Set RX gain and frequency, add gain to RX and config --- dpd/dpd.ini | 3 ++ src/ConfigParser.cpp | 1 + src/OutputUHD.cpp | 70 +++++++++++++++++++++++++++++++---------------- src/OutputUHD.h | 1 + src/OutputUHDFeedback.cpp | 10 +++---- 5 files changed, 56 insertions(+), 29 deletions(-) (limited to 'dpd/dpd.ini') 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("uhdoutput.frequency", 0); std::string chan = pt.get("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; -- cgit v1.2.3 From d57fe2c74f2c9e0a76f4b2c577942837dfac0866 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 12 May 2017 17:20:29 +0200 Subject: DPD: Set RX sample rate --- dpd/README.md | 6 ++++-- dpd/dpd.ini | 4 ++-- src/OutputUHD.cpp | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'dpd/dpd.ini') diff --git a/dpd/README.md b/dpd/README.md index 96c4fb0..ec7cec2 100644 --- a/dpd/README.md +++ b/dpd/README.md @@ -8,11 +8,13 @@ This folder contains work in progress for digital predistortion. It requires: - A feedback connection from the power amplifier output, at an appropriate power level for the B200. Usually this is done with a directional coupler. - ODR-DabMod with enabled dpd_port, and with a samplerate of 8192000 samples per second. -- Synchronous=1 so that the USRP has the timestamping set properly. +- Synchronous=1 so that the USRP has the timestamping set properly, internal refclk and pps + are sufficient for this example. +- A live mux source with TIST enabled. See dpd/dpd.ini for an example. TODO ---- -Fix timestamps and test if frame data is valid. +Implement a PA model that updates the predistorter. diff --git a/dpd/dpd.ini b/dpd/dpd.ini index 625df73..910f251 100644 --- a/dpd/dpd.ini +++ b/dpd/dpd.ini @@ -14,7 +14,7 @@ transport=tcp source=localhost:9200 [modulator] -digital_gain=0.9 +digital_gain=0.8 rate=8192000 [firfilter] @@ -34,7 +34,7 @@ pps_source=none behaviour_refclk_lock_lost=ignore max_gps_holdover_time=600 dpd_port=50055 -rxgain=10 +rxgain=0 [delaymanagement] ; Use synchronous=1 so that the USRP time is set. This works diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp index 1a137d3..c2f985b 100644 --- a/src/OutputUHD.cpp +++ b/src/OutputUHD.cpp @@ -298,6 +298,9 @@ OutputUHD::OutputUHD( SetDelayBuffer(myConf.dabMode); + myUsrp->set_rx_rate(myConf.sampleRate); + MDEBUG("OutputUHD:Actual RX Rate: %f sps...\n", myUsrp->get_rx_rate()); + myUsrp->set_rx_antenna("RX2"); MDEBUG("OutputUHD:Set RX Antenna: %s ...\n", myUsrp->get_rx_antenna().c_str()); -- cgit v1.2.3 From 418eb33d0948bb12b7b2ed2179d43ad66258aa72 Mon Sep 17 00:00:00 2001 From: andreas128 Date: Mon, 29 May 2017 22:51:19 +0100 Subject: Configure txgrain --- dpd/dpd.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dpd/dpd.ini') diff --git a/dpd/dpd.ini b/dpd/dpd.ini index 910f251..5e809e5 100644 --- a/dpd/dpd.ini +++ b/dpd/dpd.ini @@ -27,7 +27,7 @@ output=uhd device= master_clock_rate=32768000 type=b200 -txgain=50 +txgain=75 channel=13C refclk_source=internal pps_source=none -- cgit v1.2.3