Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interfacing SoapySDRPlay with rx_tools (RSPDuo) #67

Open
dhollosi opened this issue Apr 11, 2023 · 7 comments
Open

Interfacing SoapySDRPlay with rx_tools (RSPDuo) #67

dhollosi opened this issue Apr 11, 2023 · 7 comments
Assignees

Comments

@dhollosi
Copy link

Hi everyone,

Not sure if this is the right thread but I would appreciate any help on my issue!

I have managed to acquire raw IQ data from the Tuner 1 (in Single Tuner mode) with the following command:

./rx_sdr -d "driver=sdrplay" -a "Tuner 1 50 ohm" -f 1600M -s 2M -I CS16 -F CS16 -t rfgain_sel=0 test_iq.raw

I was however hoping to be able to do the same with the Tuner 2 (the one that has the bias T) with the following command:

./rx_sdr -d "driver=sdrplay" -a "Tuner 2 50 ohm" -f 1600M -s 2M -I CS16 -F CS16 -t rfgain_sel=0,biasT_ctrl=true test2_iq.raw

But the outputted data is unusable - I suspect it is still using Tuner 1 (which doesn't have my antenna connected to it). Strangely enough, the bias T still manages to power my LNA..

As an added benefit, I was hoping to use both tuners in Dual Tuner mode with rx_tools but after having got lost in the api documentation, I am unsure how to reach this goal (if possible).

Furthermore, I am struggling to understand how one can select the bandwidth given an inputted sample rate (e.g 2 MSPS).

Kind regards,
Dimitri

@fventuri
Copy link
Collaborator

Dimitri, thanks for reporting the problem.

I was able to reproduce it here using rx_sdr, however with CubicSDR I am able to use either Tuner 1 50 ohm and Tuner 2 50 ohm to receive a station without any problem, so right now I am not really sure what's going on. I am going to look into it tonight after work, and let you know what I find out.

As per the using both tuners, you have two options:

  • if you just want two independent receivers, you can use your RSPduo in master/slave mode, i.e. start one instance of rx_sdr in master mode and after that, launch a second instance of rx_sdr in slave mode
  • if you instead want to run something like diversity reception where the two streams need to be synchronized, you have to use dual tuner mode, but I am afraid rx_sdr has no way to write to two outputs (or to some sort of interleaved I/Q stream)

I just looked at the code for rx_sdr, and I couldn't find the word bandwidth or bw anywhere, so I suspect there's no way of controlling it using rx_sdr.

A few months ago I wrote a couple of I/Q 'recorders' for the SDRplay RSPs, both in single tuner mode and in dual tuner mode, that use the SDRplay API directly (without using SoapySDR and SoapySDRPlay3); you can find them here:

The dual tuner one creates two files (one for channel A and one for channel B), where the I/Q samples are synchronized, which should allow you to combine them as you like.

Franco

@fventuri fventuri self-assigned this Apr 11, 2023
@dhollosi
Copy link
Author

dhollosi commented Apr 12, 2023

Hi Franco, thanks for your answer.

Indeed, I am also able to get the desired functionalities on CubicSDR but not from rx_sdr. In my specific case, I wish to use both Tuner 1 and Tuner 2 but at different frequencies to acquire raw IQ data (approx. 2 MHZ bandwidth each would cut it). I now realise my previous example didn't really explicit that.

I spent some time last night testing our your scripts, and although they are very useful I am missing some features for my application. I checked out the .c script briefly but would need to spend more time adding:

  • antenna selection (Tuner 1 or 2) in the single-tuner-experiments
  • bias T selection (for Tuner 2)
  • frequency differentiation for both tuners in dual-tuner-experiments (i.e not the same frequency for both channels). The synchronisation aspect is great though!

I'm still playing around with them and will get back to you if I find a workaround to reach my (ambitious) goal.

Thanks,
Dimitri

@fventuri
Copy link
Collaborator

Hello Dimitri, I think I figured what is causing the problem with rx_sdr but CubicSDR works just fine.

With rx_sdr the order of commands sent to the SoapySDRPlay3 module is roughly this:

  • setFrequency() - which tunes to say 1600MHz
  • setAntenna() - which switches from the antenna Tuner 1 50 ohm to the antenna Tuner 2 50 ohm

With the RSPduo switching antenna from one tuner to the other requires a reconfiguration of the RSPduo using sdrplay_api_ReleaseDevice() and sdrplay_api_SelectDevice(); the problem is that sdrplay_api_SelectDevice() resets the device and tuner parameters to the default values, including the tuner frequency that ends up being 200MHz.

This morning I changed the code for this specific case (i.e. where the antenna/tuner is changed while the device is not yet streaming) so that all the device and tuner parameters are saved before the release/select API calls, and they are restored afterwards. I also ran a quick test, and rx_sdr seems to be working correctly here with the antenna set to Tuner 2 50 ohm.

I just pushed the code to the new branch copy-device-and-tuner-config (https://github.com/pothosware/SoapySDRPlay3/tree/copy-device-and-tuner-config); please give it a try, and let me know if it works for you too.

Tonight and in the next couple of days I'll run some more extensive tests with CubicSDR and a couple of other SDR applications to make sure everything still works as expected; if there are no unexpected consequences, I'll then merge the change into the master branch.


Regarding the I/Q recorders from the single-tuner-experiments and dual-tuner-experiments repositories, they started just as toy programs to play around with the different settings of the RSPduo and the other RSPs, but adding antenna selection and the option to enable biasT shouldn't be too hard; I can give it a try this weekend, when I have more spare time.
The frequency differentiation (along with other tuner related settings) should already be available in the I/Q recorder in dual-tuner-experiments: just set the frequency argument -f as freq1,freq2, for instance: -f 1600e6,1420e6.

Franco

@dhollosi
Copy link
Author

Hello Franco,

I tried with the latest pull but nothing has changed on my side. I even re-installed SoapySDR and SoapySDRPlay3 from scratch but no success yet.

Will look more into it this afternoon and get back to you.

Dimitri

@fventuri
Copy link
Collaborator

Dimitri,
to make sure you are using the latest version from the copy-device-and-tuner-config branch, and that your problem too is caused by switching tuner from Tuner 1 to Tuner 2 like I saw here, can you please add this log line right before the changes I made (i.e. right before this line: https://github.com/pothosware/SoapySDRPlay3/blob/copy-device-and-tuner-config/Settings.cpp#L345):

    SoapySDR_log(SOAPY_SDR_INFO, "about to switch tuner - saving and then restoring settings");

Then rebuild and reinstall the SoapySDRPlay3 module; once you run rx_sdr and set it to use the antenna Tuner 2 50 ohm, you should see that info message in the terminal; if you don't, then we have to figure out what's different between my setup here and yours.

Franco

@dhollosi
Copy link
Author

dhollosi commented Apr 20, 2023

Hi Franco,

I apologise for the lack of response, work got a bit hectic since the end of last week.

I re-installed SoapySDRPlay3, checked out the new branch, built and installed it.

Thank you very much for your help, everything works like a charm now (even with the BiasT)! As far as I'm concerned, you could proceed with the merge to the main branch.

I'm still a little unclear on how to use the rx_sdr in Master/Slave mode but will take a closer look.

All the best,
Dimitri

@fventuri
Copy link
Collaborator

Dimitri,
you are in good company about having a hectic week at work!
Anyway thanks for trying it out and making sure thst rx_sdr now works as expected; I just merged that change into the master branch.

Franco

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants