Applied Digital Signal Processing


This is a notes post and may not be as easy to follow as a de facto blog post.

Overview

Intro

Radio waves are literally everywhere always passing through us. FM/AM radio, HAM radio, WiFi, Bluetooh, car keys, garage door openers, and so much more all use radio waves to transmit information across space. Radio waves help comprise the EM spectrum, so they travel at the speed of light.

Signal Basics

Being related to light, a radio wave is an analog signal which means we can model it mathematically using a sine wave. With this being said, the wave's attributes include its frequency, amplitude, and phase. In most radio systems, we communicate information by changing the signal's frequency or amplitude over time, called frequency modulation and amplitude modulation, respectively. For example, commercial radio stations are separated by FM and AM radio stations.

Getting Hands Dirty

We can use a Software Defined Radio (SDR) dongle and attach an antenna to it in order to receive lots of radio signals. SDRs receive raw radio signals on a wide range of frequencies (often high kHZ to low GHz). The cool thing about them is that you use software to interpret the raw complex radio signals, which means you can do all the signal processing entirely using software. You can use GNU Software like GNU Radio (brew install gnuradio on macOS) or other open source software like the  rtl-sdr and its more approachable Python wrapper, pyrtlsdr. I found GQRX  to be the easiest thing to get started using for beginners with a new SDR. It was easy to download and install, and you can immediately plug in your SDR dongle and start tuning it to nearby radio stations to listen to music.

The vast majority of SDRs simply receive radio signals, but more expensive ones like the HackRF can also transmit! There's even a little hack to get your Raspberry Pi to transmit on some lower frequencies and serve as a cheap radio station. It's very approachable since the Pi is cheap, but do NOT transmit before consulting the laws in jurisdiction.

Demodulation

We can demodulate the incoming signal in a relatively simple manner, if we're given the complex signal in I/Q format. See this post for more information.

Decoding Digital Signals

WiFi, Bluetooth, digital satellites, and more using communicate using binary code. They prepare the bits in each message to be transmitted through radio waves by using digital modulating schemes that build on top of the analog modulating schemes like FM and AM.

Most digital modulation schemes are based on Phase Shift Keying and Frequency Shift Keying.

Broader Signal Processing

Cool places to learn more about Digital Signal Processing include Audio and Digital Signal Processing (DSP) in Python,  Digital Signal Processing Stack Exchange, and Cal's EE123 Course.

Applications

There's a variety of applications for radio technology. I've talked about why I care about radio, and I have a list of some easy-to-find radio stations and bands you can tune yours to if you want to find some interesting stuff.

Installing Software

On macOS:

Librtlsdr and assorted tools

  1. Install Homebrew
  2. Run brew install librtlsdr
  3. [DONE] librtlsdr and the rtl_* CLI tools should be installed and available

OR

  1. Install a version of MacPorts for your OS version from GitHub
  2. Run sudo port install rtl-sdr
  3. [DONE] librtlsdr and the rtl_* CLI tools should be installed and available

GNURadio

Adapting Aaron Scher's tutorial:

  1. Install the macOS X11 window manager, XQuartz
  2. Install a version of MacPorts for your OS version from GitHub
  3. Add /opt/local/bin and /opt/local/sbin to your $PATH environment variable so that executables in those directories can be found
  4. Open up a new terminal session and run sudo port install gnuradio
  5. Run sudo port install rtl-sdr (or brew install librtlsdr with Homebrew if that doesn't work)
  6. Run sudo port install gr-osmosdr
  7. [DONE] Run gnuradio-companion to see the GNURadio GUI!

Pyrtlsdr

  1. Install librtlsdr (see above)
  2. In the terminal, run python -m pip install pyrtlsdr

Code

See code snippets and GNURadio flows.

Extra Notes

  • PySDR is a great resource for learning the basics of applying DSP in Python.