1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-01 13:47:01 -04:00

PlutoSDR input: implement control of hardware DC and IQ corrections

This commit is contained in:
f4exb
2019-07-25 13:57:24 +02:00
parent a40bc0affe
commit 1255784b7f
301 changed files with 494 additions and 311 deletions
@@ -371,6 +371,9 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
<< " m_LOppmTenths: " << m_settings.m_LOppmTenths
<< " m_dcBlock: " << m_settings.m_dcBlock
<< " m_iqCorrection: " << m_settings.m_iqCorrection
<< " m_hwBBDCBlock: " << m_settings.m_hwBBDCBlock
<< " m_hwRFDCBlock: " << m_settings.m_hwRFDCBlock
<< " m_hwIQCorrection: " << m_settings.m_hwIQCorrection
<< " m_lpfFIREnable: " << m_settings.m_lpfFIREnable
<< " m_lpfFIRBW: " << loc.toString(m_settings.m_lpfFIRBW)
<< " m_lpfFIRlog2Decim: " << m_settings.m_lpfFIRlog2Decim
@@ -400,6 +403,15 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force) {
reverseAPIKeys.append("iqCorrection");
}
if ((m_settings.m_hwBBDCBlock != settings.m_hwBBDCBlock) || force) {
reverseAPIKeys.append("hwBBDCBlock");
}
if ((m_settings.m_hwRFDCBlock != settings.m_hwRFDCBlock) || force) {
reverseAPIKeys.append("hwRFDCBlock");
}
if ((m_settings.m_hwIQCorrection != settings.m_hwIQCorrection) || force) {
reverseAPIKeys.append("hwIQCorrection");
}
if ((m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) || force) {
reverseAPIKeys.append("lpfFIREnable");
}
@@ -592,6 +604,24 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
paramsToSet = true;
}
if ((m_settings.m_hwBBDCBlock != settings.m_hwBBDCBlock) || force)
{
params.push_back(QString(tr("in_voltage_bb_dc_offset_tracking_en=%1").arg(settings.m_hwBBDCBlock ? 1 : 0)).toStdString());
paramsToSet = true;
}
if ((m_settings.m_hwRFDCBlock != settings.m_hwRFDCBlock) || force)
{
params.push_back(QString(tr("in_voltage_rf_dc_offset_tracking_en=%1").arg(settings.m_hwRFDCBlock ? 1 : 0)).toStdString());
paramsToSet = true;
}
if ((m_settings.m_hwIQCorrection != settings.m_hwIQCorrection) || force)
{
params.push_back(QString(tr("in_voltage_quadrature_tracking_en=%1").arg(settings.m_hwIQCorrection ? 1 : 0)).toStdString());
paramsToSet = true;
}
if (paramsToSet)
{
plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params);
@@ -798,6 +828,15 @@ int PlutoSDRInput::webapiSettingsPutPatch(
if (deviceSettingsKeys.contains("iqCorrection")) {
settings.m_iqCorrection = response.getPlutoSdrInputSettings()->getIqCorrection() != 0;
}
if (deviceSettingsKeys.contains("hwBBDCBlock")) {
settings.m_hwBBDCBlock = response.getPlutoSdrInputSettings()->getHwBbdcBlock() != 0;
}
if (deviceSettingsKeys.contains("hwRFDCBlock")) {
settings.m_hwBBDCBlock = response.getPlutoSdrInputSettings()->getHwRfdcBlock() != 0;
}
if (deviceSettingsKeys.contains("hwIQCorrection")) {
settings.m_hwBBDCBlock = response.getPlutoSdrInputSettings()->getHwIqCorrection() != 0;
}
if (deviceSettingsKeys.contains("log2Decim")) {
settings.m_log2Decim = response.getPlutoSdrInputSettings()->getLog2Decim();
}
@@ -875,6 +914,9 @@ void PlutoSDRInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& r
response.getPlutoSdrInputSettings()->setFcPos((int) settings.m_fcPos);
response.getPlutoSdrInputSettings()->setDcBlock(settings.m_dcBlock ? 1 : 0);
response.getPlutoSdrInputSettings()->setIqCorrection(settings.m_iqCorrection ? 1 : 0);
response.getPlutoSdrInputSettings()->setHwBbdcBlock(settings.m_hwBBDCBlock ? 1 : 0);
response.getPlutoSdrInputSettings()->setHwRfdcBlock(settings.m_hwRFDCBlock ? 1 : 0);
response.getPlutoSdrInputSettings()->setHwIqCorrection(settings.m_hwIQCorrection ? 1 : 0);
response.getPlutoSdrInputSettings()->setLog2Decim(settings.m_log2Decim);
response.getPlutoSdrInputSettings()->setLpfBw(settings.m_lpfBW);
response.getPlutoSdrInputSettings()->setGain(settings.m_gain);
@@ -955,6 +997,15 @@ void PlutoSDRInput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys
if (deviceSettingsKeys.contains("iqCorrection") || force) {
swgPlutoSdrInputSettings->setIqCorrection(settings.m_iqCorrection ? 1 : 0);
}
if (deviceSettingsKeys.contains("hwBBDCBlock") || force) {
swgPlutoSdrInputSettings->setHwBbdcBlock(settings.m_hwBBDCBlock ? 1 : 0);
}
if (deviceSettingsKeys.contains("hwRFDCBlock") || force) {
swgPlutoSdrInputSettings->setHwRfdcBlock(settings.m_hwRFDCBlock ? 1 : 0);
}
if (deviceSettingsKeys.contains("hwIQCorrection") || force) {
swgPlutoSdrInputSettings->setHwIqCorrection(settings.m_hwIQCorrection ? 1 : 0);
}
if (deviceSettingsKeys.contains("log2Decim") || force) {
swgPlutoSdrInputSettings->setLog2Decim(settings.m_log2Decim);
}
@@ -226,6 +226,25 @@ void PlutoSDRInputGui::on_iqImbalance_toggled(bool checked)
sendSettings();
}
void PlutoSDRInputGui::on_rfDCOffset_toggled(bool checked)
{
m_settings.m_hwRFDCBlock = checked;
sendSettings();
}
void PlutoSDRInputGui::on_bbDCOffset_toggled(bool checked)
{
m_settings.m_hwBBDCBlock = checked;
sendSettings();
}
void PlutoSDRInputGui::on_hwIQImbalance_toggled(bool checked)
{
m_settings.m_hwIQCorrection = checked;
sendSettings();
}
void PlutoSDRInputGui::on_swDecim_currentIndexChanged(int index)
{
m_settings.m_log2Decim = index > 6 ? 6 : index;
@@ -378,6 +397,9 @@ void PlutoSDRInputGui::displaySettings()
ui->dcOffset->setChecked(m_settings.m_dcBlock);
ui->iqImbalance->setChecked(m_settings.m_iqCorrection);
ui->bbDCOffset->setChecked(m_settings.m_hwBBDCBlock);
ui->rfDCOffset->setChecked(m_settings.m_hwRFDCBlock);
ui->hwIQImbalance->setChecked(m_settings.m_hwIQCorrection);
ui->loPPM->setValue(m_settings.m_LOppmTenths);
ui->loPPMText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1)));
@@ -85,6 +85,9 @@ private slots:
void on_centerFrequency_changed(quint64 value);
void on_loPPM_valueChanged(int value);
void on_dcOffset_toggled(bool checked);
void on_rfDCOffset_toggled(bool checked);
void on_bbDCOffset_toggled(bool checked);
void on_hwIQImbalance_toggled(bool checked);
void on_iqImbalance_toggled(bool checked);
void on_swDecim_currentIndexChanged(int index);
void on_fcPos_currentIndexChanged(int index);
@@ -35,6 +35,9 @@ void PlutoSDRInputSettings::resetToDefaults()
m_devSampleRate = 2500 * 1000;
m_dcBlock = false;
m_iqCorrection = false;
m_hwBBDCBlock = true;
m_hwRFDCBlock = true;
m_hwIQCorrection = true;
m_lpfBW = 1500000;
m_lpfFIREnable = false;
m_lpfFIRBW = 500000U;
@@ -76,6 +79,9 @@ QByteArray PlutoSDRInputSettings::serialize() const
s.writeString(19, m_reverseAPIAddress);
s.writeU32(20, m_reverseAPIPort);
s.writeU32(21, m_reverseAPIDeviceIndex);
s.writeBool(22, m_hwBBDCBlock);
s.writeBool(23, m_hwRFDCBlock);
s.writeBool(24, m_hwIQCorrection);
return s.final();
}
@@ -144,6 +150,10 @@ bool PlutoSDRInputSettings::deserialize(const QByteArray& data)
d.readU32(21, &uintval, 0);
m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
d.readBool(22, &m_hwBBDCBlock, true);
d.readBool(23, &m_hwRFDCBlock, true);
d.readBool(24, &m_hwIQCorrection, true);
return true;
}
else
@@ -68,6 +68,9 @@ struct PlutoSDRInputSettings {
fcPos_t m_fcPos;
bool m_dcBlock;
bool m_iqCorrection;
bool m_hwBBDCBlock; //!< Hardware baseband DC blocking
bool m_hwRFDCBlock; //!< Hardware RF DC blocking
bool m_hwIQCorrection; //!< Hardware IQ correction
quint32 m_log2Decim;
quint32 m_lpfBW; //!< analog lowpass filter bandwidth (Hz)
quint32 m_gain; //!< "hardware" gain