pothosware / SoapyPlutoSDR

Soapy SDR plugin for PlutoSDR
https://github.com/pothosware/SoapyPlutoSDR/wiki
GNU Lesser General Public License v2.1
53 stars 22 forks source link

how to set manual gain mode in python? #33

Closed taskx6004 closed 2 years ago

taskx6004 commented 4 years ago

Hi, I am a bit confused when using the qspectrumanalyzer which depends on two python deps:

And this simple and beautiful PyQt works with my PlutoSDR through this long chain of invocations:

qspectrumanalyzer -> soapypower- > simplesoapy -> SoapyPlutoSdr -> SoapySDR

What's about this issue is this line of code, which determins if PlutoSDR is in AGC or manual: gain mode settings in SoapyPlutoSDR

`void SoapyPlutoSDR::setGainMode( const int direction, const size_t channel, const bool automatic ) {

gainMode = automatic;
if(direction==SOAPY_SDR_RX){
    std::lock_guard<pluto_spin_mutex> lock(rx_device_mutex);
    if (gainMode) {

        iio_channel_attr_write(iio_device_find_channel(dev, "voltage0", false), "gain_control_mode", "slow_attack");

    }else{

        iio_channel_attr_write(iio_device_find_channel(dev, "voltage0", false), "gain_control_mode", "manual");
    }

}

}`

According to my tests in qspectrumanalyzer, setting gain values regarding to my consist sample signal, does NOT change the detected power of signal, which means, gain control does NOT work.

And,

I have a power controlled RF source to test power level of plotting, when i increase the power of the signal, the power in the plot does NOT change in the graph, however the noise floor drops!

Please correct me if my conclusion is incorrect, or misinterpreted.

I want to know how to set proper gain mode for Pluto by SoapySDR in python, please, so I can confirm if this is bug came from this quirky gain control method, which standard ways of gain mode/control didn't picked it up.

Thanks.

zuckschwerdt commented 4 years ago

Perhaps easier to shorten the chain and try a few other programs: CubicSDR, Gqrx, SDRangel. Seemingly constant level with chaning noise floor would be AGC on, right? Maybe also try the iio_attr tool to inspect and set all the values.