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

SDRplay support? #422

Closed
frameshift18 opened this issue Nov 23, 2020 · 10 comments
Closed

SDRplay support? #422

frameshift18 opened this issue Nov 23, 2020 · 10 comments

Comments

@frameshift18
Copy link
Contributor

Been poking around trying to get my old SDRplay to work with TR. After all the SoapySDRplay set up it seems the gain settings on the SDRplays are quite different than the RTL based SDRs. I have got TR running with my SDRplay but TR never finds the control channel. I'm thinking not being able to modify the various gain settings is the culprit. It does work with CubicSDR correctly though so I feel I have the driver and Soapy set up correctly.

I think this could be an easy fix if all we have to do is pass the correct gain settings to osmosdr/Soapy.

I would be happy to troubleshoot and test..

@frameshift18
Copy link
Contributor Author

frameshift18 commented Nov 23, 2020

After messing with the PPM adjustment I do get good decode in TR. Seems without explicitly setting the gain values it goes in to AGC mode. The two "gains" of interest are IFGR (IF gain reduction) and RFGR (RF gain reduction).

Soapy SDR -- the SDR abstraction library
Probe device driver=sdrplay
[INFO] devIdx: 0
[INFO] hwVer: 1

-- Device identification
  driver=SDRplay
  hardware=B0002P0001
  sdrplay_api_api_version=3.070000
  sdrplay_api_hw_version=1

-- Peripheral summary
  Channels: 1 Rx, 0 Tx
  Timestamps: NO
  Other Settings:
     * RF Gain Select - RF Gain Select
       [key=rfgain_sel, default=1, type=string, options=(0, 1, 2, 3)]
     * IQ Correction - IQ Correction Control
       [key=iqcorr_ctrl, default=true, type=bool]
     * AGC Setpoint - AGC Setpoint (dBfs)
       [key=agc_setpoint, default=-30, type=int, range=[-60, 0]]

-- RX Channel 0
  Full-duplex: NO
  Supports AGC: YES
  Stream formats: CS16, CF32
  Native format: CS16 [full-scale=32767]
  Antennas: RX
  Corrections: DC removal
  Full gain range: [0, 42] dB
    IFGR gain range: [20, 59] dB
    RFGR gain range: [0, 3] dB
  Full freq range: [0.01, 2000] MHz
    RF freq range: [0.01, 2000] MHz
    CORR freq range:  MHz
  Sample rates: 0.0625, 0.125, 0.25, 0.5, 1, 6, 7, 8, 9, 10 MSps
  Filter bandwidths: 0.2, 0.3, 0.6, 1.536, 5, 6, 7, 8 MHz 

@wx-jc
Copy link

wx-jc commented Dec 28, 2020

@frameshift18 did you happen to document the process to get TR working with an SDRPlay? I have an RSPduo and haven't been successful yet. The amount of hoops you have to jump though to get all of the drivers working correctly is ridiculous. I think I am getting close, but not quite there yet. I was going to see how much better it performs for analog channels.

@frameshift18
Copy link
Contributor Author

frameshift18 commented Dec 28, 2020

I have been meaning to put together some sort of guide. Honestly I've messed with so many things I'm not sure what actually got it working lol. I used this soapysdrplay module that requires the v3 api binary. I remember reading somewhere the newer SDRPlays are only supported on the v3 api. I'm not sure if gr-osmosdr supports passing the antenna selection to soapysdr so you may run into issues there on a Duo. I will try to dig into my SDRPlay system and see what I can gather.

@NoahJaehnert
Copy link

@frameshift18 I had the same problem with an SDRPlay RSP2. I eventually gave up on it and bought an Airspy.

I still have an RSP2 and can test if you do come up with the steps/a guide.

One thing that might help is if you could share your config, or at least what you set the two gains IFGR and RFGR to?

Thanks,

-Noah

@jasonkotecki
Copy link

@frameshift18 can you share your TR config file? I have an RSP1a that I have been trying to get to work with TR and think I'm real close. I'm getting the error messages below, but I also see a warning related to setting the gain. I've pasted my current config for you to compare.

[WARNING] set_gain() is deprecated - please use set_gain(name) instead

[2021-04-14 10:22:27.459012] (debug) process_data_unit timeout
[2021-04-14 10:22:28.489953] (debug) process_data_unit timeout
[2021-04-14 10:22:29.007669] (error) [MPSCS] There is only one control channel defined
[2021-04-14 10:22:29.007901] (error) [MPSCS] Control Channel Message Decode Rate: 0.666667/sec, count: 2

{
"ver": 2,
"sources": [{
"center": 852993750,
"rate": 8000000,
"gain": -40,
"antenna": "RX",
"digitalLevels": 3,
"digitalRecorders": 4,
"driver": "osmosdr",
"device": "soapy,driver=sdrplay"
}],
"systems": [{
"shortName": "MPSCS",
"modulation": "qpsk",
"squelch": -40,
"audioArchive": "false",
"control_channels": [853250000],
"delayCreateOutput": true,
"type": "p25",
"talkgroupsFile": "talkgroups.csv"
}],

"captureDir": "/data/tr-media",
"logFile": true,
"logLevel": "trace",
"frequencyFormat": "mhz"

}

@frameshift18
Copy link
Contributor Author

frameshift18 commented Apr 15, 2021

I've noticed on my RSP (the original) the PPM needs adjusting to around 2 or 3 depending on temperature. Sometimes when starting from cold the XO will drift enough that once it warms up I lose the CC and will need to add .5 to 1 to the PPM to get it locked on the CC again. I suggest playing around with the PPM a bit and see if you get any decode.

Since I have the RSP I don't have as many options, such as antenna port, which I think is helping me since there is less to potentially be set wrong by the driver by default that TR can't currently change.

Also when you first run TR it will spit out a bunch of helpful information related to the SDR source. I get errors about no gain set but the Soapy driver defaults to AGC since TR doesn't seem to be able to set the individual gains currently. I tried poking around in the source code but the additional Soapy layer gets me lost lol. There is a way to pass arguments to the soapy driver via the device line but I haven't had any luck.

"ver": 2,
"sources": [{
"center": 854000000,
"rate": 7000000,
"ppm": 2,
"digitalRecorders": 12,
"digitalLevels": 4,
"driver": "osmosdr",
"device": "soapy,driver=sdrplay"
}]

[2021-04-15 01:42:08.129868] (info) Driver: osmosdr
[2021-04-15 01:42:08.129889] (info) Center: 854.000000 MHz
[2021-04-15 01:42:08.129900] (info) Rate: 7000000
[2021-04-15 01:42:08.129909] (info) Error: 0
[2021-04-15 01:42:08.129916] (info) PPM Error: 2
[2021-04-15 01:42:08.129923] (info) Auto gain control: false
[2021-04-15 01:42:08.129929] (info) Gain: 0
[2021-04-15 01:42:08.129934] (info) IF Gain: 0
[2021-04-15 01:42:08.129940] (info) BB Gain: 0
[2021-04-15 01:42:08.129946] (info) LNA Gain: 0
[2021-04-15 01:42:08.129952] (info) PGA Gain: 0
[2021-04-15 01:42:08.129957] (info) TIA Gain: 0
[2021-04-15 01:42:08.129963] (info) MIX Gain: 0
[2021-04-15 01:42:08.129969] (info) VGA1 Gain: 0
[2021-04-15 01:42:08.129974] (info) VGA2 Gain: 0
[2021-04-15 01:42:08.129980] (info) Idle Silence: false
[2021-04-15 01:42:08.129985] (info) Digital Recorders: 12
[2021-04-15 01:42:08.129991] (info) Debug Recorder: false
[2021-04-15 01:42:08.129997] (info) SigMF Recorders: 0
[2021-04-15 01:42:08.130002] (info) Analog Recorders: 0
[2021-04-15 01:42:08.130009] (info) Source Device: soapy,driver=sdrplay
gr-osmosdr 0.2.0.0 (0.2.0) gnuradio 3.8.2.0
built-in source types: file rtl rtl_tcp uhd hackrf rfspace airspy soapy redpitaya
[INFO] devIdx: 0
[INFO] hwVer: 1
[INFO] Using format CF32.
[2021-04-15 01:42:08.174720] (info) SOURCE TYPE OSMOSDR (osmosdr)
[2021-04-15 01:42:08.174770] (info) Setting sample rate to: 7000000
[2021-04-15 01:42:08.174830] (info) Actual sample rate: 7000000
[2021-04-15 01:42:08.174860] (info) Tuning to 854.000000 MHz
[2021-04-15 01:42:08.175015] (info) Gain Stage: IFGR supported values: 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
[2021-04-15 01:42:08.175054] (info) Gain Stage: RFGR supported values: 0 1 2 3
[2021-04-15 01:42:08.175073] (info) Max Frequency: 857.450000 MHz
[2021-04-15 01:42:08.175100] (info) Min Frequency: 850.550000 MHz
[2021-04-15 01:42:08.175122] (error) ! No Gain was specified! Things will probably not work
[2021-04-15 01:42:08.175145] (info) Auto gain control is ON
[2021-04-15 01:42:08.175164] (info) Setting antenna to [RX]
[2021-04-15 01:42:08.175186] (info) PPM set to: 2

@jkotecki
Copy link

jkotecki commented Apr 15, 2021

@frameshift18 thank you for your reply and config. I tried setting the ppm and I get a 'Segmentation fault (core dumped)'
It looks like my AGC is OFF, but I'm not sure how to enable it. It's also odd that my IF and RF gain supported values differ from yours. I wonder if it's my SoapySDR or the SoapSDRPlay3 that's different.

[2021-04-15 16:02:13.655260] (info) Driver: osmosdr
[2021-04-15 16:02:13.655270] (info) Center: 852.993750 MHz
[2021-04-15 16:02:13.655302] (info) Rate: 8000000
[2021-04-15 16:02:13.655318] (info) Error: 0
[2021-04-15 16:02:13.655331] (info) PPM Error: 0
[2021-04-15 16:02:13.655341] (info) Auto gain control: false
[2021-04-15 16:02:13.655350] (info) Gain: 0
[2021-04-15 16:02:13.655362] (info) IF Gain: 0
[2021-04-15 16:02:13.655374] (info) BB Gain: 0
[2021-04-15 16:02:13.655384] (info) LNA Gain: 0
[2021-04-15 16:02:13.655395] (info) PGA Gain: 0
[2021-04-15 16:02:13.655405] (info) TIA Gain: 0
[2021-04-15 16:02:13.655416] (info) MIX Gain: 0
[2021-04-15 16:02:13.655426] (info) VGA1 Gain: 0
[2021-04-15 16:02:13.655436] (info) VGA2 Gain: 0
[2021-04-15 16:02:13.655447] (info) Idle Silence: false
[2021-04-15 16:02:13.655456] (info) Digital Recorders: 4
[2021-04-15 16:02:13.655468] (info) Debug Recorder: false
[2021-04-15 16:02:13.655476] (info) SigMF Recorders: 0
[2021-04-15 16:02:13.655485] (info) Analog Recorders: 0
[2021-04-15 16:02:13.655497] (info) Source Device: soapy,driver=sdrplay
gr-osmosdr 0.2.0.0 (0.2.0) gnuradio 3.8.1.0
built-in source types: file rtl_tcp sdrplay rfspace redpitaya
Physical device count: 1
sdrplay=0,hwVer=255,label='SDRplay RSP1A 20060C0497'
[2021-04-15 16:02:13.769571] (info) SOURCE TYPE OSMOSDR (osmosdr)
[2021-04-15 16:02:13.769606] (info) Setting sample rate to: 8000000
[2021-04-15 16:02:13.769644] (info) Actual sample rate: 8000000
[2021-04-15 16:02:13.769669] (info) Tuning to 852.993750 MHz
[2021-04-15 16:02:13.769792] (info) Gain Stage: IF supported values: -59 -58 -57 -56 -55 -54 -53 -52 -51 -50 -49 -48 -47 -46 -45 -44 -43 -42 -41 -40 -39 -38 -37 -36 -35 -34 -33 -32 -31 -30 -29 -28 -27 -26 -25 -24 -23 -22 -21 -20
[2021-04-15 16:02:13.769936] (info) Gain Stage: RF supported values: -64 -63 -62 -61 -60 -59 -58 -57 -56 -55 -54 -53 -52 -51 -50 -49 -48 -47 -46 -45 -44 -43 -42 -41 -40 -39 -38 -37 -36 -35 -34 -33 -32 -31 -30 -29 -28 -27 -26 -25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0
[2021-04-15 16:02:13.769964] (info) Gain Stage: RF_NOTCH supported values: 0 1
[2021-04-15 16:02:13.769984] (info) Gain Stage: DAB_NOTCH supported values: 0 1
[2021-04-15 16:02:13.770000] (info) Max Frequency: 856.961750 MHz
[2021-04-15 16:02:13.770024] (info) Min Frequency: 849.025750 MHz
[2021-04-15 16:02:13.770045] (error) ! No Gain was specified! Things will probably not work
[2021-04-15 16:02:13.770068] (info) Auto gain control is OFF
[2021-04-15 16:02:13.770089] (info) Setting antenna to [RX]
Decim: 80 Decim2: 4
[2021-04-15 16:02:13.770518] (info) P25 Recorder two-stage decimator - Initial decimated rate: 100000 Second decimated rate: 25000 FA: 6250 FB: 12500 System Rate: 8000000
[2021-04-15 16:02:13.786077] (info) P25 Recorder ARB - Initial Rate: 8000000 Resampled Rate: 25000 Initial Decimation: 80 System Rate: 24000 ARB Rate: 0.96

SoapySDRUtil --info
######################################################

Soapy SDR -- the SDR abstraction library

######################################################

Lib Version: v0.8.0-g351896d3
API Version: v0.8.0
ABI Version: v0.8
Install root: /usr/local
Search path: /usr/local/lib/SoapySDR/modules0.8
Module found: /usr/local/lib/SoapySDR/modules0.8/libsdrPlaySupport.so (0.3.0-4e91a2d)
Available factories... sdrplay
Available converters...

  • CF32 -> [CF32, CS16, CS8, CU16, CU8]
  • CS16 -> [CF32, CS16, CS8, CU16, CU8]
  • CS32 -> [CS32]
  • CS8 -> [CF32, CS16, CS8, CU16, CU8]
  • CU16 -> [CF32, CS16, CS8]
  • CU8 -> [CF32, CS16, CS8]
  • F32 -> [F32, S16, S8, U16, U8]
  • S16 -> [F32, S16, S8, U16, U8]
  • S32 -> [S32]
  • S8 -> [F32, S16, S8, U16, U8]
  • U16 -> [F32, S16, S8]
  • U8 -> [F32, S16, S8]

@leee
Copy link
Contributor

leee commented Jul 17, 2021

There hasn't been activity on this issue for a few months. If anyone wants to reopen this please do so, but for now @robotastic lets close this.

@devicenull
Copy link
Contributor

So, some notes from my efforts here:

  • Use "device": "soapy,driver=sdrplay,agc_setpoint=0"
  • I had to patch source.cc set_lna_gain (line 86) to set the gain for the "RFGR" stage, and not the "LNA" stage.
    • It would be nice if trunk_recorder let us specify a list of gain settings, so maybe something like "RFGR=10,IFGR=20", rather then having individual json keys for each type of gain ( see New gain controls pothosware/SoapySDRPlay3#35 )
  • IFGR setting cannot be changed if AGC is enabled (so, setting the AGC mode needs to happen before trying to change this gain stage)
    • I just hardcoded cast_to_osmo_sptr(source_block)->set_gain(25, "IFGR", 0); in set_lna_gain to get stuff working
  • To get the AGC to actually disable, I had to enable it first, and then disable it I really don't understand this, but it works:
    cast_to_osmo_sptr(source_block)->set_gain_mode(true);
    cast_to_osmo_sptr(source_block)->set_gain_mode(false);

My config looks like this:

        "sources": [{
                        "center": "772000000",
                        "rate": "10000000",
                        "error": "0",
                        "ppm": "0",
                        "lnaGain": 1,
                        "digitalRecorders": 5,
                        "digitalLevels": 8,
                        "driver": "osmosdr",
                        "device": "soapy,driver=sdrplay,agc_setpoint=0"
        }],

@W3AXL
Copy link

W3AXL commented May 17, 2022

FYI I am unable to get gain control to work with my RSP1 from a fresh build of trunk-recorder.

My source config:

    "sources": [{
        "center": 857487500,
        "rate": 8000000,
        "error": 10000,
        "agc": false,
        "gainSettings": {
            "RFGR": 0,
            "IFGR": 25
        },
        "digitalRecorders": 16,
        "driver": "osmosdr",
        "device": "soapy,driver=sdrplay,agc_setpoint=0"
    }],

And the output when the device is initialized:

[2022-05-16 22:28:12.721095] (info)   Source Device: soapy,driver=sdrplay,agc_setpoint=0
gr-osmosdr 0.2.0.0 (0.2.0) gnuradio 3.8.2.0
built-in source types: file fcd rtl rtl_tcp uhd rfspace soapy redpitaya 
[INFO] devIdx: 0
[INFO] SerNo: B0002P0001
[INFO] hwVer: 1
[INFO] rspDuoMode: 0
[INFO] tuner: 1
[INFO] rspDuoSampleFreq: 0.000000
[INFO] Using format CF32.
[2022-05-16 22:28:12.774237] (info)   SOURCE TYPE OSMOSDR (osmosdr)
[2022-05-16 22:28:12.774266] (info)   Setting sample rate to: 8000000
[2022-05-16 22:28:12.774299] (info)   Actual sample rate: 8000000
[2022-05-16 22:28:12.774328] (info)   Tuning to 8.574975e+08
[2022-05-16 22:28:12.774434] (info)   Gain Stage: IFGR supported values: 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 
[2022-05-16 22:28:12.774465] (info)   Gain Stage: RFGR supported values: 0 1 2 3 
[2022-05-16 22:28:12.774481] (info)   Max Frequency: 8.614555e+08
[2022-05-16 22:28:12.774517] (info)   Min Frequency: 8.535195e+08
[2022-05-16 22:28:12.774549] (info)   RFGR Gain set to: 0
�[1m�[33m[WARNING] Not updating IFGR gain because AGC is enabled�[0m
[2022-05-16 22:28:12.774581] (info)   IFGR Gain set to: 50
[2022-05-16 22:28:12.774596] (info)   Auto gain control is ON
[2022-05-16 22:28:12.774609] (info)   Setting antenna to [RX]
[2022-05-16 22:28:12.778253] (info)      P25 Recorder two-stage decimator - Initial decimated rate: 100000 Second decimated rate: 25000 FA: 6250 FB: 12500 System Rate: 8000000
[2022-05-16 22:28:12.784463] (info)      P25 Recorder ARB - Initial Rate: 8000000 Resampled Rate: 25000 Initial Decimation: 80 ARB Rate: 0.96

As you can see, AGC is not disabled properly and the IF/RF gain reductions are not set to the correct values (well, RFGR is but IFGR definitely isn't)

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

9 participants