diff options
Diffstat (limited to 'host/utils/usrp_cal_tx_dc_offset.cpp')
-rw-r--r-- | host/utils/usrp_cal_tx_dc_offset.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/host/utils/usrp_cal_tx_dc_offset.cpp b/host/utils/usrp_cal_tx_dc_offset.cpp index 2c75242c7..8615e231c 100644 --- a/host/utils/usrp_cal_tx_dc_offset.cpp +++ b/host/utils/usrp_cal_tx_dc_offset.cpp @@ -116,7 +116,8 @@ static void capture_samples(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streamer:: **********************************************************************/ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::string args; - double rate, tx_wave_freq, tx_wave_ampl, rx_offset, freq_step, tx_gain, rx_gain; + double rate, tx_wave_freq, tx_wave_ampl, rx_offset; + double freq_start, freq_stop, freq_step; size_t nsamps; po::options_description desc("Allowed options"); @@ -128,8 +129,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("tx_wave_freq", po::value<double>(&tx_wave_freq)->default_value(507.123e3), "Transmit wave frequency in Hz") ("tx_wave_ampl", po::value<double>(&tx_wave_ampl)->default_value(0.7), "Transmit wave amplitude in counts") ("rx_offset", po::value<double>(&rx_offset)->default_value(.9344e6), "RX LO offset from the TX LO in Hz") - ("tx_gain", po::value<double>(&tx_gain)->default_value(0), "TX gain in dB") - ("rx_gain", po::value<double>(&rx_gain)->default_value(0), "RX gain in dB") + ("freq_start", po::value<double>(&freq_start), "Frequency start in Hz (do not specify for default)") + ("freq_stop", po::value<double>(&freq_stop), "Frequency stop in Hz (do not specify for default)") ("freq_step", po::value<double>(&freq_step)->default_value(default_freq_step), "Step size for LO sweep in Hz") ("nsamps", po::value<size_t>(&nsamps)->default_value(default_num_samps), "Samples per data capture") ; @@ -159,14 +160,13 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ usrp->set_rx_antenna("CAL"); usrp->set_tx_antenna("CAL"); + //set optimum gain settings + set_optimum_gain(usrp); + //set the sample rates usrp->set_rx_rate(rate); usrp->set_tx_rate(rate); - //set midrange rx gain, default 0 tx gain - usrp->set_tx_gain(tx_gain); - usrp->set_rx_gain(rx_gain); - //create a receive streamer uhd::stream_args_t stream_args("fc32"); //complex floats uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args); @@ -181,8 +181,10 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //store the results here std::vector<result_t> results; - const uhd::meta_range_t freq_range = usrp->get_tx_freq_range(); - for (double tx_lo_i = freq_range.start()+50e6; tx_lo_i < freq_range.stop()-50e6; tx_lo_i += freq_step){ + if (not vm.count("freq_start")) freq_start = usrp->get_tx_freq_range().start() + 50e6; + if (not vm.count("freq_stop")) freq_stop = usrp->get_tx_freq_range().stop() - 50e6; + + for (double tx_lo_i = freq_start; tx_lo_i <= freq_stop; tx_lo_i += freq_step){ const double tx_lo = tune_rx_and_tx(usrp, tx_lo_i, rx_offset); //frequency constants for this tune event @@ -235,7 +237,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ dc_q_stop = best_dc_q + dc_q_step; } - if (lowest_offset < -90){ //most likely valid, keep result + if (lowest_offset < initial_dc_dbrms){ //most likely valid, keep result result_t result; result.freq = tx_lo; result.real_corr = best_dc_i; |