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

Sample rates between 25e6/48 and 25e6/12 don't work #31

Closed csete closed 4 years ago

csete commented 4 years ago

Hi,

I noticed that sample rates between 25e6/48 and 25e6/12 don't work. I found the answer in the Linux IIO driver notes, which states that:

The minimum ADC rate is 25MSPS. Baseband rates below 2.083 MSPS (25MSPS/12) require FIR decimation/interpolation to be set. In other words the FIR filter needs to be configured and enabled. The minimum baseband rate with the FIR filter (decimate by 4) enabled is: 25MSPS /(4*12) = 520.83 kSPS.

I think it requires manually setting FIR filter taps, though I am not sure. I didn't have time to play around with it.

Rates below 25e6/48 seem to work the way it is currently handled in the code.

zuckschwerdt commented 4 years ago

If I read that right we have three decimation/interpolation stages and the FIR stage. The decimation/interpolation can be 2,bypass at two stages and one stage with 3,2,bypass. The FIR can be 4,2,1,bypass. The ADC/DAC minimum rate is 25 MHz.

Without enabling the decimation/interpolation of the FIRs we can go down to 25M/12 = 2.083 MSps. Then we scale by 8, thus should be able to go down to 25M/12/8 = 260.417kSps without needing a FIR. I guess we should set the threshold to 25e6/12.

I did some tests with

iio_attr --auto -d ad9361-phy tx_path_rates
iio_attr --auto -o -c ad9361-phy voltage0 sampling_frequency [<rate>]
iio_attr --auto -o -c cf-ad9361-dds-core-lpc voltage0 sampling_frequency [<rate|rate/8>]

which will accept lower rates (down to 25M/48 and 25M/48/8) but those will enable FIR and probably not work without loading a FIR.

mndza commented 4 years ago

Hi,

I think there is a some missing information here: when libad9361-iio is available the FIR filter taps are automatically loaded when setting sample rates down to 25e6/48 by calling ad9361_set_bb_rate. Otherwise, these sample rates need the user to set the taps manually.

zuckschwerdt commented 4 years ago

@csete were you missing libad9361-iio in your tests?

csete commented 4 years ago

@zuckschwerdt I probably did. Should libad9361-iio be installed before libiio or just before SoapyPlutoSDR?

csete commented 4 years ago

I meant to say "I probably did not have libad9361-iio installed"

zuckschwerdt commented 4 years ago

It just needs to be around when SoapyPlutoSDR is compiled. cmake should show e.g.

Found libad9361: /usr/local/lib/libad9361.so (found version "0.2")

Could you test e5313e0 again (git checkout e5313e0)? Current master circumvents the FIR from libad9361 :/

csete commented 4 years ago

Thanks for the clarification. I'm still a bit confused about what is lower sample rate limit without libad9361-iio, though it seems that I can now go below 25e6/48 without having libad9361-iio installed.

Here is the output of SoapyPlutoSDR cmake (latest master):

alc@solaris:~/sdr/src/soapy-plutosdr.git/build$ cmake .. -L -- LIBIIO_INCLUDE_DIRS: /home/alc/sdr/runtime/include -- LIBIIO_LIBRARIES: /home/alc/sdr/runtime/lib/libiio.so -- LIBIIO_DEFINITIONS: -- Could NOT find libad9361 (missing: LIBAD9361_LIBRARY LIBAD9361_INCLUDE_DIR) -- Module PlutoSDRSupport configured with version: 0.2.0-c88b7f5 -- Configuring done -- Generating done -- Build files have been written to: /home/alc/sdr/src/soapy-plutosdr.git/build -- Cache values CMAKE_BUILD_TYPE:STRING=release CMAKE_INSTALL_PREFIX:PATH=/home/alc/sdr/runtime LIB_SUFFIX:STRING= SOAPY_SDR_INCLUDE_DIR:PATH=/home/alc/sdr/runtime/include SOAPY_SDR_LIBRARY:FILEPATH=/home/alc/sdr/runtime/lib/libSoapySDR.so SoapySDR_DIR:PATH=/home/alc/sdr/runtime/share/cmake/SoapySDR

Both the SoapySDRUtil transfer test and the spectrum shown with a simple GNU Radio 3.8 / gr-soapy test script shows that I can use both 1, 2, and 3 MSPS with the current master

1 MSPS: plutosdr-1MSPS

2 MSPS: plutosdr-2MSPS

3 MSPS: plutosdr-3MSPS

csete commented 4 years ago

And, by the way, thanks for the fix!

zuckschwerdt commented 4 years ago

Ok, the fix works but isn't great if we have libad9361. I'll make it conditional to use the old behaviour when libad9361 is there, otherwise the current one.