Some simple audio DSP for CW RX
I recently picked up an FT-818 amateur radio transceiver. It’s a wonderful little thing, with lots of features. But it’s an older design, and doesn’t have a lot of filtering for audio enjoyment. Worse, I’m a cheapskate and don’t want to spring for an expensive add-on filter.
Today I played around with one of my Teensy 4.0 microcontrollers, which can be used for some pretty powerful audio digital signal processing (DSP). This post is about some real improvements I was able to achieve, with parts I have on hand around the house.
OK, really the reason I played around with this today is because my poor Siglent oscilloscope developed a problem on port 4, and I had to send it to the Siglent hospital for some warranty work. This means I’m analog blind for a couple weeks, and need to find some other things to occupy myself until it returns safely home.
PJRC makes wonderful little microcontroller boards – think of them as arduinos, but Paul Stoffregen does a great job adapting much more powerful platforms for the Maker community. The Teensy 4.0 works with the Arduino IDE, and supports the popular Arduino API. It’s built on a 600 MHz ARM Cortex-M7, with a bunch of great stuff. Today I used the Teensy 4.0 and the audio board:
The audio board provides an I2S audio chip, with much better analog input and output capabilities than the microcontroller alone. It supports Paul’s excellent audio library, which provides a lot of DSP capabilities. I thought maybe this could be very quickly whipped into an external audio DSP filter for my FT-818.
The problem is that the FT-818 supports lots of modes, from CW which typically needs, say, a couple hundred Hertz of audio bandwidth, to SSB phone, which is usually around 3KHz. Being a somewhat older design (The FT-817 was released in 2001, I think!), it doesn’t have the nice DSP features that modern transceivers have. Unless I want to spend a bunch for an optional CW filter (which are kind of hard to find these days as it is), I have to receive CW transmissions with the same audio filter as used for SSB voice.
The PJRC audio library includes an online architectural design tool, which makes it really easy to drag and drop the DSP components you want to use in a design. Here’s what I ended up working out:
Audio input comes into the microcontroller, is passed to a FIR filter, which feeds into two biquad filter blocks that create the left and right channels for my headphones. I also added an output to the Teensy 4.0’s USB audio device, so I can easily record the audio passing through the device on my computer (examples to follow soon!).
I did experiment with several approaches here, and ended up finding that it was hard to beat the FIR filter on the input. The PJRC library’s biquad filters do work for lowpass, bandpass, and highpass situations. But comparing the results with my ears, the FIR filter approach worked the best.
I designed the bandpass filter using the excellent online calculator, TFilter, as follows:
I suspect playing around with more settings might get even better results, but what I worked out seems to be doing quite well. The code for the Teensy 4.0 board is written in the Arduino IDE, and can be found here.
The hardware comes together looking like this:
The Teensy 4.0 is powered from the USB cable (also used to obtain audio samples for recording on my computer). The line in pins connect to a 3.5mm TRS breakout, which is connected to the headphone output on the FT-818.
This weekend seemed to have a ton of CW activity (I assume some contest, though I didn’t try to copy any of it – everybody was sending much faster than I can decode it by ear!), so it was a great time to test the filter. I spent awhile tweaking the filter settings, trying to get good suppression of the high and low frequencies I didn’t want. It also seemed like a neat chance to play with binaural reception, so getting the left and right channels balanced well was important.
I have only ever read about binaural filtering for CW reception. The idea is that lower and higher frequencies are separated into left and right audio channels. With headphones on, it means signals near your target center frequency sound “in front” of you, while low and high signals approach from the left and recede to the right, respectively.
It really did make a big difference. I made sure that the effect is only moderate… if I made the divide between the left and right channels too sharp, it made for some odd perception, tuning across the band. Where it is, there is just enough binaural character to it that it feels less 1-dimensional, but not so much that it causes problems or becomes a distraction. I have a nice FT-891, which has narrow filtering and noise reduction… but I might want to use something like today’s filter with that one too, just for the binaural experience!
It’s hard to describe the differences that I could hear, so I used the USB audio output on the Teensy 4.0 to record some samples. Personally, I think the experiment is a success, and I am surprised how quickly and easily I could make up for what is likely the most significant weakness of the FT-818!
FT-818 CW RX without filtering
FT-818 CW RX with filtering
(just a quick note: the occasional ‘popping’ that you can hear in the second link doesn’t come through the headphones… I suspect it’s something to do with the USB audio sink and/or the Linux driver.)