1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

BladeRF2 output: implemented LO soft correction

This commit is contained in:
f4exb 2018-09-30 10:59:52 +02:00
parent b5c4b532ae
commit e754dee625
7 changed files with 88 additions and 20 deletions

View File

@ -502,6 +502,25 @@ void BladeRF2Output::setCenterFrequency(qint64 centerFrequency)
}
}
bool BladeRF2Output::setDeviceCenterFrequency(struct bladerf *dev, int requestedChannel, quint64 freq_hz)
{
qint64 df = ((qint64)freq_hz * m_settings.m_LOppmTenths) / 10000000LL;
freq_hz += df;
int status = bladerf_set_frequency(dev, BLADERF_CHANNEL_TX(requestedChannel), freq_hz);
if (status < 0) {
qWarning("BladeRF2Output::setDeviceCenterFrequency: bladerf_set_frequency(%lld) failed: %s",
freq_hz, bladerf_strerror(status));
return false;
}
else
{
qDebug("BladeRF2Output::setDeviceCenterFrequency: bladerf_set_frequency(%lld)", freq_hz);
return true;
}
}
void BladeRF2Output::getFrequencyRange(uint64_t& min, uint64_t& max, int& step)
{
if (m_deviceShared.m_dev) {
@ -572,6 +591,7 @@ bool BladeRF2Output::handleMessage(const Message& message)
else // Tx buddy change: check for: frequency, gain mode and value, bias tee, sample rate, bandwidth
{
settings.m_devSampleRate = report.getDevSampleRate();
settings.m_LOppmTenths = report.getLOppmTenths();
settings.m_centerFrequency = report.getCenterFrequency();
status = bladerf_get_bandwidth(dev, BLADERF_CHANNEL_TX(requestedChannel), &tmp_uint);
@ -733,6 +753,7 @@ bool BladeRF2Output::applySettings(const BladeRF2OutputSettings& settings, bool
}
if ((m_settings.m_centerFrequency != settings.m_centerFrequency)
|| (m_settings.m_LOppmTenths != settings.m_LOppmTenths)
|| (m_settings.m_devSampleRate != settings.m_devSampleRate) || force)
{
forwardChangeOwnDSP = true;
@ -740,16 +761,8 @@ bool BladeRF2Output::applySettings(const BladeRF2OutputSettings& settings, bool
if (dev != 0)
{
int status = bladerf_set_frequency(dev, BLADERF_CHANNEL_TX(requestedChannel), settings.m_centerFrequency);
if (status < 0) {
qWarning("BladeRF2Output::applySettings: bladerf_set_frequency(%lld) failed: %s",
settings.m_centerFrequency, bladerf_strerror(status));
}
else
if (setDeviceCenterFrequency(dev, requestedChannel, settings.m_centerFrequency))
{
qDebug("BladeRF2Output::applySettings: bladerf_set_frequency(%lld)", settings.m_centerFrequency);
if (getMessageQueueToGUI())
{
int min, max, step;
@ -802,8 +815,8 @@ bool BladeRF2Output::applySettings(const BladeRF2OutputSettings& settings, bool
{
DeviceBladeRF2Shared::MsgReportBuddyChange *report = DeviceBladeRF2Shared::MsgReportBuddyChange::create(
settings.m_centerFrequency,
0,
0,
settings.m_LOppmTenths,
2,
settings.m_devSampleRate,
false);
(*itSource)->getSampleSourceInputMessageQueue()->push(report);
@ -820,8 +833,8 @@ bool BladeRF2Output::applySettings(const BladeRF2OutputSettings& settings, bool
{
DeviceBladeRF2Shared::MsgReportBuddyChange *report = DeviceBladeRF2Shared::MsgReportBuddyChange::create(
settings.m_centerFrequency,
0,
0,
settings.m_LOppmTenths,
2,
settings.m_devSampleRate,
false);
(*itSink)->getSampleSinkInputMessageQueue()->push(report);
@ -832,6 +845,7 @@ bool BladeRF2Output::applySettings(const BladeRF2OutputSettings& settings, bool
qDebug() << "BladeRF2Output::applySettings: "
<< " m_centerFrequency: " << m_settings.m_centerFrequency << " Hz"
<< " m_LOppmTenths: " << m_settings.m_LOppmTenths
<< " m_bandwidth: " << m_settings.m_bandwidth
<< " m_log2Interp: " << m_settings.m_log2Interp
<< " m_devSampleRate: " << m_settings.m_devSampleRate

View File

@ -152,6 +152,7 @@ private:
BladeRF2OutputThread *findThread();
void moveThreadToBuddy();
bool applySettings(const BladeRF2OutputSettings& settings, bool force);
bool setDeviceCenterFrequency(struct bladerf *dev, int requestedChannel, quint64 freq_hz);
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const BladeRF2OutputSettings& settings);
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);

View File

@ -217,6 +217,8 @@ void BladeRF2OutputGui::displaySettings()
blockApplySettings(true);
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
ui->LOppm->setValue(m_settings.m_LOppmTenths);
ui->LOppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1)));
ui->sampleRate->setValue(m_settings.m_devSampleRate);
ui->bandwidth->setValue(m_settings.m_bandwidth / 1000);
@ -240,6 +242,13 @@ void BladeRF2OutputGui::on_centerFrequency_changed(quint64 value)
sendSettings();
}
void BladeRF2OutputGui::on_LOppm_valueChanged(int value)
{
ui->LOppmText->setText(QString("%1").arg(QString::number(value/10.0, 'f', 1)));
m_settings.m_LOppmTenths = value;
sendSettings();
}
void BladeRF2OutputGui::on_sampleRate_changed(quint64 value)
{
m_settings.m_devSampleRate = value;

View File

@ -74,6 +74,7 @@ private:
private slots:
void handleInputMessages();
void on_centerFrequency_changed(quint64 value);
void on_LOppm_valueChanged(int value);
void on_biasTee_toggled(bool checked);
void on_sampleRate_changed(quint64 value);
void on_bandwidth_changed(quint64 value);

View File

@ -158,6 +158,52 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="LOppm_layout">
<item>
<widget class="QLabel" name="LOppmLabel">
<property name="text">
<string>LO ppm</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="LOppm">
<property name="toolTip">
<string>Local Oscillator ppm correction</string>
</property>
<property name="minimum">
<number>-20</number>
</property>
<property name="maximum">
<number>20</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="LOppmText">
<property name="minimumSize">
<size>
<width>26</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>-0.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
@ -240,13 +286,6 @@
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_freq">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="sampleRateLayout">
<property name="topMargin">

View File

@ -28,6 +28,7 @@ BladeRF2OutputSettings::BladeRF2OutputSettings()
void BladeRF2OutputSettings::resetToDefaults()
{
m_centerFrequency = 435000*1000;
m_LOppmTenths = 0;
m_devSampleRate = 3072000;
m_bandwidth = 1500000;
m_globalGain = -3;
@ -41,6 +42,7 @@ QByteArray BladeRF2OutputSettings::serialize() const
s.writeS32(1, m_devSampleRate);
s.writeS32(2, m_bandwidth);
s.writeS32(3, m_LOppmTenths);
s.writeS32(4, m_globalGain);
s.writeBool(5, m_biasTee);
s.writeU32(6, m_log2Interp);
@ -62,6 +64,7 @@ bool BladeRF2OutputSettings::deserialize(const QByteArray& data)
{
d.readS32(1, &m_devSampleRate);
d.readS32(2, &m_bandwidth);
d.readS32(3, &m_LOppmTenths);
d.readS32(4, &m_globalGain);
d.readBool(5, &m_biasTee);
d.readU32(6, &m_log2Interp);

View File

@ -22,6 +22,7 @@
struct BladeRF2OutputSettings {
quint64 m_centerFrequency;
int m_LOppmTenths;
qint32 m_devSampleRate;
qint32 m_bandwidth;
int m_globalGain;