-
Notifications
You must be signed in to change notification settings - Fork 15
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
Bandwidth stuck at 200kHz #66
Comments
John, let's start from the problem with the bandwidth. In SoapySDRPlay3 the bandwidth is determined by the sample rate; this is to avoid problems with aliasing if you set the bandwidth wider than the sample rate (because of the Nyquist theorem). I am not sure what value of sample rate and decimation you are using, but I would suggest to try a quick test with sample rate = 2MHz and decimation = 1 to see if the bandwidth gets set correctly at 1536kHz (instead of 200kHz). Franco |
Franco…..Thanks for the quick reply. I thought you guys would still be in bed!!!
I may have misled you with the term bandwidth……I am actually getting the bandwidth on the spectrum screen that I expect for the given sample rate and decimation combination. What I have is a 200kHz hump in the middle of that bandwidth where the receiver works fine. Outside of that it gets progressively deafer until it hears nothing.
This is what I did to test the software/hardware combination. I fired up GQRX first and the default values are 2Msps, Decimation = None (ie 1) and IFGR = 50 and RFGR = 0. This gives a plot that has a hump about 200kHz wide (at -80dBm) in the middle of the 1MHz spectrum plot (at -120dBm elsewhere). Not the approximately 2MHz of signal across the entire 2MHz displayed on the GQRX screen that I was expecting. Adjusting the RFGR = 4 brings the hump noise floor down to about -100dBm…..The rest stays at -120dBm. Inside the 200kHz it receives fine.
I have played with various combinations of Sample Rates up to 10Msps and down to 500ksps (I think)…..and various Decimations (mostly around 4-16 but some higher). As expected the bandwidth on the 5Msps ~= 5MHz of BW. On 8Msps = 8MHz or BW. All with this 200kHz wide hump in the middle. If I put in 8Msps and Dec = 8 then I get ~1MHz BW with a 200kHz hump in the middle. At low sample rates (ie 125ksps) the hump is not visible and the bandwidth is only 125kHz wide.
All of these tests were done with GQRX 2.15.9. I tried a few similar things in GNURadio using the SoapySDRPlay source with similar results.
Out of interest……Your test of Sample Rate = 2Msps and Dec = 1 (ie none) gives me a bandwidth of 2MHz…..not the 1.536MHz you suggest. Looking at the code I can see where it gets set to 200kHz if the ‘output_sample_rate < 300000’ and works its way through the various combinations up to 8Msps. Basically the setting of the spectrum bandwidth seems to be working. It seems more like a filter on the RF side of things.
One of the things I noted when I do a SoapySDRUtil –probe=”driver=sdrplay” is that the last line after the Sample Rates report is the Filter Bandwidths…..the lowest of these is 0.2 MHz. I cannot see where they are coming from and how they are used. Is there something in this area that may be limiting the RF bandwidth within the displayed spectrum bandwidth?
By the way I have a second RSPdx that does the same thing on linux. They work fine with SDR-Console.
Appreciate you looking in this and offering any help. If I can get it all working my next step is to see if I can get the recipe process working for Ryan Volz’s radioconda.
John – VK4JBE
|
John, it's about 10:30pm here in Florida, so I am about to go to bed now LOL Anyway since you are saying the problem happens with GNU Radio too, do you mind attaching here the .grc file you used and the screenshot that shows that hump? This way I can try to reproduce it here with my RSPdx. As per the bandwidth when the sample rate is set to 2MHz, you are 100% correct: it should be 2MHz, not 1536kHz. Franco K4VZ |
Franco.....Here are the files you requested. I have put the .grc file in a .zip file because github did not seem to like that extension. Also attached is a screen dump of my .grc running. You can clearly see the hump in the middle of the passband.
[SDRPlay_RSPdx_Rxer.zip](https://github.com/pothosware/SoapySDRPlay3/files/10857082/SDRPlay_RSPdx_Rxer.zip)
![image](https://user-images.githubusercontent.com/110154091/222044133-60e7b404-1c05-472e-ba72-4f2d5753f385.png)
Hope this provides some clues. Meantime I will continue my digging.
John - VK4JBE
|
Franco....I have been doing a bit more digging in the Settings.cpp file.
I can see that in the Bandwidth API section the setBandwidth() function (L937-L952) calls the sdrPlayGetBwMhzEnum() function (L945). Looking at the code for the sdrPlayGetBwMhzEnum() function I can see that the default if it fails to match an 'output_sample_rate' is to set the return value to 'sdrplay_api_BW_0_200'. I assume this sets the filter bandwidth to 200kHz (but I am only guessing).
The setBandwidth() parameter 'bw_in' is passed straight to the sdrPlayGetBwMhzEnum() function with no validation so that if the setBandwidth() function passed an invalid bandwidth then it would always fail to 200kHz.
I note the sdrPlayGetBwMhzEnum() function and the getBwEnumForRate() function are similar in that they take in a sample_rate and both return the 'sdrplay_api_BW_x_yyy' constant. The getBwEnumForRate() function has advantage that if you put in an invalid value it will select the most appropiate 'sdrplay_api_BW_x_yyy' constant (ie put in 2Msps and it will give 1.5356MHz). I note that is what you originally expected for a 2Msps sample rate. Is that a clue!!!!
All of this leads me to suspect that line 945 of the setBandwidth() function should use the failsafe getBwEnumForRate() rather than the sdrPlayGetBwMhzEnum() which can only deal with valid sample rates.
Is my logic correct? Is this a possible source of the error?
That said .....I think I am feeding it valid sample rates from GQRX and GNURadio so I am not sure why it is failing and I can’t find what feeds the setBandwidth() function to check that out. In GNURadio I did try casting the sample rate value as a float() and an int() but it did not change things.
I might also try and set up a new VM on my VirtualBox machine and make the changes to the code and see what difference it makes. I am not very confident in c++ compiling (or coding) so I may quickly hit the wall of knowledge (or lack of!!!)
One further bit of info is that I recalled that I had a RPi with a PiSDR image on it that supports the SDRPlay devices. I tried the RSPdx in that RPi and fired up GQRX and it did the same thing as my laptop and VM. That image was precompiled so it suggests that the process of compiling the code on my laptop and VM is ok. The other alternative is that both my RSPdx's are the issue. I bought them about 1 year apart so you would think that is not the case....plus one device at least runs ok on SDR-Console on windows. I have not tried the other device.
Hope this provides some clues that may mean more to you.
John – VK4JBE
|
Excellent detective work John! I read your comment and looked at the code, and I think you're right that the function Unfortunately I have to start work in a few minutes, so perhaps in the meanwhile you could change just that line in Tonight after work I'll try the same thing (before and after the change), and if everything looks OK, I'll commit this change in the code. Franco K4VZ |
Franco... Hope you had a productive day at work. I think I see some sense in this now.
I did as you suggested and built a new VM with radioconda and recompiled the SoapySDRPlay3 with the suggested changes. I also have a separate VM with the original SoapSDRPlay3 (without the changes). This makes it easy to compare the new version with the old version.
I initially tested the new version with GQRX and it did not seem to make any changes. I had the default values. Sample Rate = 2Msps Decimation = None (ie =1) and Bandwidth = 0.00000MHz.
In GQRX I had a Display Bandwidth of 2MHz (ie equal to the sample rate) and a RF Signal Bandwidth of 200kHz (the hump). I then set the GQRX bandwidth to 2MHz and got a much wider signal. As it turned out it was the 1.536MHz that was in your mind. I played with a few different settings and combinations and found that it is important to set the Bandwidth in GQRX. If you leave the Bandwidth = 0.000MHz then you get 200kHz. Basically the available bandwidths are those that you get when you run SoapySDRUtil --probe="driver=sdrplay".
I flipped over to the old SoapySDRPlay VM and ran GQRX again. Here I found that if you did not set the Bandwidth to one of the valid RF Bandwidths then you got 200kHz of RF Bandwidth. Playing around with combinations I found that provided you set a valid Bandwidth and you set a Sample Rate that was faster than the Bandwidth and you could get the correct RF bandwidth to display.
It is worthy of note that the GQRX Sample Rate sets the Display Bandwidth and that the Bandwidth sets the RF Bandwidth of the signal within the display.
It is also worthy of note that the SDRPlay sample rates only partially match the RF Bandwidths. Most people would probably set the RF Bandwidth = Sample Rate (aka Display Bandwidth) or leave it at 0.0MHz as I did initially.
SDRPlay Valid Sample Rates (ksps): 62.5, 96, 125, 250, 384, 500, 768, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000
SDRPlay Valid RF Bandwidths (kHz): 200 300 600 1536 5000, 6000, 7000, 8000
The beauty of the change in the new VM is that if you set a non-valid Bandwidth it selects the next lowest valid Bandwidth. That does not help people who leave the GQRX Bandwidth = 0.0Mhz. That will always be set to 200kHz.
I think if you are doing satellite work like I am you want a pass band of about 600kHz or maybe 1.536MHz to see the segment of interest for a satellite with a linear transponder, a CW beacon and telemetry. If you are looking at large chunks of bandwidth then 5-8MHz is the go.
I note that setting the Bandwidth value in the GNURadio Soapy SDRPlay Source also fixes the problem. I had not done that in the .grc I sent you.
I suggest that you deploy the change to make it a little more goose proof. I am not familiar with Wiki's but it may be worthwhile adding a note about this to the SoapySDRPlay3 wiki. I am happy to write the words if you want.
John - VK4JBE
|
@vk4jbe - thanks for making the change and confirming that it solves the problem. Tonight I too ran your GNU Radio flowgraph with the original code from the I created a new branch called When you have time, try building SoapySDRPlay3 using the code from the new branch Finally, if you are doing advanced work in GNU Radio using your RSPdx's, you may want to consider the 'gr-sdrplay3' OOT module that I wrote specifically for the SDRplay RSPs (https://github.com/fventuri/gr-sdrplay3) to use them as native GNU Radio sources. Franco K4VZ |
Great information. I have some sdrplay equipment, but hadn’t noticed this before. Once it’s in main I’d like to build it into a deb package and test a deployment upgrade over apt. |
Franco......thanks for validating the changes and for all the extra info. I have been doing some family things for the last few days but last night managed to download the new branch and compile it. All ok on my system.
Emboldened by my success at compiling a one line change (LOL) I thought I might have a go at putting in a warning message if the user forgets to set the bandwidth or makes it a value less than 200kHz.
In the getBwEnumforRate() function I changed the first line of the function from this....
if (output_sample_rate < 300000) return sdrplay_api_BW_0_200;
to this.....
if (output_sample_rate < 200000)
{
SoapySDR_log(SOAPY_SDR_WARNING, "Bandwidth < 200000 is not valid! Setting Bandwidth to 200kHz.");
return sdrplay_api_BW_0_200;
}
else if (output_sample_rate < 300000) return sdrplay_api_BW_0_200;
I tested that and it worked fine.....Whilst not 100% fool proof it at least it points people in the right direction if they get that funny hump in the middle of there spectrum display.
If you feel like some more cosmetic changes I would suggest a minor change to the naming of the getBwEnumforRate(output_sample_rate) and getBwValueFromEnum(bwEnum) functions would make the code a little more readable for us newbies.
These two functions convert a BwEnum to BwValue and vice versa. However, the name getBwEnumforRate() and the input parameter 'output_sample_rate' suggest it is about converting sample rates when in fact it is about converting a bandwidth value. The getBwValueFromEnum(bwEnum) function about converting an enumeration is almost correct. Just a minor name change for consistency.
Can I suggest the following minor name changes..
getBwEnumforRate(output_sample_rate) => getBwEnumforBwValue(bwValue) .......and parameter 'output_sample_rate' => 'bwValue'
getBwValueFromEnum(bwEnum) => getBwValueFromBwEnum(bwEnum).......the parameter ‘bwEnum’ is clearly named.
There are some changes in SoapySDRPlay.hpp on L260 and L262 and some changes is the Settings.cpp on L739, L943, L945, L960 and of course the two functions. I have made these changes and they seem to work. If you feel inclined to make these changes in a the new branch I will test them out for you.
I have also written some words to update the wiki. I will post those separately. PS: I must learn how to markup in github.
John - VK4JBE
|
Franco – Attached is my suggested wording for the SoapySDRPlay3 wiki. I have tried to make it cover the current version and your new branch. Feel free to modify, update, correct as necessary.
I am not familiar enough with the Github system to add that to the wiki so if you are able to update it I would appreciate it.
<snip>
Soapy SDRPlay3 Sample Rates and Bandwidths:
The SDRPlay RSP series have a range of preferred Sample Rates and a separate range of valid Bandwidths. The bandwidth is actually the bandwidth of the IF filter. If you are using SDRPlay RSP’s with SoapySDR to interface to programs like GQRX and GNURadio it is important to set a valid Bandwidth along with an appropriate Sample Rate (preferably a Preferred Sample Rate).
Preferred Sample Rates (ksps):
62.5, 96, 125, 192, 250, 384, 500, 768, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000
Valid Bandwidths (kHz):
200 300 600 1536 5000, 6000, 7000, 8000
In both GQRX and GNURadio the width of the spectrum displayed is set by the Sample Rate parameter (or the Input Rate in combination with the Decimation parameter). Within that displayed spectrum the bandwidth of the RF signal that is displayed is set by the Bandwidth parameter which controls the IF filters.
Until SoapySDRPlay3 is updated it is best to select a preferred Sample Rate and then select the next lowest valid Bandwidth. For example, Sample Rate = 2Msps, Decimation = None and Bandwidth = 1.536MHz. If you select an invalid Bandwidth, or leave it at 0.00MHz, it will default to 200kHz and you will see a 'hump' of signal in the middle of the displayed spectrum.
When SoapySDRPlay3 is updated you will be able to put in any Bandwidth and it will automatically convert that to the next lowest valid Bandwidth. For example, Sample Rate = 2Msps, Decimation = None and Bandwidth = 2MHz will be converted automatically to Bandwidth = 1.536MHz. If you leave the Bandwidth = 0.0MHz then the bandwidth will default to 200kHz.
The above information applies to the RSP1A, RSP2, RSP2pro, RSPduo and RSPdx devices.
Note that you can use sample rates other than the Preferred Sample Rates but they are so are not as efficient.
</snip>
John – VK4JBE
|
John, thanks for your feedback and hard work! Tonight I took a quick look at
The variable If I remember correctly the problem you observed with gqrx was that the application was attempting to set a bandwidth of 0Hz, which is definitely an invalid value. Perhaps we may want to consider to have a similar warning if the argument for I might not be able to work on this issue for the next couple of days due to my schedule, but Wednesday night I should be able to answer your comments and discuss this with you. Franco K4VZ |
No problems Franco and no rush. I appreciate you bearing with me on this.
I now understand what it going on and what I need to do to get it working on my system. My only reason for pursuing it is so others don’t fall into the same trap.
Thanks for the other info….I have been having a bit of a look at that.
John – VK4JBE
|
John, this morning I ran gqrx (all my tests were done with GNU Radio so far), and I noticed that if you hover on the bandwidth selection box it says "Analog bandwidth (leave at 0 for default)". I then added a log statement in the Because of the special meaning that gqrx gives to the value 0, I thought that it might be a good idea to change the function I also refactored I left temporarily that log statement in In the next few days I also want to validate these changes with CubicSDR, to make sure they don't introduce problems or unexpected behavior there; CubicSDR is kind of how the whole SoapySDRPlay3 module started, and I use CubicSDR as the reference SDR client application for SoapySDRPlay3 (I also think there's a significant number of users running CubicSDR). Please try the latest changes from the Franco K4VZ |
Franco….Interestingly enough I have done some similar things. I actually put log statements in various places in both For some odd reason the The next thing I observed was that if the Bandwidth = 0.0MHz in the menu then If the Bandwidth value in the menu is a valid value then the I am not sure if you have noticed this behaviour. GNURadio on the other hand is much simpler. It calls both I have played with the Settings.cpp code to make it a bit more foolproof with the only area that is still not resolved in GQRX is the Bandwidth = 0.0MHz. It sets an incorrect value due to the odd calculation of the I will have a look at your refactored code and run it up to see if it does what I expect. I might also add I have never used CubicSDR, but have heard it mentioned plenty of times. I guess I am used to the tight integration between GQRX and GPredict for satellite work. I actually use SDR-Console on Windows for most of my satellite voice comms. That is a great program. I am trying to develop a setup for digital satellite work and experimentation using Linux…..hence getting the RSPdx working. Thanks for your efforts on this. John – VK4JBE |
John, whe I ran gqrx this morning I too noticed the call to
Since gqrx uses the GNU Radio OOT module gr-osmocom to talk to SoapySDR and therefore to this module SoapySDRplay3, I suspect that that 75% comes from this line (https://github.com/osmocom/gr-osmosdr/blob/master/lib/soapy/soapy_source_c.cc#L326):
Also since 0 as a bandwidth selection does not make much sense per-se (an ideal filter with a bandwidth = 0Hz wouldn't let any signal through), I think it is OK to accept that that specific value actually means "set the bandwidth to a reasonable default value", as gqrx seems to expect (but I need to double check that other programs like CubicSDR don't make different assumptions for that value). Franco K4VZ |
@franco I have tested your latest new branch and it is giving the bandwidth settings you would expect in both GNURadio and GQRX for all combinations of sample rate and bandwidth. Perfect. Thank you. I had played with trying to use the existing Your I am not sure if leaving the log statement in will confuse GQRX users and cause questions or not. Perhaps it might be more instructive if it showed the Sample Rate and the Bandwidth. I am happy to see you merge that into the main/master branch. Thanks for all your work on this. John – VK4JBE |
Franco. That explains the weird John - VK4JBE |
John, I just removed that log statement; since I didn't know know you already had done something similar, I added it temporarily to show you what happens. As per SoapySDRPlay3, since it is a general purpose module that can be used by many different SDR applications in the context of the SoapySDR framework, it is sometimes difficult for me to 'forecast' how an application will be using a method like On the other side, it is also hard if not impossible for a client application like gr-osmosdr to know the best thing to do; for instance the author of gr-osmosdr had the good intention of making the bandwidth a little less of the sample rate to prevent aliasing problems; they didn't know/realize that in the specific case of the SDRplay RSPs the selectable bandwidths are only a limited set of values, and in the case of a sample rate of 2Msps, 75% of that is 1500kHz, and the I plan to run some tests with CubicSDR tonight after work; if everything works OK, then I'll merge these changes into the Franco K4VZ |
Franco, I am happy to test the If I am reading this right it seems like updating the wiki is really just an update to the README.md file with the appropriate markup (or is it markdown) for formatting. Can it be that simple!! John - VK4JBE |
John, good news; it looks like in CubiCSDR the method
so these changes to I just merged the Franco K4VZ |
Will do Franco. Edit: Just downloaded the new SoapySDRPlay3 from master. Install worked fine. Running GNURadio and GQRX with a variety of combinations of Sample Rate and Bandwidth including bandwidth = 0.0MHz and non-standard values (ie 3Mhz) as well as standard values (300kHz, etc) and it all seems to be working as expected. Great work. John - VK4JBE |
People,
I am wondering of someone can help me with my SoapySDR / SDRPlay3 / SDRPlay RSPdx install. I have successfully installed the SDRPlay 3.07 API, Ryan Volz's radioconda and compiled the pothosware SoapySDRPlay3 0.8 library on a Ubuntu 22.04 system. The SDR is receiving signals fine with both GQRX and GNURadio but the bandwidth seems stuck on 200kHz and the device seems to be stuck in AGC = on mode.
Looking at the pothosware/SoapySDRPlay3 github site I have checked out the SoapySDRPlay.hpp and settings.cpp files and it appears from the comments that the default bandwidth is 200khz (although I can't actually see where this is set in code). The code to change that is in internal functions that appear to be part of the Sample Rate API in the settings.cpp.
I have also noticed that the I get a "Not updating IFGR gain because AGC is enabled" warning when I try to change the IFGR in GQRX. Once again AGC = on seems to be the default. In GQRX the AGC flag is not ticked but the error still occurs.
I have been digging through the c++ source code to see if I can figure it out but unfortunately I am not familiar enough with c++ to debug this stuff.
I am wondering if anybody else has noticed this and has a fix or has enough familiarity with the code to track the issue through.
John - VK4JBE
The text was updated successfully, but these errors were encountered: