From 18abd4dbbf29ec9372bdd2ee83288fc94c20534c Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 15 Nov 2011 16:22:18 -0800 Subject: uhd: support for applying cal corrections B100 --- host/docs/calibration.rst | 13 +++++++------ host/lib/usrp/b100/b100_impl.cpp | 21 +++++++++++++++++++++ host/lib/usrp/b100/b100_impl.hpp | 2 ++ host/utils/uhd_cal_rx_iq_balance.cpp | 2 +- host/utils/uhd_cal_tx_dc_offset.cpp | 2 +- host/utils/uhd_cal_tx_iq_balance.cpp | 2 +- host/utils/usrp_cal_utils.hpp | 2 +- 7 files changed, 34 insertions(+), 10 deletions(-) diff --git a/host/docs/calibration.rst b/host/docs/calibration.rst index 26a1064c9..0aaace8f4 100644 --- a/host/docs/calibration.rst +++ b/host/docs/calibration.rst @@ -28,11 +28,12 @@ The following RF frontends are supported by the self-calibration utilities: * more to come... ******************************************** -Basic tool usage +Calibration utilities ******************************************** - UHD installs the calibration utilities into /bin. -Run the following from the command line: +**Disconnect** any extrernal hardware from the RF antenna ports, +and run the following from the command line. +Each utility will take several minutes to complete. :: uhd_cal_rx_iq_balance --verbose --args= @@ -43,13 +44,13 @@ See the output given by --help for more advanced options, such as: manually choosing the frequency range and step size for the sweeps. ******************************************** -Calibration files +Calibration data ******************************************** Calibration files are stored in the user's home/application directory. They can easily be moved from machine to another by copying the "cal" directory. Re-running a calibration utility will replace the existing calibration file. The old calibration file will be renamed so it may be recovered by the user. - * **Unix:** ${HOME}/.uhd/cal - * **Windows:** %APPDATA%\.uhd\cal + * **Unix:** ${HOME}/.uhd/cal/ + * **Windows:** %APPDATA%\\.uhd\\cal\\ diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp index 067fe8d47..7674a0fcf 100644 --- a/host/lib/usrp/b100/b100_impl.cpp +++ b/host/lib/usrp/b100/b100_impl.cpp @@ -15,6 +15,7 @@ // along with this program. If not, see . // +#include "apply_corrections.hpp" #include "b100_impl.hpp" #include "b100_ctrl.hpp" #include "fpga_regs_standard.h" @@ -408,6 +409,18 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ _dboard_iface, _tree->subtree(mb_path / "dboards/A") ); + //bind frontend corrections to the dboard freq props + const fs_path db_tx_fe_path = mb_path / "dboards" / "A" / "tx_frontends"; + BOOST_FOREACH(const std::string &name, _tree->list(db_tx_fe_path)){ + _tree->access(db_tx_fe_path / name / "freq" / "value") + .subscribe(boost::bind(&b100_impl::set_tx_fe_corrections, this, _1)); + } + const fs_path db_rx_fe_path = mb_path / "dboards" / "A" / "rx_frontends"; + BOOST_FOREACH(const std::string &name, _tree->list(db_rx_fe_path)){ + _tree->access(db_rx_fe_path / name / "freq" / "value") + .subscribe(boost::bind(&b100_impl::set_rx_fe_corrections, this, _1)); + } + //initialize io handling this->io_init(); @@ -501,3 +514,11 @@ sensor_value_t b100_impl::get_ref_locked(void){ const bool lock = _clock_ctrl->get_locked(); return sensor_value_t("Ref", lock, "locked", "unlocked"); } + +void b100_impl::set_rx_fe_corrections(const double lo_freq){ + apply_rx_fe_corrections(this->get_tree()->subtree("/mboards/0"), "A", lo_freq); +} + +void b100_impl::set_tx_fe_corrections(const double lo_freq){ + apply_tx_fe_corrections(this->get_tree()->subtree("/mboards/0"), "A", lo_freq); +} diff --git a/host/lib/usrp/b100/b100_impl.hpp b/host/lib/usrp/b100/b100_impl.hpp index 0984260be..96d90b14c 100644 --- a/host/lib/usrp/b100/b100_impl.hpp +++ b/host/lib/usrp/b100/b100_impl.hpp @@ -125,6 +125,8 @@ private: void clear_fpga_fifo(void); void handle_async_message(uhd::transport::managed_recv_buffer::sptr); uhd::sensor_value_t get_ref_locked(void); + void set_rx_fe_corrections(const double); + void set_tx_fe_corrections(const double); }; #endif /* INCLUDED_b100_IMPL_HPP */ diff --git a/host/utils/uhd_cal_rx_iq_balance.cpp b/host/utils/uhd_cal_rx_iq_balance.cpp index 7924323a5..a05df60b2 100644 --- a/host/utils/uhd_cal_rx_iq_balance.cpp +++ b/host/utils/uhd_cal_rx_iq_balance.cpp @@ -249,7 +249,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ result.delta = best_suppression - initial_suppression; results.push_back(result); if (vm.count("verbose")){ - std::cout << boost::format("%f MHz: best suppression %fdB, corrected %fdB") % (rx_lo/1e6) % result.best % result.delta << std::endl; + std::cout << boost::format("%f MHz: best suppression %f dB, corrected %f dB") % (rx_lo/1e6) % result.best % result.delta << std::endl; } else std::cout << "." << std::flush; } diff --git a/host/utils/uhd_cal_tx_dc_offset.cpp b/host/utils/uhd_cal_tx_dc_offset.cpp index 8615e231c..ed1b85bb3 100644 --- a/host/utils/uhd_cal_tx_dc_offset.cpp +++ b/host/utils/uhd_cal_tx_dc_offset.cpp @@ -246,7 +246,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ result.delta = initial_dc_dbrms - lowest_offset; results.push_back(result); if (vm.count("verbose")){ - std::cout << boost::format("%f MHz: lowest offset %fdB, corrected %fdB") % (tx_lo/1e6) % result.best % result.delta << std::endl; + std::cout << boost::format("%f MHz: lowest offset %f dB, corrected %f dB") % (tx_lo/1e6) % result.best % result.delta << std::endl; } else std::cout << "." << std::flush; } diff --git a/host/utils/uhd_cal_tx_iq_balance.cpp b/host/utils/uhd_cal_tx_iq_balance.cpp index 29b6f5ede..8b49ef170 100644 --- a/host/utils/uhd_cal_tx_iq_balance.cpp +++ b/host/utils/uhd_cal_tx_iq_balance.cpp @@ -251,7 +251,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ result.delta = best_suppression - initial_suppression; results.push_back(result); if (vm.count("verbose")){ - std::cout << boost::format("%f MHz: best suppression %fdB, corrected %fdB") % (tx_lo/1e6) % result.best % result.delta << std::endl; + std::cout << boost::format("%f MHz: best suppression %f dB, corrected %f dB") % (tx_lo/1e6) % result.best % result.delta << std::endl; } else std::cout << "." << std::flush; } diff --git a/host/utils/usrp_cal_utils.hpp b/host/utils/usrp_cal_utils.hpp index 5378b0d69..3058cd928 100644 --- a/host/utils/usrp_cal_utils.hpp +++ b/host/utils/usrp_cal_utils.hpp @@ -73,7 +73,7 @@ static inline void set_optimum_gain(uhd::usrp::multi_usrp::sptr usrp){ static inline std::vector > gen_table(void){ std::vector > wave_table(wave_table_len); for (size_t i = 0; i < wave_table_len; i++){ - wave_table[i] = std::polar(1.0, (tau*i)/wave_table_len); + wave_table[i] = std::complex(std::polar(1.0, (tau*i)/wave_table_len)); } return wave_table; } -- cgit v1.2.3