Lime: Report calibration errors in GUI. Check LPF is reasonable for up/downconversion.

This commit is contained in:
Jon Beniston 2022-08-27 17:08:03 +01:00
parent d1a4fca49b
commit d04b4840a9
13 changed files with 183 additions and 40 deletions

View File

@ -41,6 +41,7 @@
MESSAGE_CLASS_DEFINITION(LimeSDROutput::MsgConfigureLimeSDR, Message)
MESSAGE_CLASS_DEFINITION(LimeSDROutput::MsgStartStop, Message)
MESSAGE_CLASS_DEFINITION(LimeSDROutput::MsgCalibrationResult, Message)
MESSAGE_CLASS_DEFINITION(LimeSDROutput::MsgGetStreamInfo, Message)
MESSAGE_CLASS_DEFINITION(LimeSDROutput::MsgGetDeviceInfo, Message)
MESSAGE_CLASS_DEFINITION(LimeSDROutput::MsgReportStreamInfo, Message)
@ -1066,19 +1067,20 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
if (doCalibration)
{
double bw = std::min((double)m_settings.m_devSampleRate, 2500000.0); // Min supported calibration bandwidth is 2.5MHz
if (LMS_Calibrate(m_deviceShared.m_deviceParams->getDevice(),
LMS_CH_TX,
m_deviceShared.m_channel,
bw,
0) != 0)
{
double bw = std::max((double)m_settings.m_devSampleRate, 2500000.0); // Min supported calibration bandwidth is 2.5MHz
bool calibrationOK = LMS_Calibrate(m_deviceShared.m_deviceParams->getDevice(),
LMS_CH_TX,
m_deviceShared.m_channel,
bw,
0) == 0;
if (!calibrationOK) {
qCritical("LimeSDROutput::applySettings: calibration failed on Tx channel %d", m_deviceShared.m_channel);
}
else
{
} else {
qDebug("LimeSDROutput::applySettings: calibration successful on Tx channel %d", m_deviceShared.m_channel);
}
if (m_guiMessageQueue) {
m_guiMessageQueue->push(MsgCalibrationResult::create(calibrationOK));
}
}
if (doLPCalibration)

View File

@ -79,6 +79,25 @@ public:
{ }
};
class MsgCalibrationResult : public Message {
MESSAGE_CLASS_DECLARATION
public:
bool getSuccess() const { return m_success; }
static MsgCalibrationResult* create(bool success) {
return new MsgCalibrationResult(success);
}
protected:
bool m_success;
MsgCalibrationResult(bool success) :
Message(),
m_success(success)
{ }
};
class MsgGetStreamInfo : public Message {
MESSAGE_CLASS_DECLARATION

View File

@ -202,6 +202,16 @@ bool LimeSDROutputGUI::handleMessage(const Message& message)
return true;
}
else if (LimeSDROutput::MsgCalibrationResult::match(message))
{
LimeSDROutput::MsgCalibrationResult& report = (LimeSDROutput::MsgCalibrationResult&) message;
if (report.getSuccess()) {
ui->calibrationLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
} else {
ui->calibrationLabel->setStyleSheet("QLabel { background-color : red; }");
}
}
else if (LimeSDROutput::MsgReportStreamInfo::match(message))
{
LimeSDROutput::MsgReportStreamInfo& report = (LimeSDROutput::MsgReportStreamInfo&) message;
@ -303,6 +313,32 @@ void LimeSDROutputGUI::updateSampleRateAndFrequency()
m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate);
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
displaySampleRate();
checkLPF();
}
// Check if LPF BW is set wide enough when down-converting using NCO
void LimeSDROutputGUI::checkLPF()
{
bool highlightLPFLabel = false;
int64_t centerFrequency = m_settings.m_centerFrequency;
if (m_settings.m_ncoEnable) {
centerFrequency += m_settings.m_ncoFrequency;
}
if (centerFrequency < 30000000)
{
int64_t requiredBW = 30000000 - centerFrequency;
highlightLPFLabel = m_settings.m_lpfBW < requiredBW;
}
if (highlightLPFLabel)
{
ui->lpfLabel->setStyleSheet("QLabel { background-color : red; }");
ui->lpfLabel->setToolTip("LPF BW is too low for selected center frequency");
}
else
{
ui->lpfLabel->setStyleSheet("QLabel { background-color: rgb(64, 64, 64); }");
ui->lpfLabel->setToolTip("");
}
}
void LimeSDROutputGUI::updateDACRate()
@ -573,6 +609,7 @@ void LimeSDROutputGUI::on_swInterp_currentIndexChanged(int index)
void LimeSDROutputGUI::on_lpf_changed(quint64 value)
{
m_settings.m_lpfBW = value * 1000;
checkLPF();
sendSettings();
}

View File

@ -73,6 +73,7 @@ private:
void setCenterFrequencySetting(uint64_t kHzValue);
void sendSettings();
void updateSampleRateAndFrequency();
void checkLPF();
void updateDACRate();
void updateFrequencyLimits();
void blockApplySettings(bool block);

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>360</width>
<height>209</height>
<height>230</height>
</rect>
</property>
<property name="sizePolicy">
@ -19,7 +19,7 @@
<property name="minimumSize">
<size>
<width>360</width>
<height>209</height>
<height>230</height>
</size>
</property>
<property name="maximumSize">
@ -831,6 +831,19 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="calibrationLabel">
<property name="toolTip">
<string>Red if calibration failed (check log for error)</string>
</property>
<property name="styleSheet">
<string notr="true">background:rgb(79,79,79);</string>
</property>
<property name="text">
<string>C</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="streamLinkRateText">
<property name="minimumSize">
@ -934,12 +947,6 @@ QToolTip{background-color: white; color: black;}</string>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ValueDial</class>
<extends>QWidget</extends>
<header>gui/valuedial.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
@ -951,6 +958,12 @@ QToolTip{background-color: white; color: black;}</string>
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDial</class>
<extends>QWidget</extends>
<header>gui/valuedial.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TransverterButton</class>
<extends>QPushButton</extends>

View File

@ -202,6 +202,7 @@ This label turns green when status can be obtained from the current stream. Usua
- **U**: turns red if stream experiences underruns
- **O**: turns red if stream experiences overruns
- **P**: turns red if stream experiences packet drop outs
- **C**: turns red if calibration fails
<h3>18: Stream global (all Tx) throughput in MB/s</h3>

View File

@ -77,6 +77,7 @@ private:
void displayTime();
void sendSettings();
void updateSampleRateAndFrequency();
void checkLPF();
void configureFileName();
void updateWithAcquisition();
void updateWithStreamData();

View File

@ -45,6 +45,7 @@ MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgGetStreamInfo, Message)
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgGetDeviceInfo, Message)
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgReportStreamInfo, Message)
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgStartStop, Message)
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgCalibrationResult, Message)
LimeSDRInput::LimeSDRInput(DeviceAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
@ -1227,19 +1228,20 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
if (doCalibration)
{
double bw = std::min((double)m_settings.m_devSampleRate, 2500000.0); // Min supported calibration bandwidth is 2.5MHz
if (LMS_Calibrate(m_deviceShared.m_deviceParams->getDevice(),
double bw = std::max((double)m_settings.m_devSampleRate, 2500000.0); // Min supported calibration bandwidth is 2.5MHz
bool calibrationOK = LMS_Calibrate(m_deviceShared.m_deviceParams->getDevice(),
LMS_CH_RX,
m_deviceShared.m_channel,
bw,
0) != 0)
{
0) == 0;
if (!calibrationOK) {
qCritical("LimeSDRInput::applySettings: calibration failed on Rx channel %d", m_deviceShared.m_channel);
}
else
{
} else {
qDebug("LimeSDRInput::applySettings: calibration successful on Rx channel %d", m_deviceShared.m_channel);
}
if (m_guiMessageQueue) {
m_guiMessageQueue->push(MsgCalibrationResult::create(calibrationOK));
}
}
if (doLPCalibration)

View File

@ -184,6 +184,25 @@ public:
{ }
};
class MsgCalibrationResult : public Message {
MESSAGE_CLASS_DECLARATION
public:
bool getSuccess() const { return m_success; }
static MsgCalibrationResult* create(bool success) {
return new MsgCalibrationResult(success);
}
protected:
bool m_success;
MsgCalibrationResult(bool success) :
Message(),
m_success(success)
{ }
};
LimeSDRInput(DeviceAPI *deviceAPI);
virtual ~LimeSDRInput();
virtual void destroy();

View File

@ -189,6 +189,16 @@ bool LimeSDRInputGUI::handleMessage(const Message& message)
return true;
}
else if (LimeSDRInput::MsgCalibrationResult::match(message))
{
LimeSDRInput::MsgCalibrationResult& report = (LimeSDRInput::MsgCalibrationResult&) message;
if (report.getSuccess()) {
ui->calibrationLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
} else {
ui->calibrationLabel->setStyleSheet("QLabel { background-color : red; }");
}
}
else if (LimeSDRInput::MsgReportStreamInfo::match(message))
{
LimeSDRInput::MsgReportStreamInfo& report = (LimeSDRInput::MsgReportStreamInfo&) message;
@ -322,6 +332,32 @@ void LimeSDRInputGUI::updateSampleRateAndFrequency()
m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate);
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
displaySampleRate();
checkLPF();
}
// Check if LPF BW is set wide enough when up-converting using NCO
void LimeSDRInputGUI::checkLPF()
{
bool highlightLPFLabel = false;
int64_t centerFrequency = m_settings.m_centerFrequency;
if (m_settings.m_ncoEnable) {
centerFrequency += m_settings.m_ncoFrequency;
}
if (centerFrequency < 30000000)
{
int64_t requiredBW = 30000000 - centerFrequency;
highlightLPFLabel = m_settings.m_lpfBW < requiredBW;
}
if (highlightLPFLabel)
{
ui->lpfLabel->setStyleSheet("QLabel { background-color : red; }");
ui->lpfLabel->setToolTip("LPF BW is too low for selected center frequency");
}
else
{
ui->lpfLabel->setStyleSheet("QLabel { background-color: rgb(64, 64, 64); }");
ui->lpfLabel->setToolTip("");
}
}
void LimeSDRInputGUI::displaySampleRate()
@ -619,6 +655,7 @@ void LimeSDRInputGUI::on_swDecim_currentIndexChanged(int index)
void LimeSDRInputGUI::on_lpf_changed(quint64 value)
{
m_settings.m_lpfBW = value * 1000;
checkLPF();
sendSettings();
}

View File

@ -72,6 +72,7 @@ private:
void setCenterFrequencySetting(uint64_t kHzValue);
void sendSettings();
void updateSampleRateAndFrequency();
void checkLPF();
void updateADCRate();
void updateFrequencyLimits();
void blockApplySettings(bool block);

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>370</width>
<height>209</height>
<width>360</width>
<height>230</height>
</rect>
</property>
<property name="sizePolicy">
@ -18,13 +18,13 @@
</property>
<property name="minimumSize">
<size>
<width>370</width>
<height>209</height>
<width>360</width>
<height>230</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>390</width>
<width>380</width>
<height>266</height>
</size>
</property>
@ -135,7 +135,6 @@
<font>
<family>Liberation Mono</family>
<pointsize>16</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
@ -248,7 +247,6 @@
<font>
<family>Liberation Mono</family>
<pointsize>12</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
@ -374,7 +372,6 @@
<font>
<family>Liberation Mono</family>
<pointsize>12</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
@ -565,7 +562,6 @@
<font>
<family>Liberation Mono</family>
<pointsize>12</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
@ -1057,6 +1053,19 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="calibrationLabel">
<property name="toolTip">
<string>Red if calibration failed (check log for error)</string>
</property>
<property name="styleSheet">
<string notr="true">background:rgb(79,79,79);</string>
</property>
<property name="text">
<string>C</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="streamLinkRateText">
<property name="minimumSize">
@ -1163,12 +1172,6 @@ QToolTip{background-color: white; color: black;}</string>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ValueDial</class>
<extends>QWidget</extends>
<header>gui/valuedial.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
@ -1180,6 +1183,12 @@ QToolTip{background-color: white; color: black;}</string>
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDial</class>
<extends>QWidget</extends>
<header>gui/valuedial.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TransverterButton</class>
<extends>QPushButton</extends>

View File

@ -195,6 +195,7 @@ This label turns green when status can be obtained from the current stream. Usua
- **U**: turns red if stream experiences underruns
- **O**: turns red if stream experiences overruns
- **P**: turns red if stream experiences packet drop outs
- **C**: turns red if calibration fails
<h3>12: Stream global (all Rx) throughput in MB/s</h3>