Nothern Utah WebSDR Logo - A skep with a Yagi Northern Utah WebSDR
Using the "libmirisdr-4" utility for reception

What's this, then?

In the page that refers to this one (link) there are other pages discuss the use of the SDRPlay RSP1a for use with the PA3FWM WebSDR, how to configure a Linux system to allow up to 768 kHz of bandwidth with "aplay", a "fast" (768 kHz capable) version of "aloop", getting I/Q data from this using the "sdrplayalsa utility" and using the "csdr" program to convert to baseband.

The aforementioned use of the SDRPlay relies on the "Version 3" API by SDRPlay itself which, unfortunately, is not open-sourced - and it's a bit buggy, with no way to fix it other than hope that the SDRPlay folks get around to it.

"libmirisdr-4"

There is an open-source driver collectively known as "libmirisdr-4" that will talk to this same hardware.  This driver is much less well-developed and has fewer features than the SDRPlay drivers - and a few drawbacks (to be discussed in the conclusion) - but I decided to taking a crack at making it work.

This page is NOT intended to be an exhaustive guide to using libmirisdr (and "miri_sdr", the actual driver) but rather more of a place where I have placed various notes and comments on what I have done to make it work:  If I find libmirisdr to be useful, I may add to it - but even if not, others might find this useful.


Getting and compiling

The most current version (as of this writing) is "libmirisdr-4" found at the Git of f4exb here:  https://github.com/f4exb/libmirisdr-4

To install:

git clone https://github.com/f4exb/libmirisdr-4

cd libmirisdr-4

mkdir build

cd build

cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=~/libmirisdr-4 ..

make -j4 install

When successfully done you will find the binaries in /libmirisdr-4/bin - notably "miri_sdr" and "miri_fm".  Only "miri_sdr" is discussed in detail here.

Using

To invoke, go to the directory with the binary ( /libmirisdr-4/bin" in the example above) and type "./miri_sdr" and you'll get the list of command-line arguments which require a bit of explanation.  Since I'm not terribly familiar with the internals, I'm sketchy on some of the details.

Setting of "-g" Signal level for 12 dB SINAD Calculated MDS A/D severe clipping level (dBm)
1 -55.0 (S9+18) -71.5 (S9+1.5) +33 (S9+106)
2 -64.0 (S9+9) -80.5 (S8) +23 (S9+96)
3 -72.0 (S9+1) -88.5 (S6+) +13 (S9+86)
4 -82.0 (S7+) -98.5 (S5) +3 (S9+76)
5 -92.0 (S6) -108.5 (S3) -7 (S9+66)
6 -95.0 (S5+) -114.5 (S2+) -17 (S9+56)
7 -95.0 (S5+) -111.5 (S2+) -27 (S9+46)
8 -95.0 (S5+) -111.5 (S2+) -37 (S9+36)
9 -95.0 (S5+) -111.5 (S2+) -47 (S9+26)
10 -95.0 (S5+) -111.5 (S2+) -57 (S9+16)
The last argument is either a filename, or simply a hyphen ( - ) - the latter indicating that the output should go to STDOUT.  If you want to "record" raw I/Q data to a file, you would use the filename.

Example command line invocation:

./miri_sdr -f 2500000 -w 200000 -m 252 -s 1536000 -

Where:

Example with csdr:

"csdr" was written by HA7ILM and may be found here:  https://github.com/ha7ilm/csdr

You can find real-world examples of using csdr on this page:  Using CSDR for auxiliary receivers on a WebSDR system - link.

This software suite consists of the raw tools necessary to take a raw I/Q stream, filter and demodulate it as the example shows:

./miri_sdr -f 2500000 -w 200000 -m 384 -s 1536000 - | csdr convert_s16_f | csdr fir_decimate_cc 32 0.01 HAMMING | csdr bandpass_fir_fft_cc -0.1 0.1 0.05 | csdr amdemod_cf | csdr fastdcblock_ff | csdr agc_ff | csdr limit_ff | csdr convert_f_s16 | csdr mono2stereo_s16 | aplay -r 48000 -c2 -f s16_le

In this example we have the same configuration of "miri_sdr" as above (e.g. tuned to 2.5 Mhz) but are using CSDR to decimate and AM demodulate it as follows:

Using with a WebSDR system

Referring to other documents on this site mentioned above, we can apply what we no know to make this usable with a PA3FWM WebSDR.  To accomplish this we must decimate to the input rate of the WebSDR - and let's assume that we have it configured for a 768 kHz bandwidth (see the article "Operating a WebSDR receiver at 384 or 768 kHz using the 16 bit signal path" - link and related at this site.

A possible configuration is as follows:

 ./miri_sdr -f 2510000 -w 600000 -m 384 -s 1536000 - | csdr convert_s16_f | csdr fir_decimate_cc 2 0.45 HAMMING | csdr limit_ff | csdr convert_f_s16 | aplay -r 768000 -c2 -f s16_le --disable-softvol -B 50000 -D plug:rx_ch0

In this example we are tuned to 2.51 MHz with a hardware bandwidth of 600 kHz using the 14 bit mode and a raw sample rate of 1536 kHz, sending the output to several instances of csdr.  Using csdr, we convert to floating point, decimate by two to yield 768 kHz, prevent clipping, and then convert back to signed 16 bit and then send it to our loopback device using "aplay" configured for 768 kHz and two-channel audio.

In testing this, it's noted that the decimation filter doesn't seem to have quite the effect expected (e.g. it didn't seem to be filtering at all based on experiments with differing bandwidth settings), but the hardware filter (set to 600 kHz) seemed to do a reasonable job.  Practically speaking, an instance of "csdr bandpass_fir_fft_cc" could be used before and after the decimation to provide additional filter, at the expense of CPU utilization.

Experiments were also done with the "gain" (-g) parameter and it was noted that the default amount of gain (0) was still too high for typical HF use:  As noted below a means of adjusting the RSP1a's other gain parameter (attenuation, actually) doesn't seem to be available via the interface, but more testing is warranted.

CPU Utilization

The "test" computer is quite old, running an Intel E5400 dual-core Pentium at 2.7 GHz:  Not a speed demon, but plenty good for testing.
This would imply that - within the scope of this testing - that the CPU utilization is about the same for each of these methods.
Limitations of "miri_sdr:


As mentioned above, there are some issues with "libmirisdr" as it's presently understood:
Other comments:

It would seem that other devices use the same Mirics chipset.  Based on a glance at the file "devices.c" in the source code, this seems to cover SDRPlay RSP1a and RSP2.

Other devices that appear to use the same/similar chip sets and - based on the source code - may work include the "VTX3D", Hauppauge WinTV 133559 LF, AverMedia A859 Pure DBTV, IO-Data GV-TV100 stick and Logitec LDT-1S310U/J.  Most of these device are intended for TV reception and likely will not work well at HF at least without modification and/or additional filtering.

Conclusion:


In testing, the "miri_sdr" utility/driver shows promise and warrants further investigation:  If there are features present that I missed - particularly in terms of methods to enumerating multiple devices - please let me know using the email address below.



Additional information:
 Back to the Northern Utah WebSDR landing page