RPi 3 & RTL-SDR/OP25?

Status
Not open for further replies.

mkmv

Newbie
Joined
Nov 26, 2018
Messages
2
Location
Stavropol, Russia
Can't decode DMR.

We have MMDVM node and Retevis RT3 clients.
Newest(today git pull) op25 on RPi3 1Gb RAM, RTL-SDR v3, Raspbian.

Listened YSF - all works!
DMR - nothing. If plot enabled - I see signal.

cfg.json:
Code:
{
    "channels": [
        {
            "demod_type": "cqpsk", 
            "destination": "udp://127.0.0.1:56120", 
            "excess_bw": 0.2, 
            "filter_type": "rc", 
            "frequency": 439675000, 
            "if_rate": 24000, 
            "name": "p25", 
            "symbol_rate": 4800
        }, 
        {
            "demod_type": "fsk4", 
            "destination": "udp://127.0.0.1:56121", 
            "excess_bw": 0.2, 
            "filter_type": "rrc", 
            "frequency": 439675000, 
            "if_rate": 24000, 
            "name": "ysf", 
            "symbol_rate": 4800
        }, 
        {
            "demod_type": "fsk4", 
            "destination": "udp://127.0.0.1:56122", 
            "excess_bw": 0.2, 
            "filter_type": "rrc", 
            "frequency": 439675000, 
            "if_rate": 24000, 
            "name": "dmr", 
            "symbol_rate": 4800
        }
    ], 
    "devices": [
        {
            "args": "rtl=0", 
            "frequency": 439675000, 
            "gains": "lna:47", 
            "name": "rtl0", 
            "offset": 0, 
            "ppm": 0, 
            "rate": 250000, 
            "tunable": false
        }
    ]
}

Run by command:
Code:
./multi_rx.py -c cfg.json -v9

And listening audio:
Code:
nc -kluvw 1 127.0.0.1 56122 | aplay -c1 -f S16_LE -r 8000
nc -kluvw 1 127.0.0.1 56124 | aplay -c1 -f S16_LE -r 8000

Here's log:
Code:
i@raspberrypi:~/op25/op25/gr-op25_repeater/apps $ ./multi_rx.py -c cfg.json -v9
linux; GNU C++ version 6.2.0 20161010; Boost_106100; UHD_003.009.005-0-unknown

device: {'gains': 'lna:47', 'args': 'rtl=0', 'tunable': False, 'rate': 250000, 'frequency': 439675000, 'ppm': 0, 'offset': 0, 'name': 'rtl0'}
gr-osmosdr 0.1.4 (0.1.4) gnuradio 3.7.10
built-in source types: file osmosdr fcd rtl rtl_tcp uhd miri hackrf bladerf rfspace airspy soapy redpitaya 
Using device #0 Realtek RTL2838UHIDIR SN: 00000001
Found Rafael Micro R820T tuner
[R82XX] PLL not locked!
Exact sample rate is: 250000.000414 Hz
[R82XX] PLL not locked!
channel (dev rtl0): {'name': 'p25', 'demod_type': 'cqpsk', 'symbol_rate': 4800, 'destination': 'udp://127.0.0.1:56120', 'excess_bw': 0.2, 'filter_type': 'rc', 'frequency': 439675000, 'if_rate': 24000}
Using two-stage decimator for speed=250000, decim=5/2 if1=50000 if2=25000
op25_audio::open_socket(): enabled udp host(127.0.0.1), wireshark(56120), audio(56120)
channel (dev rtl0): {'name': 'ysf', 'demod_type': 'fsk4', 'symbol_rate': 4800, 'destination': 'udp://127.0.0.1:56121', 'excess_bw': 0.2, 'filter_type': 'rrc', 'frequency': 439675000, 'if_rate': 24000}
Using two-stage decimator for speed=250000, decim=5/2 if1=50000 if2=25000
op25_audio::open_socket(): enabled udp host(127.0.0.1), wireshark(56121), audio(56121)
channel (dev rtl0): {'name': 'dmr', 'demod_type': 'fsk4', 'symbol_rate': 4800, 'destination': 'udp://127.0.0.1:56122', 'excess_bw': 0.2, 'filter_type': 'rrc', 'frequency': 439675000, 'if_rate': 24000}
Using two-stage decimator for speed=250000, decim=5/2 if1=50000 if2=25000
op25_audio::open_socket(): enabled udp host(127.0.0.1), wireshark(56122), audio(56122)
 

KA1RBI

Member
Joined
Aug 15, 2008
Messages
799
Location
Portage Escarpment
Since DMR and YSF are very close in terms of modulation format, I'd initially expect that either both or neither would work. One thing to check is to make sure the DMR you're trying to receive is a base station. The reception of TDMA from a mobile or handheld unit would probably not work. I'm also not sure what would happen with two listeners - it's just possible that if you've started two separate 'nc | aplay" processes that one or the other may be hogging the sound card port.

In order to simplify this I'd suggest removing two of the three entries in the "channels" list leaving only the "rc" one titled "dmr" and also starting only a single "nc | aplay". In order to further diagnose you can also try something like
Code:
nc .... | od -v -t x1

This should print out the data.

Also be careful about port numbers - DMR uses two slots so the audio for the second slot would be on whatever the port number is plus two.

Another thing to do in debugging is to run the "ifconfig lo" (use the actual name of the loopback interface if it isn't "lo"). What you're looking for is for the "rx packets" or "tx packets" to increase when there is audio.

Finally could you take datascope and symbol plots and post them please...

Max
 

vk2mpj

Member
Premium Subscriber
Joined
Dec 22, 2011
Messages
8
Location
Wagga Wagga, New South Wales
Curious. 57600 works fine on all my 820T2 dongles. By the way the "supported sample rates" thing says that on mine system even though it works just fine. The "Invalid sample rate" is what's stopping you. Try working upwards (or downwards) in multiples of 9600 until you find the lowest it will accept.

Overall though, I would say anything slower than the RPi3 is probably not going to work very well. The Pi3 is on the edge of being acceptable with audio decode.

I get the exact same error if I try and run 57600. It still appears to work, but I note it seems to actually force a higher sample rate on start up, as indicated when when I doing a tail on the stderr log.
I have set mine to 1000000 for now. CPU idles at about 20-25% and on load anywhere between 30-50% depending on what else I am doing. This Pi uses VNC, so that'll use some, plus also my DV4Mini dongle is also run off it at the same time.
My RTL dongle though is not a V3, it's one of the previous versions.

Two other questions from me though.
When turning the verbosity level up for logging, is there a descriptor somewhere that explains the different levels?

Also, regarding the -q switch, is the number following directly related to ppm? ie, 1 = 1ppm. 2 = 2ppm etc. If so, I use kalibrate to measure my ppm of the devices, I should be able to input that figure to the nearest whole number for the most accurate setting?
 
Last edited:

boatbod

Member
Joined
Mar 3, 2007
Messages
3,316
Location
Talbot Co, MD
I get the exact same error if I try and run 57600. It still appears to work, but I note it seems to actually force a higher sample rate on start up, as indicated when when I doing a tail on the stderr log.
I have set mine to 1000000 for now. CPU idles at about 20-25% and on load anywhere between 30-50% depending on what else I am doing. This Pi uses VNC, so that'll use some, plus also my DV4Mini dongle is also run off it at the same time.
My RTL dongle though is not a V3, it's one of the previous versions.

Two other questions from me though.
When turning the verbosity level up for logging, is there a descriptor somewhere that explains the different levels?

Also, regarding the -q switch, is the number following directly related to ppm? ie, 1 = 1ppm. 2 = 2ppm etc. If so, I use kalibrate to measure my ppm of the devices, I should be able to input that figure to the nearest whole number for the most accurate setting?

Log level varies from 0 (silent) to 11 (extremely verbose). While there's no direct explanation of the various levels, if you want protocol level info you generally need to be at "-v 10". The lesser levels are more useful when you are trunking rather than listening to straight DMR.

PPM correction is indeed just a matter of putting a number after the -q parameter. e.g. "-q 1" or "-q -1" etc.
 

vk2mpj

Member
Premium Subscriber
Joined
Dec 22, 2011
Messages
8
Location
Wagga Wagga, New South Wales
snip

PPM correction is indeed just a matter of putting a number after the -q parameter. e.g. "-q 1" or "-q -1" etc.

Thanks mate. I did a kalibrate-rtl last night and I was seeing errors of ~- 20ppm. That would seem like a massive number to be using after -q.
I've been using q -2 and it seems to be pretty much in the ball park. Occasionally, when I start OP25 I'll get Tuning Error (-1200) but doing a > followed by < seems to fix it. Not sure why since the net effect is zero change lol
I am running your fork of OP25

Thanks to you and Max for the work on the program.
 

marklt1

Member
Feed Provider
Joined
Mar 5, 2005
Messages
53
Location
Streetsboro, OH
Any way to improve the audio decoding quality on OP25. On my RPi3b+ units, I have everything tweaked for performance and audio comes out steady and without hesitation. I have tried all three methods of extracting audio, the best results sending the PCM stream via UDP to my Windows workstation where I can filter and massage the audio. On any methods used for listening, the audio will sometime sound like the speaker is echoing like it is in the bottom of a 55gal drum. Sometime the sound can be tinny or not as clear. It doesn't sound like that on my Motorola P25 portable or my Unication G4, which understandable has dedicated Vocoder hardware for audio quality. I have done all of the recommended tips with much success. I and am very grateful for what Boatbod had done with the product and being an invaluable to this group of enthusiasts. Are there any other audio optimizations that can be made? If this is as good as it gets, I am still very satisfied.
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,316
Location
Talbot Co, MD
Any way to improve the audio decoding quality on OP25. On my RPi3b+ units, I have everything tweaked for performance and audio comes out steady and without hesitation. I have tried all three methods of extracting audio, the best results sending the PCM stream via UDP to my Windows workstation where I can filter and massage the audio. On any methods used for listening, the audio will sometime sound like the speaker is echoing like it is in the bottom of a 55gal drum. Sometime the sound can be tinny or not as clear. It doesn't sound like that on my Motorola P25 portable or my Unication G4, which understandable has dedicated Vocoder hardware for audio quality. I have done all of the recommended tips with much success. I and am very grateful for what Boatbod had done with the product and being an invaluable to this group of enthusiasts. Are there any other audio optimizations that can be made? If this is as good as it gets, I am still very satisfied.
In my experience the audio from op25 holds it's own against both G4/G5 pagers and subscriber radios. Echo is not normally a problem, but I will say there is more delay from op25 so if you are playing that and a "real" radio side by side you will notice echo.

Optimizations for the RPi3 involve reducing cpu impact as much as possible. Turn the sample size down (-S 57600), turn off any plots and reduce logging to minimum.
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,316
Location
Talbot Co, MD
Thanks mate. I did a kalibrate-rtl last night and I was seeing errors of ~- 20ppm. That would seem like a massive number to be using after -q.
I've been using q -2 and it seems to be pretty much in the ball park. Occasionally, when I start OP25 I'll get Tuning Error (-1200) but doing a > followed by < seems to fix it. Not sure why since the net effect is zero change lol
I am running your fork of OP25

Thanks to you and Max for the work on the program.
Ignore the results from kalibrate and go with what works on op25. Use the fft plot (#1) and mixer plot (#5) to successively dial in ppm adjustment (-q) and finally the fine tune (-d) so the mixer hump is centered on the tuning line.

Not sure if you have a tcxo in your dongle, but if you don't, initial drift is to be expected until it warms up.
 

marklt1

Member
Feed Provider
Joined
Mar 5, 2005
Messages
53
Location
Streetsboro, OH
In my experience the audio from op25 holds it's own against both G4/G5 pagers and subscriber radios. Echo is not normally a problem, but I will say there is more delay from op25 so if you are playing that and a "real" radio side by side you will notice echo.

Optimizations for the RPi3 involve reducing cpu impact as much as possible. Turn the sample size down (-S 57600), turn off any plots and reduce logging to minimum.

Thanks for the reply and the reassurance. I didn't read too much on this issue in the forums, so at least I know now to look elsewhere.

Now I have a good idea where to focus.
 

Reords80

Newbie
Joined
Dec 1, 2018
Messages
3
@boatbod,

First - THANK YOU for this awesome project.

I have been running your fork on an RPI listening to trunked Phase II for several months with almost no issues!

Quick question:

I need PulseAudio installed to do some other SDR things - piping audio from GQRX to WSJT-X and similar.

However, once I install Pulse (and pauvcontrol) and try to run OP25 I get the "slow motion" audio stuttering - it comes through just reeaaallllllly sllllooooowww.

alsa = OP25 all good, but no GQRX piping > Other programs

pulse = No OP25 but piping audio streams between other programs works

As SOON as I uninstall pulse / pauv OP25 works perfectly again.

Any ideas?

Thanks!
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,316
Location
Talbot Co, MD
@boatbod,

First - THANK YOU for this awesome project.

I have been running your fork on an RPI listening to trunked Phase II for several months with almost no issues!

Quick question:

I need PulseAudio installed to do some other SDR things - piping audio from GQRX to WSJT-X and similar.

However, once I install Pulse (and pauvcontrol) and try to run OP25 I get the "slow motion" audio stuttering - it comes through just reeaaallllllly sllllooooowww.

alsa = OP25 all good, but no GQRX piping > Other programs

pulse = No OP25 but piping audio streams between other programs works

As SOON as I uninstall pulse / pauv OP25 works perfectly again.

Any ideas?

Thanks!

Hard to say, other than the biggest issue with RPi3 is lack of cpu horsepower.
You could try playing with the buffer parameters found inside sockaudio.py (near the top) to see if you can improve things.
Code:
# OP25 defaults
PCM_RATE = 8000                 # audio sample rate (Hz)
PCM_BUFFER_SIZE = 4000          # size of ALSA buffer in frames
 

Reords80

Newbie
Joined
Dec 1, 2018
Messages
3
Thanks, I'll give that a try a report back!

I didn't get the impression that it was a resources issue - the CPU load was not high in either case.
 

Reords80

Newbie
Joined
Dec 1, 2018
Messages
3
I didn't get the impression it was a resources issue - the CPU was not under heavy load with either one.

I'm happy to try playing with the PCM numbers, but do you have any idea what the scale or changes should be?

I have no idea what those parameters mean so...

Should I change it from 8000 to 80000?

or from 8000 to 80?

likewise for the buffer size.

Thanks!
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,316
Location
Talbot Co, MD
I didn't get the impression it was a resources issue - the CPU was not under heavy load with either one.

I'm happy to try playing with the PCM numbers, but do you have any idea what the scale or changes should be?

I have no idea what those parameters mean so...

Should I change it from 8000 to 80000?

or from 8000 to 80?

likewise for the buffer size.

Thanks!
8000 is the pcm sample rate. That needs to stay the same to match the decode.

Buffer size is the one you can modify. The numbers that are there work pretty well with alsa. Pulse is not something I've ever played with on a RPi3
 

maus92

Member
Premium Subscriber
Joined
Jun 23, 2004
Messages
7,973
Location
The OP
Can we talk the RTL sample rate for a minute ? Is there any advantage at all running the S parameter value at anything value above where the software starts to decode the stream and produce voice? Does the decode quality improve at all as you increase the sample rate above when it first starts to produce audio?

Same question about LNA value - is there any advantage at all boosting it above the point where you start separating a usable signal above the noise floor?
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,316
Location
Talbot Co, MD
Can we talk the RTL sample rate for a minute ? Is there any advantage at all running the S parameter value at anything value above where the software starts to decode the stream and produce voice? Does the decode quality improve at all as you increase the sample rate above when it first starts to produce audio?

Same question about LNA value - is there any advantage at all boosting it above the point where you start separating a usable signal above the noise floor?

Maybe the radio guys will chime in, but there are very limited benefits to raising the sample rate beyond the minimum necessary to ensure reliable decode. From an operational perspective there is no benefit whatsoever.
- A larger sample rate does allow you to "see" more on the fft plot, but it doesn't make the decode any better. In fact, on cpu limited hardware it makes decode worse because the audio stutters.
- On some SDR hardware the maximum bandwidth will be wide enough that you could set a center frequency and receive an entire trunked system without ever having to re-tune the sdr hardware. Generally this doesn't apply to an RTL stick because 2Mhz is pretty limited. That said, when feasible, center tuning does have the significant advantage that it is quicker to follow trunked voice grants and gets you on frequency sooner than hardware tuning. In the real world this probably doesn't mean much unless you need to capture the ESS present in the MAC_PTT message.

For LNA, the general rule is to increase the gain no more than (a) necessary to reliably receive the signal and (b) just less than the value that noticeably raises the noise floor.
The easiest way I've found to work this out is use the osmocom_fft application so you can dynamically tweak the values and see the fft plot in real time.
 

mkmv

Newbie
Joined
Nov 26, 2018
Messages
2
Location
Stavropol, Russia
Since DMR and YSF are very close in terms of modulation format, I'd initially expect that either both or neither would work. One thing to check is to make sure the DMR you're trying to receive is a base station.

I think, I can't decode your base station, because it's selfmade hardware. Simplex MMDVM+RPi3+Morotola GM340 and Pi-Star software. Maybe it not base station like industrial Motorola and Hytera Tier II repeaters.

Tried this config, out mmdvm node works DMR on timeslot 2:

Code:
{
    "channels": [
        {
            "demod_type": "fsk4", 
            "destination": "udp://127.0.0.1:56122", 
            "excess_bw": 0.2, 
            "filter_type": "rc", 
            "frequency": 439675000, 
            "if_rate": 24000, 
            "name": "dmr", 
            "plot": "datascope",
            "symbol_rate": 4800
        }
    ], 
    "devices": [
        {
            "args": "rtl=0", 
            "frequency": 439675000, 
            "gains": "lna:28", 
            "name": "rtl0", 
            "offset": 0, 
            "ppm": -2, 
            "rate": 1000000, 
            "tunable": false
        }
    ]
}

Code:
nc -kluvw 1 127.0.0.1 56124 | aplay -c1 -f S16_LE -r 8000
nc -kluvw 1 127.0.0.1 56124 | od -v -t x1

and result - no data. od -v -t x1 - nothing. ifconfig lo - no changing rx/tx.

But scopes show signal:
 

Attachments

  • symbol.jpg
    symbol.jpg
    58.8 KB · Views: 136
  • datascope.png
    datascope.png
    169.3 KB · Views: 134

boatbod

Member
Joined
Mar 3, 2007
Messages
3,316
Location
Talbot Co, MD
I think, I can't decode your base station... <snip>
and result - no data. od -v -t x1 - nothing. ifconfig lo - no changing rx/tx.

But scopes show signal:

Your symbol plot looks a little strange with those gaps in it. By comparison here is a typical plot from a P25 Phase 2 system with ambe audio present.
 

Attachments

  • Screenshot from 2018-12-03 12-11-21.png
    Screenshot from 2018-12-03 12-11-21.png
    16.2 KB · Views: 124

KA1RBI

Member
Joined
Aug 15, 2008
Messages
799
Location
Portage Escarpment
and result - no data. od -v -t x1 - nothing. ifconfig lo - no changing rx/tx.

But scopes show signal:

OK this gives a better idea of where it's failing. It isn't even close to a valid decode - which is why there's no output showing in the network and 'nc' tests.

You datascope plot shows a signal that's somewhat off frequency but more important it looks as if the baseband audio gain is set too high for some reason. It also looks suspiciously like it might be a d-star signal, not a dmr signal. It's possible if you try the dstar settings (gmsk, etc) and adjust the frequency tuning by a fine amount it might work.

Also -separately - as a temporary change for test purposes it would be interesting to see a datascope plot using a lowered baseband gain (with your existing config)

Code:
op25/op25/gr-op25_repeater/apps$ grep _def_bb_gain  p25_demodulator.py
_def_bb_gain = 1.0
        self.baseband_amp = blocks.multiply_const_ff(_def_bb_gain)

try settings of 0.5 or 0.25 etc until the display stops overflowing the datascope window vertically. I'd be interested to see the result. We should also make this a configurable parameter but for the time being it's hard coded in the script.

Max
 

faff29

Member
Feed Provider
Joined
Jul 30, 2008
Messages
51
Location
Eastlake, OH
I have been scouring the internet for the past couple of days for help on an issue with my rpi and op25. I have it working well and broadcasting on broadcastify but I would like to have alpha tagging showing up on the broadcast. Is there a way to do that with a rpi, or is that not an option yet?
 
Status
Not open for further replies.
Top