Browse Source

PlutoSDR: power the Rx/Tx LO up on start and down on stop

Other applications (e.g. SoapyPlutoSDR, used by gqrx) leave the RX LO
powered down when they close, so SDRangel only received the AD9361's
own noise. In FDD mode the Tx LO also stays up while no stream runs,
radiating LO leakage when the Tx device is merely opened.

Set the LO powerdown attribute explicitly: power the LO up when a
stream starts, down when it stops or fails, and power the Tx LO down
when the Tx device is opened. Applies to the input, output and MIMO
plugins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chirpmodem-v8.0.0
Michał Słomkowski 1 month ago
parent
commit
32f1111838
  1. 16
      devices/plutosdr/deviceplutosdrbox.cpp
  2. 2
      devices/plutosdr/deviceplutosdrbox.h
  3. 6
      plugins/samplemimo/plutosdrmimo/plutosdrmimo.cpp
  4. 11
      plugins/samplesink/plutosdroutput/plutosdroutput.cpp
  5. 6
      plugins/samplesource/plutosdrinput/plutosdrinput.cpp

16
devices/plutosdr/deviceplutosdrbox.cpp

@ -653,6 +653,22 @@ void DevicePlutoSDRBox::closeSecondTx() @@ -653,6 +653,22 @@ void DevicePlutoSDRBox::closeSecondTx()
if (m_txChannels.size() > 3) { disableChannel(m_txChannels.at(3), m_txMask); }
}
// Other applications (e.g. SoapyPlutoSDR) may leave an LO powered down, and the Tx LO
// stays up in FDD mode even with no stream running, so set the LO state explicitly
void DevicePlutoSDRBox::setRxLOPowerdown(bool powerdown)
{
std::vector<std::string> params;
params.push_back(std::string("out_altvoltage0_RX_LO_powerdown=") + (powerdown ? "1" : "0"));
set_params(DEVICE_PHY, params);
}
void DevicePlutoSDRBox::setTxLOPowerdown(bool powerdown)
{
std::vector<std::string> params;
params.push_back(std::string("out_altvoltage1_TX_LO_powerdown=") + (powerdown ? "1" : "0"));
set_params(DEVICE_PHY, params);
}
struct iio_buffer *DevicePlutoSDRBox::createRxBuffer(unsigned int size, bool cyclic)
{
#ifdef LIBIIO_V1

2
devices/plutosdr/deviceplutosdrbox.h

@ -93,6 +93,8 @@ public: @@ -93,6 +93,8 @@ public:
void closeTx(); //!< Close first Tx (Tx0)
void closeSecondRx(); //!< Close second Rx (Rx1)
void closeSecondTx(); //!< Close second Tx (Tx1)
void setRxLOPowerdown(bool powerdown); //!< Power down (true) or up (false) the Rx LO
void setTxLOPowerdown(bool powerdown); //!< Power down (true) or up (false) the Tx LO
int getNbRx() const { return m_rxChannels.size() / 2; }
int getNbTx() const { return m_txChannels.size() / 2; }
int getRxSampleBytes() const { return m_rxSampleBytes; }

6
plugins/samplemimo/plutosdrmimo/plutosdrmimo.cpp

@ -138,6 +138,8 @@ bool PlutoSDRMIMO::openDevice() @@ -138,6 +138,8 @@ bool PlutoSDRMIMO::openDevice()
}
}
m_plutoParams->getBox()->setTxLOPowerdown(true); // do not radiate LO leakage until Tx is started
return true;
}
@ -181,6 +183,7 @@ bool PlutoSDRMIMO::startRx() @@ -181,6 +183,7 @@ bool PlutoSDRMIMO::startRx()
}
qDebug("PlutoSDRMIMO::startRx");
m_plutoParams->getBox()->setRxLOPowerdown(false);
m_sourceThread = new PlutoSDRMIThread(m_plutoParams->getBox());
connect(m_sourceThread, &PlutoSDRMIThread::error, this, &PlutoSDRMIMO::handleError, Qt::QueuedConnection);
@ -220,6 +223,7 @@ bool PlutoSDRMIMO::startTx() @@ -220,6 +223,7 @@ bool PlutoSDRMIMO::startTx()
}
qDebug("PlutoSDRMIMO::startTx");
m_plutoParams->getBox()->setTxLOPowerdown(false);
m_sinkThread = new PlutoSDRMOThread(m_plutoParams->getBox());
connect(m_sinkThread, &PlutoSDRMOThread::error, this, &PlutoSDRMIMO::handleError, Qt::QueuedConnection);
@ -272,6 +276,7 @@ void PlutoSDRMIMO::stopRx() @@ -272,6 +276,7 @@ void PlutoSDRMIMO::stopRx()
m_plutoParams->getBox()->deleteRxBuffer();
m_plutoTxBuffer = nullptr;
m_plutoParams->getBox()->setRxLOPowerdown(true);
}
void PlutoSDRMIMO::stopTx()
@ -303,6 +308,7 @@ void PlutoSDRMIMO::stopTx() @@ -303,6 +308,7 @@ void PlutoSDRMIMO::stopTx()
m_plutoParams->getBox()->deleteTxBuffer();
m_plutoRxBuffer = nullptr;
m_plutoParams->getBox()->setTxLOPowerdown(true);
}
void PlutoSDRMIMO::handleError(int errorCode)

11
plugins/samplesink/plutosdroutput/plutosdroutput.cpp

@ -124,6 +124,8 @@ bool PlutoSDROutput::start() @@ -124,6 +124,8 @@ bool PlutoSDROutput::start()
return false;
}
m_deviceShared.m_deviceParams->getBox()->setTxLOPowerdown(false);
// start / stop streaming is done in the thread.
m_plutoSDROutputThread = new PlutoSDROutputThread(PLUTOSDR_BLOCKSIZE_SAMPLES, m_deviceShared.m_deviceParams->getBox(), &m_sampleSourceFifo);
@ -172,6 +174,10 @@ void PlutoSDROutput::stop() @@ -172,6 +174,10 @@ void PlutoSDROutput::stop()
delete m_plutoSDROutputThread;
m_plutoSDROutputThread = nullptr;
}
if (m_deviceShared.m_deviceParams && m_deviceShared.m_deviceParams->getBox()) {
m_deviceShared.m_deviceParams->getBox()->setTxLOPowerdown(true);
}
}
void PlutoSDROutput::handleError(int errorCode)
@ -193,6 +199,10 @@ void PlutoSDROutput::handleError(int errorCode) @@ -193,6 +199,10 @@ void PlutoSDROutput::handleError(int errorCode)
m_plutoSDROutputThread = nullptr;
}
if (m_deviceShared.m_deviceParams && m_deviceShared.m_deviceParams->getBox()) {
m_deviceShared.m_deviceParams->getBox()->setTxLOPowerdown(true);
}
const QString errorMessage =
tr("Radio needs a restart: %1 (%2)")
.arg(strerror(-errorCode))
@ -398,6 +408,7 @@ bool PlutoSDROutput::openDevice() @@ -398,6 +408,7 @@ bool PlutoSDROutput::openDevice()
}
m_plutoTxBuffer = plutoBox->createTxBuffer(PLUTOSDR_BLOCKSIZE_SAMPLES, false); // PlutoSDR buffer size is counted in number of (I,Q) samples
plutoBox->setTxLOPowerdown(true); // do not radiate LO leakage until started
return true;
}

6
plugins/samplesource/plutosdrinput/plutosdrinput.cpp

@ -124,6 +124,8 @@ bool PlutoSDRInput::start() @@ -124,6 +124,8 @@ bool PlutoSDRInput::start()
return false;
}
m_deviceShared.m_deviceParams->getBox()->setRxLOPowerdown(false);
// start / stop streaming is done in the thread.
m_plutoSDRInputThread = new PlutoSDRInputThread(PLUTOSDR_BLOCKSIZE_SAMPLES, m_deviceShared.m_deviceParams->getBox(), &m_sampleFifo);
@ -173,6 +175,10 @@ void PlutoSDRInput::stop() @@ -173,6 +175,10 @@ void PlutoSDRInput::stop()
delete m_plutoSDRInputThread;
m_plutoSDRInputThread = nullptr;
}
if (m_deviceShared.m_deviceParams && m_deviceShared.m_deviceParams->getBox()) {
m_deviceShared.m_deviceParams->getBox()->setRxLOPowerdown(true);
}
}
void PlutoSDRInput::handleError(int errorCode)

Loading…
Cancel
Save