LimeSDR: fixed amalog LP bandwidth filter and general calibration

This commit is contained in:
f4exb 2017-11-09 17:31:32 +01:00
parent c4e26bf66d
commit 23b9450c56
2 changed files with 58 additions and 42 deletions

View File

@ -637,6 +637,7 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
bool forwardClockSource = false; bool forwardClockSource = false;
bool ownThreadWasRunning = false; bool ownThreadWasRunning = false;
bool doCalibration = false; bool doCalibration = false;
bool doLPCalibration = false;
double clockGenFreq = 0.0; double clockGenFreq = 0.0;
// QMutexLocker mutexLocker(&m_mutex); // QMutexLocker mutexLocker(&m_mutex);
@ -713,18 +714,7 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
{ {
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired) if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
{ {
if (LMS_SetLPFBW(m_deviceShared.m_deviceParams->getDevice(), doLPCalibration = true;
LMS_CH_TX,
m_deviceShared.m_channel,
settings.m_lpfBW) < 0)
{
qCritical("LimeSDROutput::applySettings: could not set LPF to %f Hz", settings.m_lpfBW);
}
else
{
//doCalibration = true;
qDebug("LimeSDROutput::applySettings: LPF set to %f Hz", settings.m_lpfBW);
}
} }
} }
@ -869,7 +859,7 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
doCalibration = doCalibration || (clockGenFreqAfter != clockGenFreq); doCalibration = doCalibration || (clockGenFreqAfter != clockGenFreq);
} }
if (doCalibration && m_channelAcquired) if ((doCalibration || doLPCalibration) && m_channelAcquired)
{ {
if (m_limeSDROutputThread && m_limeSDROutputThread->isRunning()) if (m_limeSDROutputThread && m_limeSDROutputThread->isRunning())
{ {
@ -880,10 +870,12 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
suspendRxBuddies(); suspendRxBuddies();
suspendTxBuddies(); suspendTxBuddies();
if (doCalibration)
{
if (LMS_Calibrate(m_deviceShared.m_deviceParams->getDevice(), if (LMS_Calibrate(m_deviceShared.m_deviceParams->getDevice(),
LMS_CH_TX, LMS_CH_TX,
m_deviceShared.m_channel, m_deviceShared.m_channel,
m_settings.m_lpfBW, m_settings.m_devSampleRate,
0) < 0) 0) < 0)
{ {
qCritical("LimeSDROutput::applySettings: calibration failed on Tx channel %d", m_deviceShared.m_channel); qCritical("LimeSDROutput::applySettings: calibration failed on Tx channel %d", m_deviceShared.m_channel);
@ -892,6 +884,22 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
{ {
qDebug("LimeSDROutput::applySettings: calibration successful on Tx channel %d", m_deviceShared.m_channel); qDebug("LimeSDROutput::applySettings: calibration successful on Tx channel %d", m_deviceShared.m_channel);
} }
}
else if (doLPCalibration)
{
if (LMS_SetLPFBW(m_deviceShared.m_deviceParams->getDevice(),
LMS_CH_TX,
m_deviceShared.m_channel,
m_settings.m_lpfBW) < 0)
{
qCritical("LimeSDROutput::applySettings: could not set LPF to %f Hz", m_settings.m_lpfBW);
}
else
{
//doCalibration = true;
qDebug("LimeSDROutput::applySettings: LPF set to %f Hz", m_settings.m_lpfBW);
}
}
resumeTxBuddies(); resumeTxBuddies();
resumeRxBuddies(); resumeRxBuddies();

View File

@ -669,6 +669,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
bool forwardClockSource = false; bool forwardClockSource = false;
bool ownThreadWasRunning = false; bool ownThreadWasRunning = false;
bool doCalibration = false; bool doCalibration = false;
bool doLPCalibration = false;
bool setAntennaAuto = false; bool setAntennaAuto = false;
double clockGenFreq = 0.0; double clockGenFreq = 0.0;
// QMutexLocker mutexLocker(&m_mutex); // QMutexLocker mutexLocker(&m_mutex);
@ -863,18 +864,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
{ {
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired) if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
{ {
if (LMS_SetLPFBW(m_deviceShared.m_deviceParams->getDevice(), doLPCalibration = true;
LMS_CH_RX,
m_deviceShared.m_channel,
settings.m_lpfBW) < 0)
{
qCritical("LimeSDRInput::applySettings: could not set LPF to %f Hz", settings.m_lpfBW);
}
else
{
doCalibration = true;
qDebug("LimeSDRInput::applySettings: LPF set to %f Hz", settings.m_lpfBW);
}
} }
} }
@ -1021,7 +1011,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
doCalibration = doCalibration || (clockGenFreqAfter != clockGenFreq); doCalibration = doCalibration || (clockGenFreqAfter != clockGenFreq);
} }
if (doCalibration) if (doCalibration || doLPCalibration)
{ {
if (m_limeSDRInputThread && m_limeSDRInputThread->isRunning()) if (m_limeSDRInputThread && m_limeSDRInputThread->isRunning())
{ {
@ -1032,10 +1022,12 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
suspendRxBuddies(); suspendRxBuddies();
suspendTxBuddies(); suspendTxBuddies();
if (doCalibration)
{
if (LMS_Calibrate(m_deviceShared.m_deviceParams->getDevice(), if (LMS_Calibrate(m_deviceShared.m_deviceParams->getDevice(),
LMS_CH_RX, LMS_CH_RX,
m_deviceShared.m_channel, m_deviceShared.m_channel,
m_settings.m_lpfBW, m_settings.m_devSampleRate,
0) < 0) 0) < 0)
{ {
qCritical("LimeSDRInput::applySettings: calibration failed on Rx channel %d", m_deviceShared.m_channel); qCritical("LimeSDRInput::applySettings: calibration failed on Rx channel %d", m_deviceShared.m_channel);
@ -1044,6 +1036,22 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
{ {
qDebug("LimeSDRInput::applySettings: calibration successful on Rx channel %d", m_deviceShared.m_channel); qDebug("LimeSDRInput::applySettings: calibration successful on Rx channel %d", m_deviceShared.m_channel);
} }
}
else if (doLPCalibration)
{
if (LMS_SetLPFBW(m_deviceShared.m_deviceParams->getDevice(),
LMS_CH_RX,
m_deviceShared.m_channel,
m_settings.m_lpfBW) < 0)
{
qCritical("LimeSDRInput::applySettings: could not set LPF to %f Hz", m_settings.m_lpfBW);
}
else
{
doCalibration = true;
qDebug("LimeSDRInput::applySettings: LPF set to %f Hz", m_settings.m_lpfBW);
}
}
resumeTxBuddies(); resumeTxBuddies();
resumeRxBuddies(); resumeRxBuddies();