1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

PlutoSDR input: restore full range of FIR Rx gain

This commit is contained in:
f4exb 2017-09-11 23:51:58 +02:00
parent 7fed299b97
commit 629fc9ce79
5 changed files with 40 additions and 19 deletions

View File

@ -27,6 +27,8 @@
#include "deviceplutosdrbox.h"
DevicePlutoSDRBox::DevicePlutoSDRBox(const std::string& uri) :
m_lpfFIRRxGain(0),
m_lpfFIRTxGain(0),
m_chnRx0(0),
m_chnTx0(0),
m_rxBuf(0),
@ -470,7 +472,14 @@ void DevicePlutoSDRBox::setSampleRate(uint32_t sampleRate)
m_devSampleRate = sampleRate;
}
void DevicePlutoSDRBox::setFIR(uint32_t sampleRate, uint32_t log2IntDec, uint32_t bw, int gain)
/**
* @param sampleRate baseband sample rate (S/s)
* @param log2IntDec FIR interpolation or decimation factor
* @param use Rx or Tx. Applies to the rest of the parameters
* @param bw FIR filter bandwidth at approximately -6 dB cutoff (Hz)
* @param gain FIR filter gain (dB)
*/
void DevicePlutoSDRBox::setFIR(uint32_t sampleRate, uint32_t log2IntDec, DeviceUse use, uint32_t bw, int gain)
{
SampleRates sampleRates;
std::ostringstream ostr;
@ -479,11 +488,19 @@ void DevicePlutoSDRBox::setFIR(uint32_t sampleRate, uint32_t log2IntDec, uint32_
double normalizedBW;
uint32_t intdec = 1<<(log2IntDec > 2 ? 2 : log2IntDec);
// update gain parameter
if (use == USE_RX) {
m_lpfFIRRxGain = gain;
} else {
m_lpfFIRTxGain = gain;
}
// set a dummy minimal filter first to get the sample rates right
setFIREnable(false); // disable first
formatFIRHeader(ostr, intdec, gain);
formatFIRHeader(ostr, intdec);
formatFIRCoefficients(ostr, 16, 0.5);
setFilter(ostr.str());
ostr.str(""); // reset string stream
@ -515,13 +532,12 @@ void DevicePlutoSDRBox::setFIR(uint32_t sampleRate, uint32_t log2IntDec, uint32_
// set the right filter
formatFIRHeader(ostr, intdec, gain);
formatFIRHeader(ostr, intdec);
formatFIRCoefficients(ostr, nbTaps, normalizedBW);
setFilter(ostr.str());
m_lpfFIRlog2Decim = log2IntDec;
m_lpfFIRBW = bw;
m_lpfFIRGain = gain;
// enable and set sample rate will be done by the caller
}
@ -547,10 +563,10 @@ void DevicePlutoSDRBox::setLOPPMTenths(int ppmTenths)
m_LOppmTenths = ppmTenths;
}
void DevicePlutoSDRBox::formatFIRHeader(std::ostringstream& ostr,uint32_t intdec, int32_t gain)
void DevicePlutoSDRBox::formatFIRHeader(std::ostringstream& ostr,uint32_t intdec)
{
ostr << "RX 3 GAIN " << gain << " DEC " << intdec << std::endl;
ostr << "TX 3 GAIN " << gain << " INT " << intdec << std::endl;
ostr << "RX 3 GAIN " << m_lpfFIRRxGain << " DEC " << intdec << std::endl;
ostr << "TX 3 GAIN " << m_lpfFIRTxGain << " INT " << intdec << std::endl;
}
void DevicePlutoSDRBox::formatFIRCoefficients(std::ostringstream& ostr, uint32_t nbTaps, double normalizedBW)

View File

@ -57,7 +57,8 @@ public:
bool m_lpfFIREnable; //!< enable digital lowpass FIR filter
float m_lpfFIRBW; //!< digital lowpass FIR filter bandwidth (Hz)
uint32_t m_lpfFIRlog2Decim; //!< digital lowpass FIR filter log2 of decimation factor (0..2)
int m_lpfFIRGain; //!< digital lowpass FIR filter gain (dB)
int m_lpfFIRRxGain; //!< digital lowpass FIR filter gain Rx side (dB)
int m_lpfFIRTxGain; //!< digital lowpass FIR filter gain Tx side (dB)
DevicePlutoSDRBox(const std::string& uri);
~DevicePlutoSDRBox();
@ -88,7 +89,7 @@ public:
bool getRxSampleRates(SampleRates& sampleRates);
bool getTxSampleRates(SampleRates& sampleRates);
void setSampleRate(uint32_t sampleRate);
void setFIR(uint32_t sampleRate, uint32_t intdec, uint32_t bw, int gain);
void setFIR(uint32_t sampleRate, uint32_t intdec, DeviceUse use, uint32_t bw, int gain);
void setFIREnable(bool enable);
void setLOPPMTenths(int ppmTenths);
bool getRSSI(std::string& rssiStr, unsigned int chan);
@ -111,7 +112,7 @@ private:
bool parseSampleRates(const std::string& rateStr, SampleRates& sampleRates);
void setFilter(const std::string& filterConfigStr);
void formatFIRHeader(std::ostringstream& str, uint32_t intdec, int32_t gain);
void formatFIRHeader(std::ostringstream& str, uint32_t intdec);
void formatFIRCoefficients(std::ostringstream& str, uint32_t nbTaps, double normalizedBW);
void getXO();
void setTracking();

View File

@ -322,7 +322,7 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
(settings.m_lpfFIRBW != m_settings.m_lpfFIRBW) ||
(settings.m_lpfFIRGain != m_settings.m_lpfFIRGain) || force)
{
plutoBox->setFIR(settings.m_devSampleRate, settings.m_lpfFIRlog2Decim, settings.m_lpfFIRBW, settings.m_lpfFIRGain); // don't bother with the FIR at this point
plutoBox->setFIR(settings.m_devSampleRate, settings.m_lpfFIRlog2Decim, DevicePlutoSDRBox::USE_RX, settings.m_lpfFIRBW, settings.m_lpfFIRGain);
plutoBox->setFIREnable(settings.m_lpfFIREnable); // eventually enable/disable FIR
plutoBox->setSampleRate(settings.m_devSampleRate); // and set end point sample rate

View File

@ -235,7 +235,7 @@ void PlutoSDRInputGui::on_lpFIRDecimation_currentIndexChanged(int index)
void PlutoSDRInputGui::on_lpFIRGain_currentIndexChanged(int index)
{
m_settings.m_lpfFIRGain = 6*(index > 1 ? 1 : index) - 6;
m_settings.m_lpfFIRGain = 6*(index > 3 ? 3 : index) - 12;
sendSettings();
}
@ -276,7 +276,7 @@ void PlutoSDRInputGui::displaySettings()
ui->lpFIREnable->setChecked(m_settings.m_lpfFIREnable);
ui->lpFIR->setValue(m_settings.m_lpfFIRBW / 1000);
ui->lpFIRDecimation->setCurrentIndex(m_settings.m_lpfFIRlog2Decim);
ui->lpFIRGain->setCurrentIndex((m_settings.m_lpfFIRGain + 6)/6);
ui->lpFIRGain->setCurrentIndex((m_settings.m_lpfFIRGain + 12)/6);
ui->lpFIRDecimation->setEnabled(m_settings.m_lpfFIREnable);
ui->lpFIRGain->setEnabled(m_settings.m_lpfFIREnable);

View File

@ -701,15 +701,14 @@
</item>
<item>
<widget class="QComboBox" name="lpFIRGain">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>FIR gain (dB)</string>
</property>
<item>
<property name="text">
<string>-12</string>
</property>
</item>
<item>
<property name="text">
<string>-6</string>
@ -720,6 +719,11 @@
<string>0</string>
</property>
</item>
<item>
<property name="text">
<string>+6</string>
</property>
</item>
</widget>
</item>
<item>