MacOS Software Defined Radio with GQRX and RTL-SDR

Radio, like most else, has gone digital. In the early days of digital signal processing, pioneers realized that many modulation and demodulation techniques could be performed by digital computation.

As computers became cheaper and faster and integrated circuits became cheaper and faster, it was inevitable that the guts of radio receivers and transmitters would be mostly digital and that computers would do much of what went on inside new radios.

This post will describe the initial exploration of GQRX and RTL-SDR here at Dismal Manor. Most of what is already written on the Internet neglects to mention a couple of details the Moocher learned the hard way. Find out what these are after the break.

The iCom 7300 transceiver is a premier example of this new generation of radios. Although a traditional amateur transceiver in appearance, a software defined radio is inside resulting in dramatic price-performance improvements. This radio can be purchased new for less than the used price of the previous generation of traditional radios.

iCom 7300 Transceiver courtesy of iCom

Also inevitable, software developers would begin open source software projects to develop a digital radio architecture and signal processing blocks for that architecture. GNU Radio is the best known of these. A number of projects develop software defined radio receivers or transmitters on top of these products. This post talks about my experimentation with the RTL-SDR receiver and GQRX software defined radio application built using the GNU Radio architecture and blocks.

Acknowledgements

I’d like to take a minute to recognize Alexandru Csete, OZ9AEC. Alex has done yeoman work developing GQRX from GNU Radio and the various radio tuner devices out there. The program works nicely on Linux and MacOS and I was particularly impressed that the GQRX App package included the utilities commonly used with GQRX and the RTL-SDR device.

I’d also like to recognize System76 and their POP_OS Linux distribution. POP_OS package repository included the complete GQRX package with the RTL-SDR libraries and utilities included in the package. No rummaging was needed to install GQRX on POP_OS.

Especially noteworthy was that both packages worked exactly as advertised. The issues encountered on this journey were some learning things on my part and the power hungry RTL-SDR device exceeding USB port power capability. The three GQRX distributions were first rate.

References

  1. https://icomamerica.com/en/products/amateur/hf/7300/default.aspx
  2. https://www.rtl-sdr.com/about-rtl-sdr/
  3. http://gqrx.dk
  4. http://gqrx.dk/download/install-ubuntu
  5. http://www.usps.org/lc/redwood/education/vhf_channels.htm

Busted weather radio

After watching several YouTube videos, I decided to give SDR a try using a Raspberry Pi and the RTL-SDR receiver. My initial motivation was that my weather radio had died as discovered during the yearly Virginia tornado drill. Virginia sent the signal and it just sat there. On investigation, I found my radio sitting fat, dumb, and unhappy on my dresser with the “Check Op” indication on the display. After checking the radio, I determined that the indication could not be cleared suggesting that the receiver bits had broken. So what was available for weather radios? Was home-brew possible? Was home brew desirable? What else could the bits do?

Being a recovering former engineer …

You guessed it. I began poking around on the WWW and YouTube and quickly discovered that SDR was mature and easily installed pre-compiled packages were available. I decided to give it a try.

Raspberry Pi 3 experience

I ordered a genuine RTL-SDR receiver from the recommended source at Amazon and a Raspberry Pi display from the good folks at Amazon (the Raspberry Pi foundation). I wanted to be careful here to get the one compatible with GQRX.

The kit came. I put everything together. I downloaded Raspberry Pi GQRX and the RTL-SDR support software. And nothing worked on the Pi. The 7-inch touchscreen is cute and worked well but GQRX will not arrange itself properly for this display. The display will not hold the complete dialogs. An external display is recommended. I never did get the thing to make noise. That I didn’t have an audio output device connected didn’t help but I never got that far.

Lenovo Yoga Try Two

I tried again on an old Lenovo Yoga running Pop_OS Linux. The good folks at System76 specialize in engineering and software developer workstations, servers, and laptops. POP_OS is a curated Ubuntu version tailored to technical use. POP_OS repository had a complete GQRX package available including the tuner modules. Just one thing to install. Still no joy. I grabbed GQRX for MacOS from the website and joy was had.

What went wrong on the small machines?

The dongle got nicely warm when powered from the iMac USB port. The Pi meanwhile was griping abut USB under-voltage. So the Pi does not have the grunt to power computer, display, and tuner. GQRX UI was responsive but the radio would not make sound. At this time I did not know about the play button.

Moving on to the laptop, similar problems. The tuner was detected but not operating and the tuner was cool to the touch. I suspect the same issue, USB under voltage. Again, I had not yet learned how to use the configuration settings or start radio processing.

Had I known about the configuration settings and the play button, I would still have had USB power issues. The program was just not happy with the external radio tuner bits.

The MacOS Experience

Trying to figure out if I had bad hardware, I watched a couple of YouTube videos to see if I had missed any switchology. Then, I grabbed the MacOS GQRX package from the GQRX website and followed the instructions.

Since Alex last updated the GQRX website text, the MacOS GQRX distribution has progressed from “somewhat experimental” in Alex’s words to fairly polished. As of spring 2019, the Linux and MacOS versions are comparable in features and usability.

The MacOS version is built as an APP. The App contents include a shell script to start the app from the terminal, the floating point tuning utility, the RTL-SDR test tool, and other odds and ends. The top level archive also contained a README covering the MacOS specific things to be done. If you do what the README says, life is good. The code came up as advertised. The radio came up as advertised. The RTL-SDR housing warmed above skin temperature as expected.

By this time, I knew to open the tuner’s filter and press the play button so something actually happened here.

I set up the radio ensuring the filter was open. I tuned to a local NOAA weather station. Output. I tuned to WHRV. Output. I tuned to WHRO. Output. The FM-stereo detector is scratchy. The FM-mono detector is quite good. The Narrow Band FM detector is quite good. Weather radio never sounded so clean. This with a 2 meter quarter wave fixed length whip installed.

Intel Linux Optimizations

Over the years, the IA-64 architecture has accumulated a number of vector instruction sets and trigonometric function implementations. Since GQRX makes heavy use of digital filtering and the Fast Fourier transform to do convolutions (time domain convolution is frequency domain multiplication), SDR performance can be enhanced by linking the proper vector-trig libraries with the application, usually by symbolic link trickery rather than by rebuilding and relinking the image.

The Ubuntu Linux installation instructions explain how to test the host floating point performance to set up GQRX for optimized trig function vector math. Note that these instructions are specific to Intel hardware on the Linux OS with current compilers. I can’t recall if I tried this on my MacOs iMac.

Gqrx SDR 2.6 with RFSpace Cloud-IQ
Courtesy of https://gqrx.dk/

Tool Bar

Next we will take a walk around the GQRX UI starting with the tool bar. The tool bar has the following buttons of interest

  1. Run/Stop button to start and stop radio processing
  2. Configuration button to open the tuner settings
  3. Folder tool to open saved configurations library
  4. Disk tool to save a configuration to the library
  5. Frequency bookmark tool saves a frequency to recall
  6. Record/Plaback tool to record and replay a saved sample stream.

Not much happens until you toggle the play button to the playing state. Once set to playing, the spectrum analyzer will begin updating and there will be audio output.

The Shiny Stuff

At the top is a frequency display. Under the frequency display is a waterfall showing the frequency across, intensity in pseudo-color, and time running down the display. The radio can be tuned by clicking or dragging on this display.

Hardware Configuration

At a minimum, GQRX must be configured to select an available radio tuner from those connected to or installed in the host. The PCI card button opens the dialog used to select and configure the hardware. Some settings are common to all tuners. Others may be hardware specific. Selecting a tuner type will load the presets configured for that tuner. The distribution comes with reasonable recommended values for RTL-SDR radios.

Select the tuner configuration tool from the tool bar. This dialog lets you select the hardware radio (USB dongle here). For the RTL-SDR device on MacOS, identify the device by using the About This Mac tool’s System Report USB section. You will see an entry like this

RTL2838UHIDIR

Pick the best match device from the Device drop down. Making this selection should set the other entries to values appropriate to this device. Confirm that the bandwidth is greater than 0. One MHz appears to be a good starting value. Too small and there is nothing to process. Too big and things get noisy. Once you have a contact, adjust this setting for best reception.

Dismiss the dialog by clicking the OK button.

Radio Controls

The pane to the right of the spectrum analyzer shows the current radio processing options. Three tabs allow setting of input controls, Receiver options, and fast Fourier transform settings for the spectrum analyzer.

Input Controls

Three controls at the top of the pane are of the most interest. These are the local oscillator frequency, the Hardware AGC check box, and the RF amplifier gain. The defaults are reasonable.

The LNB LO frequency is used to translate frequencies outside the tuner’s pass band into the tuner’s pass band. Leave this set to zero MHz for direct reception.

The Hardware AGC box enables automatic gain control of the tuner’s RF amplifier. When unchecked, the slider sets the RF amplifier gain. Use AGC unless it is badly behaved for a contact. Then uncheck and adjust the amplifier gain for -60 db RF backgrouind level. Most carrier signals will be about 20 db above background.

Receiver Options

These controls set up the receiver to receive a specific radio frequency and modulation type.

  • Frequency: Enter channel center frequency here
  • Filter Width: sets bandwidth of the intermediate filters
  • Filter Shape: sets filter order for broad, normal, or sharp filtering.
  • Mode: selects the demodulator used (FM narrow, FM mono, FM stereo, USB, LSB, AM, etc). Select the filter appropriate to the band. Select I/Q to pass the complex sample stream to an external demodulator via host OS audio signal patching.
  • AGC: slow is good
  • Squelch: Suppresses background noise. Set to a value above the background level shown in the spectrum analyzer but below the modulation level

FFT Settings

I’ve been using the following spectrum analyzer FFT settings

  • FFT size: 8192 — i’ve left this alone. This number and the sampling rate determine the spacing between lines in the spectrum display. Too low and narrow bandwidth signals are missed. Too high steals processor from demodulation processing.
  • FFT rate: I use 5 Hz. The out of the box value is 25 Hz resulting in a busy display. This setting selects interval between FFT calculations for the spectrum display and the waterfall spectragram display.
  • Time span: Changes the number of FFT rows shown by the spectrum analyzer. Auto calculates from the window size. A value forces a specific height. Leave this at auto.
  • Window: This refers to the weighting of samples in the FFT. Because the FFT uses a finite set of samples, yet an infinite sequence of samples define the signal, the finite snippet can be considered the product of the window with the infinite sample stream. In effect, the window has operated on the sample sequence to select a subset. The resulting transform will reflect both the signal and the window used. If we were to process white noise with a rectangular window function, the resulting spectrum would show a sin(f)/f shape while the actual spectrum is invariant with frequency. To reduce spectrum artifacts, one of several windowing functions is applied to the sample sequence before transforming them to the frequency domain. The default setting appears to be a Hann window. The Hamming window is another good one.

Antennas?

I’m currently using a 2 meter whip which works well with FM radio (brute force) and weather radio (162.550 MHz in band) and should work with bridge to bridge marine radio.