Random Quote Board
Making a "Soft" Tuner & Receiver in Gnu Radio
When you look the spectrum from one of your SDR programs, you may see several signals at the same time.
In the days of analog receivers, you could only demodulate and listen (or view) the signal at the center. And just one signal. To understand why that is, you have to understand the general flow for receiving a signal. Tuning to that signal is just the first step. The signal also has to be filtered (to remove all other signals and the ever-present noise), then demodulated (to extract the actual information from the RF signal). With analog systems, this was all done in hardware. You literally needed components, typically in the form of transistors, resistors, capacitors and inductors, for the tuning, filtering and demodulation.
Fast forward to today. Maybe you've used GQRX, shown above, or one of the other programs, such as SDR#, SDRconsole, HDSDR, SDR++, or CubicSDR, and seen a similar spectrum. With these programs, you were able to literally click on any of the signals you see in the spectrum and, VIOLA! You heard audio. Have you ever wondered how these various programs were able to do that? How were they able to demodulate a signal that wasn't centered?
The answer is software tuning. We use software to tune, filter and demodulate the signal. This means we're not hardware limited; we're only limited by what the software can do and the amount of processing available.
Why Do Software Tuning?
There are several reasons why we might want or need software tuning. Let's go through some of those reasons.
IQ Files
The first reason is based on the question, "What if we are playing back an IQ file? And the desired signal is not already centered?" If you have a file, you don't have a SDR to tune. You just have a file of samples. Much as a captured thermal image cannot change the "FORD" (focus, thermal range, distance), a collected IQ file cannot change the center frequency at which it was recorded nor the various settings of the SDR itself, such as the gain or filtered bandwidth. The only way in which you can tune in this way is with software tuning.
Networked Systems
This is similar to reading samples from an IQ file. But instead of the samples coming from a file, they come from the network. The software receivers cannot change the SDR hardware parameters, including the center frequency, so they have to use software to tune and process the samples.
Listen to Multiple Stations at Once
Another possibility is that you want to listen to two radio stations at one time, just as the singer Tom Waits does. If you didn't have two SDRs to run at the same time, then this, too, would require the use of a software tuner. This is demonstrated quite nicely by the Youtube channel "Ham Radio DX" in which he uses the software "SDRconsole" to receive multiple stations at the same time.
Avoiding the LO Feedthrough
Several SDRs, especially the less expensive ones, will have a spike at 0 Hz (DC). This is due (primarily) to the analog RF front end of these systems. The local oscillators and mixers together perform analog frequency tuning. The tuning process creates a large signal at DC, which then becomes part of the digitized spectrum. As complex signal processing is centered at DC, this could create problems for some signal processing. By offtuning from the signal being captured, the system can use software tuning to shift the signal back to DC for processing.
Recover Baseband Subchannels
Many analog signals have subchannels, typically called "subcarriers", on them. For example, FM broadcast stations carry stereo, RDS and sometimes SCA signals. NOAA APT signals use a subcarrier to convey the video information. These, too, can use a software tuner to recover this information.
We'll go through a couple of different methods to make software tuners using Gnu Radio Companion.
How Frequency Conversion Works
The gist is this. When you multiply (mix) a sinewave with another signal, the frequency of that signal is shifted by the frequency of the sinewave.
There are already a lot of different websites, especially Youtube videos, explaining how frequency conversion works. The gist is this. When you multiply (mix) a sinewave with another signal, the frequency of that signal is shifted by the frequency of the sinewave. In other words, the frequency of the sinewave is added to the frequency of the signal. This is where some confusion may occur. I said "frequencies add". But there's also a difference frequency, meaning that the sinewave's frequency is also subtracted from the signal frequency. Why is that?
All signals have both a negative and positive frequency component. Real signals (as opposed to complex signals) always have both a negative and positive frequency component. Certain complex signals, specifically analytic signals, have only a negative or positive frequency component. If we look at the double-sided spectrum of a sinusoid and a signal, we'll see both negative and positive components.
This is one of the key concepts for receiver operation. It's called heterodyning. The definition of "heterodyning" is to mix two signals together in a nonlinear device. I prefer to think of heterodyning as "mix two signals together". And by mixing, we're talking "multiply". Which works perfectly for digital signals. The two signals that are mixed are typically a modulated signal at some radio frequency (RF), while the other is a sinusoid called a "local oscillator" or "LO". The output will be the RF signal shifted by the frequency of the LO. You effectively shift the frequency of the signal by the frequency of the sinusoid. Combined with this concept is the concept of superheterodyning. Superheterodyning, or "superhet" for short, means to shift the frequency of a signal to a fixed, intermediate frequency or "IF". The purpose for shifting to this fixed frequency is so that all of the follow-on processing, such as filtering and demodulation, can be designed for one frequency. This makes designing and building such circuits much easier.
The Limits of Software Tuning
Software tuning will only work on signals within +/-1/2 of the sample rate of the SDR.
Software tuning has one limitation. It only works on those signals within the instantaneous bandwidth of the SDR. In other words, it will only work on signals within +/-1/2 of the sample rate of the SDR.
Using Complex Sinusoids
But now we can add something that is difficult to do in the analog world. We can use complex sinusoids. Such a signal can have only a positive component (an analytical signal) or only a negative component (whatever that is called). With Gnu Radio, there are several ways we can create such signals. The simplest is using a Signal Source block with the "Output Type" set to "complex" and the "Waveform" set to either "Cosine" (the default) or "Sine".
We can also create such sinusoids in one of two ways. The first way is to create a real cosine and a real sine and use them as the real and imaginary components of a complex sinusoid, respectively. The second way is to create a real sinusoid, then filter out the negative frequency component using the Hilbert transform.
The Complex Frequency Shift
Regardless of how the single-sided sinusoid is created, it's useful for one thing in particular. It can be used to shift the frequency of a complex signal by simply multiplying the signal with the complex sinusoid. It is the most straightforward method for software tuning in Gnu Radio Companion. Just combine a Multiply block with a Signal Source block, with both blocks set for "complex" samples. This is a straightforward frequency shifter. This is what we discussed in the previous section.
And that is how software tuning is performed, typically. Multiply by a complex sinusoid to shift the desired signal higher or lower in frequency until it is centered, then perform the processing.
An Example
This is a basic receiver for the United States NOAA Weather Radio system. It uses a RTL-SDR, but the SDR is set to a fixed frequency. The "tuning" is all done in software. With the SDR set to the center channel (162.475 MHz) and the channel spacing of 25 kHz, the system only needs ~170 kHz of bandwidth to cover all of the channels (to include the bandwidth of the end channels due to modulation). However, I've set the RTL-SDR sample rate to 1.2 MHz. The reason is that, based on my experience, the lower sample rates (225 kHz - 300 kHz) don't tend to work as well as the higher ones. This could just be the quantization noise, or something else. Regardless, I've set the sample rate to 1.2 MHz initially, then filtered and decimated afterwards. I've used a lowpass filter set to a bandwidth of 100 kHz to provide the spectrum for tuning. Further, I've used a relatively high transition width in order to keep the amount of required processing down. The "Signal Source" block provides the complex sinusoid to tune in the desired signal. The rest is the standard processing (filtering, demodulation, sample rate adjustment, audio output). I used a "QT GUI Chooser" block to select one of the seven available channels. The QT GUI Chooser selects a frequency offset (+/-75 kHz in 25 kHz steps), which controls the Signal Source block.
Other Software Receivers
The Bandpass Filter with Complex Taps
Here's another method for creating a software receiver that doesn't really "tune". By "tune", I mean to perform frequency conversion. Instead, it uses complex filter taps to create a bandpass filter. Instead of shifting the signal to the filter, this shifts the filter to the signal.
A bandpass filter that uses complex taps can operate on signals either just positive or negative in frequency. A bandpass filter that uses real taps must work equally on the positive and negative frequencies. The use of a complex tap bandpass filter means that all but one signal can be filtered out. Further, because it is an FM signal, we can frequency demodulate the signal with a polar discriminator (the improperly-named "Quadrature Demod" block), except it will have a large DC offset. The DC offset can be calculated, then removed with a "Add Const" block. While this is an interesting, in my opinion, this requires more processing than the complex frequency shift flowgraph from above. This particular flowgraph is not much more processing than the one using the complex frequency shift. Based on the use of a "Null Source" block to replace the RTL-SDR, and a "Probe Rate" and "Message Debug" block to replace the "Audio Sink", the complex frequency shift provided a maximum of 10.0 MSps, while this flowgraph provided 9.5 MSps.
Software Tuning with the Polyphase Channelizer
Here's yet another software tuner. The difference of this one is that it doesn't process just one signal; if done properly, it does them all. For this example, I've tuned a RTL-SDR to a portion of the FM broadcast band. This flowgraph makes use of the "Polyphase Channelizer" block. This makes use of a polyphase filter bank that both filters and frequency shifts the signal down to 0 Hz. Which means that every signal within the instantaneous bandwidth of the RTL-SDR can be filtered, frequency shifted, and output. The only question is "Now what?" Sure, you can demodulate and further process one station (or, again, two if you're Tom Waits), but what about the rest? One possibility is that each channel is output to a network, where other systems can process each station. Or record each station. Or record the information contained in the broadcast.
One part that must be understood in order for this to work is that the sample rate must be the channel spacing (200 kHz, in this example) multiplied by the number of channels (12). That is why the overall sample rate is set to 2.4 MHz. This could also work with other sample rates, so long as the sample rate is an integer multiple of the channel spacing.
Software Tuning Baseband Signals
This is something I've already covered in several posts, most recently with my post on the best RDS demodulator and decoder circuit. Those flowgraphs show a complex frequency shift for the baseband spectrum in order to tune to the 57 kHz RDS / RBDS signal.
If we were to put a "Frequency Sink" block both before and after the "Multiply" block, we would see the spectrum first unshifted (before) and shifted down by 57 kHz (after).
Summary
This hopefully gives you an idea of the many different options for performing software tuning. There are several possible options for each of these, along with things I didn't have time to cover. For example, one thing I didn't cover was the use of a "Vector Source" block to replace the "Signal Source" block. This is possible when it's possible to calculate the values of the complex sinusoids beforehand. This will save on the processing required as the "Signal Source" block calculates its values on-the-fly. If they can be calculated before the flowgraph runs, this saves on the processing.
Til next time!