aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/lib/usrp/common/apply_corrections.cpp49
-rw-r--r--host/lib/usrp/cores/rx_frontend_core_200.cpp4
-rw-r--r--host/lib/usrp/cores/tx_frontend_core_200.cpp4
-rw-r--r--host/utils/uhd_cal_rx_iq_balance.cpp4
-rw-r--r--host/utils/uhd_cal_tx_iq_balance.cpp4
-rw-r--r--host/utils/usrp_cal_utils.hpp2
6 files changed, 15 insertions, 52 deletions
diff --git a/host/lib/usrp/common/apply_corrections.cpp b/host/lib/usrp/common/apply_corrections.cpp
index 6aee00753..b889266f2 100644
--- a/host/lib/usrp/common/apply_corrections.cpp
+++ b/host/lib/usrp/common/apply_corrections.cpp
@@ -54,7 +54,7 @@ static bool fe_cal_comp(fe_cal_t a, fe_cal_t b){
static uhd::dict<std::string, std::vector<fe_cal_t> > fe_cal_cache;
-static std::complex<double> get_fe_dc_correction(
+static std::complex<double> get_fe_correction(
const std::string &key, const double lo_freq
){
const std::vector<fe_cal_t> &datas = fe_cal_cache[key];
@@ -81,36 +81,6 @@ static std::complex<double> get_fe_dc_correction(
);
}
-static std::complex<double> get_fe_iq_correction(
- const std::string &key, const double lo_freq
-){
- const std::vector<fe_cal_t> &datas = fe_cal_cache[key];
- if (datas.empty()) throw uhd::runtime_error("empty calibration table " + key);
-
- //search for lo freq
- size_t lo_index = 0;
- size_t hi_index = datas.size()-1;
- for (size_t i = 0; i < datas.size(); i++){
- if (datas[i].lo_freq > lo_freq){
- hi_index = i;
- break;
- }
- lo_index = i;
- }
-
- if (lo_index == 0) return std::complex<double>(datas[lo_index].iq_corr_real, datas[lo_index].iq_corr_imag);
- if (hi_index == lo_index) return std::complex<double>(datas[hi_index].iq_corr_real, datas[hi_index].iq_corr_imag);
-
- const std::complex<double> lo_val(datas[lo_index].iq_corr_real, datas[lo_index].iq_corr_imag);
- const std::complex<double> hi_val(datas[hi_index].iq_corr_real, datas[hi_index].iq_corr_imag);
-
- //interpolation time
- return std::polar<double>(
- linear_interp(lo_freq, datas[lo_index].lo_freq, std::abs(lo_val), datas[hi_index].lo_freq, std::abs(hi_val)),
- linear_interp(lo_freq, datas[lo_index].lo_freq, std::arg(lo_val), datas[hi_index].lo_freq, std::arg(hi_val))
- );
-}
-
static void apply_fe_corrections(
uhd::property_tree::sptr sub_tree,
const uhd::fs_path &db_path,
@@ -155,15 +125,8 @@ static void apply_fe_corrections(
}
- if (file_prefix.find("dc_cal") != std::string::npos){
- sub_tree->access<std::complex<double> >(fe_path)
- .set(get_fe_dc_correction(cal_data_path.string(), lo_freq));
- }
- else if (file_prefix.find("iq_cal") != std::string::npos){
- sub_tree->access<std::complex<double> >(fe_path)
- .set(get_fe_iq_correction(cal_data_path.string(), lo_freq));
- }
- else throw uhd::runtime_error("could not determine interpolation function");
+ sub_tree->access<std::complex<double> >(fe_path)
+ .set(get_fe_correction(cal_data_path.string(), lo_freq));
}
/***********************************************************************
@@ -180,14 +143,14 @@ void uhd::usrp::apply_tx_fe_corrections(
sub_tree,
"dboards/" + slot + "/tx_eeprom",
"tx_frontends/" + slot + "/iq_balance/value",
- "tx_iq_cal_v0.1_",
+ "tx_iq_cal_v0.2_",
lo_freq
);
apply_fe_corrections(
sub_tree,
"dboards/" + slot + "/tx_eeprom",
"tx_frontends/" + slot + "/dc_offset/value",
- "tx_dc_cal_v0.1_",
+ "tx_dc_cal_v0.2_",
lo_freq
);
}
@@ -207,7 +170,7 @@ void uhd::usrp::apply_rx_fe_corrections(
sub_tree,
"dboards/" + slot + "/rx_eeprom",
"rx_frontends/" + slot + "/iq_balance/value",
- "rx_iq_cal_v0.1_",
+ "rx_iq_cal_v0.2_",
lo_freq
);
}
diff --git a/host/lib/usrp/cores/rx_frontend_core_200.cpp b/host/lib/usrp/cores/rx_frontend_core_200.cpp
index d6396ef45..eb9f39fcf 100644
--- a/host/lib/usrp/cores/rx_frontend_core_200.cpp
+++ b/host/lib/usrp/cores/rx_frontend_core_200.cpp
@@ -64,8 +64,8 @@ public:
}
void set_iq_balance(const std::complex<double> &cor){
- _iface->poke32(REG_RX_FE_MAG_CORRECTION, fs_to_bits(std::abs(cor) - 1, 18));
- _iface->poke32(REG_RX_FE_PHASE_CORRECTION, fs_to_bits(std::arg(cor)/6.28318531, 18));
+ _iface->poke32(REG_RX_FE_MAG_CORRECTION, fs_to_bits(cor.real(), 18));
+ _iface->poke32(REG_RX_FE_PHASE_CORRECTION, fs_to_bits(cor.imag(), 18));
}
private:
diff --git a/host/lib/usrp/cores/tx_frontend_core_200.cpp b/host/lib/usrp/cores/tx_frontend_core_200.cpp
index b90281d9f..e35874173 100644
--- a/host/lib/usrp/cores/tx_frontend_core_200.cpp
+++ b/host/lib/usrp/cores/tx_frontend_core_200.cpp
@@ -62,8 +62,8 @@ public:
}
void set_iq_balance(const std::complex<double> &cor){
- _iface->poke32(REG_TX_FE_MAG_CORRECTION, fs_to_bits(std::abs(cor) - 1, 18));
- _iface->poke32(REG_TX_FE_PHASE_CORRECTION, fs_to_bits(std::arg(cor)/6.28318531, 18));
+ _iface->poke32(REG_TX_FE_MAG_CORRECTION, fs_to_bits(cor.real(), 18));
+ _iface->poke32(REG_TX_FE_PHASE_CORRECTION, fs_to_bits(cor.imag(), 18));
}
private:
diff --git a/host/utils/uhd_cal_rx_iq_balance.cpp b/host/utils/uhd_cal_rx_iq_balance.cpp
index 34a0a63fe..7b6f10f3b 100644
--- a/host/utils/uhd_cal_rx_iq_balance.cpp
+++ b/host/utils/uhd_cal_rx_iq_balance.cpp
@@ -166,7 +166,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
const double bb_imag_freq = -bb_tone_freq;
//capture initial uncorrected value
- usrp->set_rx_iq_balance(std::polar<double>(1.0, 0.0));
+ usrp->set_rx_iq_balance(0.0);
capture_samples(usrp, rx_stream, buff, nsamps);
const double initial_suppression = compute_tone_dbrms(buff, bb_tone_freq/actual_rx_rate) - compute_tone_dbrms(buff, bb_imag_freq/actual_rx_rate);
@@ -184,7 +184,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
for (double phase_corr = phase_corr_start; phase_corr <= phase_corr_stop + phase_corr_step/2; phase_corr += phase_corr_step){
for (double ampl_corr = ampl_corr_start; ampl_corr <= ampl_corr_stop + ampl_corr_step/2; ampl_corr += ampl_corr_step){
- const std::complex<double> correction = std::polar(ampl_corr+1, phase_corr*tau);
+ const std::complex<double> correction(ampl_corr, phase_corr);
usrp->set_rx_iq_balance(correction);
//receive some samples
diff --git a/host/utils/uhd_cal_tx_iq_balance.cpp b/host/utils/uhd_cal_tx_iq_balance.cpp
index c2222e777..cff3d1646 100644
--- a/host/utils/uhd_cal_tx_iq_balance.cpp
+++ b/host/utils/uhd_cal_tx_iq_balance.cpp
@@ -169,7 +169,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
const double bb_imag_freq = actual_tx_freq - tx_wave_freq - actual_rx_freq;
//capture initial uncorrected value
- usrp->set_tx_iq_balance(std::polar<double>(1.0, 0.0));
+ usrp->set_tx_iq_balance(0.0);
capture_samples(usrp, rx_stream, buff, nsamps);
const double initial_suppression = compute_tone_dbrms(buff, bb_tone_freq/actual_rx_rate) - compute_tone_dbrms(buff, bb_imag_freq/actual_rx_rate);
@@ -187,7 +187,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
for (double phase_corr = phase_corr_start; phase_corr <= phase_corr_stop + phase_corr_step/2; phase_corr += phase_corr_step){
for (double ampl_corr = ampl_corr_start; ampl_corr <= ampl_corr_stop + ampl_corr_step/2; ampl_corr += ampl_corr_step){
- const std::complex<double> correction = std::polar(ampl_corr+1, phase_corr*tau);
+ const std::complex<double> correction(ampl_corr, phase_corr);
usrp->set_tx_iq_balance(correction);
//receive some samples
diff --git a/host/utils/usrp_cal_utils.hpp b/host/utils/usrp_cal_utils.hpp
index 6d0c500e3..825d94d64 100644
--- a/host/utils/usrp_cal_utils.hpp
+++ b/host/utils/usrp_cal_utils.hpp
@@ -155,7 +155,7 @@ static void store_results(
fs::create_directory(cal_data_path);
cal_data_path = cal_data_path / "cal";
fs::create_directory(cal_data_path);
- cal_data_path = cal_data_path / str(boost::format("%s_%s_cal_v0.1_%s.csv") % xx % what % db_eeprom.serial);
+ cal_data_path = cal_data_path / str(boost::format("%s_%s_cal_v0.2_%s.csv") % xx % what % db_eeprom.serial);
if (fs::exists(cal_data_path)){
fs::rename(cal_data_path, cal_data_path.string() + str(boost::format(".%d") % time(NULL)));
}