Random Quote Board

Software Defined Radios and Spectral Displays

Gary Schafer, March 2021

This post will cover digital spectral displays, with a strong focus on resolution bandwidth (RBW).

What is Resolution Bandwidth?

I'm going to assume that you already understand the concept of resolution bandwidth. If you do not, here's what I recommend:

Resolution bandwidth plays two, important roles in spectral analysis. These are:

  1. set the ability to resolve the fine spectral details of a signal: Resolution bandwidth is so called because of that first word, "resolution". As in "resolve". It was originally defined as the ability to resolve two, closely-spaced tones. I tend to think of it as the ability to see more detail on spectral data. A lower RBW means "more detail"; higher means "less detail".
  2. set the displayed noise floor: The combination of the RBW and the noise figure of the spectrum analyzer also sets the displayed average noise level (DANL). RBW and the noise level are directly related. You can see this below in the two spectra. The first, with a high RBW, also has a relatively high noise level. The second, with a lower RBW, also has a lower noise level. This is due to the basic fact that the spectrum analyzer will input a certain amount of noise. As the RBW goes down, that power is divided up into more and more bins. Each bin will receive a smaller share of the total power. The inverse is true. Increasing the RBW will also decrease the number of bins. Each bin will get a larger portion of noise.
Spectrum of a FM broadcast signal and digital "shelves" using a high resolution bandwidth. Note that the details of the signal are smeared together. Also note the noise floor on either side of the signal. (Spectrum created using a RTL-SDR and the "Spektrum" program.)
Spectrum of a FM broadcast signal and digital "shelves" using a relatively low resolution bandwidth. Note that it is now possible to see the fine details of the signal. The center, analog signal stands out from the two digital sidebands. Note how much lower the noise floor on either side of the signal is compared to the other spectrum. (Spectrum created using a RTL-SDR and the "Spektrum" program.)

Analog vs Digital Resolution Bandwidth

A key issue of resolution bandwidth is understanding how it is measured. In analog spectrum analyzers, its measured at points 3 dB down from the peak of the (typically Gaussian) filter. Further, analog filters also have a parameter known as the selectivity. This refers to how quickly the filter goes from little to no attenuation to a lot of attenuation. It's typically measured as a ratio between the bandwidth at the 3 dB points (again, which is the RBW), and at points 60 dB down from the peak.

Diagram showing the 3 dB and 60 dB bandwidths as measured on an analog spectrum analyzer. (Image source: Hewlett-Packard, Spectrum Analyzer Series, Application Note 150, April 1974.)

The DFT is different. As we go into more detail about digital spectra, we'll build up to an understanding of resolution bandwidth with respect to the DFT.

The Discrete Fourier Transform and Binwidth

The discrete Fourier transform (DFT) creates a discrete spectrum consisting of a series of points. Each point represents a bin, meaning a certain amount of spectrum. The bandwidth of each bin is a binwidth. The binwidth can be calculated as follows:

Binwidth = fs/N

where:

Basic diagram of a discrete Fourier transform (DFT). The DFT input is a sampled time-domain; the output is a sampled frequency-domain. This means that the spectrum is only defined at certain, discrete points. Each point represents a slice, called a "bin", of the spectrum. The width of each bin, the "bin width", is fs/N, where fs = the sample rate and N = the number of samples in the time-domain record (including both data and zero samples).

The Discrete Fourier Transform and Windowing

Let's say that we have a time record of a signal. Further, let's say that we take this time record and plug it directly into the DFT algorithm. Here's how the corresponding time domain and frequency domain displays would appear.

Time record consisting of 700 samples of a signal. This is the digitized IF (center frequency of 200 kHz) of the analog portion of a FM broadcast station.
This is the spectrum of the digitized signal. This signal shows the effects of spectral leakage, which include a high noise floor as well as scalloping loss of the signal itself.

Spectral leakage, which honestly sounds like a really bad medical condition that I might have as I pass through middle age, creates problems in the spectrum. This includes scalloping loss (an improper amplitude level) and poor dynamic range. It is not something that has an equivalent in the analog world; it is strictly a problem of the digital spectrum. To alleviate these problems, a digital window is applied. A window is a set of weights applied to each point of the time record such that the ends are pushed to zero, or close to it.

This is the time domain view of the window weights for a 4-term Blackman-harris window.
This is the time record after it has been multiplied, on a point-by-point basis, with the window. Note that the ends of the time record have been set to zero.
This is the spectrum of the windowed time record.
This compares the windowed spectrum (black) with the unwindowed spectrum (red). Note that the noise floor above and below the signal are greatly reduced, but the sharpness of the peaks is also greatly reduced.

Windowing and Resolution Bandwidth

Windowing has several effects on the spectral trace. This includes the resolution bandwidth, the dynamic range, and amplitude accuracy.

The window used affects three, primary attributes of a spectral display. These are its amplitude accuracy (which varies due to scalloping loss), resolution bandwidth, and the peak sidelobe level (PSLL), which directly affects the dynamic range of the display. This window shows a continuous version (black) versus a discrete version (red). As windows are zeropadded (discussed below), the discrete version will approach the continuous version.
This is a comparison of two, different types of windows. The specific windows used is not as important as noticing that there are trade-offs between windows. The Hanning window (red) has a lower resolution bandwidth, but it also has worse dynamic range (due to its higher sidelobe levels) and it also has worse scalloping loss (amplitude inaccuracy, which is not visible in this image). The other window, a variation of a 4-term generalized cosine, has better amplitude accuracy and dynamic range, but higher RBW. This is why most systems provide multiple windows so that the correct window can be used depending on the requirements for spectral analysis.

There are a host of different windows possible. A good overview as well as analysis of different windows is fred harris' "On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform".

This is where we point out the difference between analog and digital resolution bandwidth. As fred harris pointed out (with my emphasis added):

The classic criterion for this resolution is the width of the window at the half-power points (the 3.0-dB bandwidth). This criterion reflects the fact that two equal strength main lobes separated in frequency by less than their 3.0-dB bandwidths will exhibit a single spectral peak and will not be resolved as two distinct lines. The problem with this criterion is that it does not work for the coherent addition we find in the DFT. The DFT output points are the coherent addition of the spectral components weighted through the window at a given frequency.
If two kernels are contributing to the coherent summation, the sum at the crossover point (nominally half-way between them) must be smaller than the individual peaks if the two peaks are to be resolved. Thus at the crossover points of the kernels, the gain from each kemel must be less than 0.5, or the crossover points must occur beyond the 6.0-dB points of the windows...it is the 6.0-dB bandwidth which defines the resolution of the windowed DFT.

"On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform", fredric harris, Proceedings of the IEEE, Vol. 66, No. 1, January 1978

Using the 6 dB point is not widely accepted. Instead, most systems use the normalized equivalent noise bandwidth (NENBW). The equivalent noise bandwidth (ENBW) is the bandwidth of an ideal, brickwall filter that passes the same amount of power as does the window spectrum. The normalized ENBW is an ENBW that has been scaled by the number of samples used to create the window. The NENBW does not have a point measurement such as with the 3 dB, 6 dB or 60 dB points on a filter spectrum. Instead, it must be calculated from the values of the window weights (discussed below) placed on the time record before it is input to the DFT.

Diagram showing equivalent noise bandwidth (ENBW). This bandwidth is the bandwidth expressed by an ideal rectangular filter (dashed line) that has the same power as the window spectrum (solid line). The "normalized" ENBW is the ENBW that is expressed as "bins", not "Hz". (Image credit: fred harris, "On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform", Proceedings of the IEEE, Vol. 66, No. 1, January 1978)

With the addition of windowing, the calculation for the resolution bandwidth is as follows:

RBW = β * fS / N = β * binwidth

where:

According to harris, the NENBW can be calculated as:

Equation to calculate the normalized equivalent noise bandwidth.

Where:
N = number of data samples in time record
w[n] = values for window

The table below lists some common windows and their respective 3 dB, 6 dB and NENBW window bandwidth factors.

Windowβ Value
3 dB BW6 dB BWNENBW
Uniform0.885891.2067131.000000
Hanning1.440582.0000001.500000
Hamming1.3029851.815231.362826
Blackman (approx)1.6436842.2988031.726757
4-Term Minimum Blackman-harris1.8994482.6664282.004353
Nuttall (used in Spike)1.9154622.6887502.021233
Stanford Research Flattop ("Flattop" in Spike)3.7311974.5926653.770164

For example, for the Blackman window using the NENBW, a 2.4 MHz sample rate, and a 2048 point DFT, the resulting RBW = (1.726757)(10e6)/(2048) = 2023.6 Hz. These are the settings and the RBW for the GQRX display shown below.

Spectral display from GQRX. The sample rate (fS) was 2.4 MHz, the time record was 2048 samples, and it uses a Blackman window. Assuming that the RBW is based on the NENBW, the RBW is 2023.6 Hz. The value of "RBW" shown here, 1.2 kHz, is actually the binwidth (2.4 MHz / 2048).
Spectral display from Airspy. The sample rate for this was 2.048 MHz, the time record consists of 16384 samples, and it uses a minimum 4-term Blackman-harris window. This provides a resolution bandwidth of (2.048 MHz)(2.0044)/(16384) = 250.5 Hz.

The FFT and Zeropadding

Up til now, we've talked about the discrete Fourier transform or DFT. The idea of calculating the spectral values digitally (e.g. with a computer) didn't really take off until Cooley and Tukey published their paper explaining how to perform the DFT in an extremely efficient manner. This is now what we call the fast Fourier transform or FFT. The most popular FFT algorithms require that the length of the time record must be a power-of-2. If the time record does not have a length that is a power-of-2, then the "fast" will not be as... fast.

Most basic spectral displays use a power-of-2. For example, the GQRX display is 2048 points (211), while the Airspy display is 16384 samples (214).

Spectral displays from GQRX. The FFT size is listed as 2048. This is a power-of-2 (211).
Spectral display from Airspy. This system is using a time record size of 16384. This is a power-of-2 (214).

Here's the problem. If the sample rate is fixed, then the available resolution bandwidths will be limited by the fact that the time record must be a power-of-2. If we adjust the number of samples in the time record (N), then it may not be a power-of-2. This is where zeropadding comes into play. We can literally add samples consisting of 0s to the end of the time record until the number of samples is a power-of-2. For example, look at the 700 point time record. By adding 324 0s to its end, we create a 1024 (210) time record.

The original, unmodified DFT requires N2 operations, while a full FFT only requires N*log2N. To give you an idea of the savings in computations by zeropadding, take a 1741 point time record. The number 1741 is a prime number. It cannot be factored. It would require the full N2, or 3031081, computations to calculate the DFT. But what if we added 307 zeros to the record? It would now be 1741 + 307 = 2048. This is a power-of-2. It would only require N*log2N = 2048*11 = 22528 computations. Despite the fact that the time record is larger, it would require less than 1/100th of the amount of calculations. It would also have the benefit of slightly reducing any amplitude inaccuracies.

Windowed time record consisting of 700 samples.
Windowed and zero padded time record. The record consists of 700 data samples and 324 zeros for a total of 1024 samples.

Looking at the zeropadded time record, it consists of two segments.

The total length of the time record is: N = Nd + Nz.

NOTE: If employing zeropadding, the time record should be windowed first, then zero padded.

The zero padded time record consists of two segments, the data segment (length = Nd) and the zero segment (length = Nz).

There are two things about zeropadding and the spectral display. These are:

  1. The resolution bandwidth only depends on the length of the data segment (Nd): If the time record was not zero padded, its length would be the Fourier transform convolved with the rectangular impulse. By adding zeros, there's no new information being added, which means that the resolution bandwidth will not change.
  2. The binwidth depends on the total length of the time record (N = Nd + Nz): Zeropadding does not add any new information, but it will lower the binwidth. The result of this on real world signals is that, as more zeros are added, the DFT becomes closer to being the discrete time Fourier transform (DTFT), meaning that the time domain is discrete, but the spectrum is continuous.

The Variable RBW

Signal Hound's Spike software is different from most other software for SDRs. It allows the user to create a user-provided resolution bandwidth. How does it do this? Remember how the RBW is calculated for a DFT:

RBW = β fS / Nd

where:

Given a particular window, there are two variables that can be adjusted to create a variable bandwidth spectral display. These are the sample rate and the length of the data segment. It's typically easier to keep the sample rate fixed, and adjust the number of samples collected into the data segment of the time record. This is precisely what Spike does.

Spike takes the user-provided resolution bandwidth, a fixed sample rate[1], the chosen window (Nuttall or flattop for the BB60C), and calculates the number of samples needed in the data segment. It zero pads the rest of the time record to make it a power-of-2, then calculates the FFT of the time record.

The calculation for the required number of data samples can be found by re-arranging the equation above.

Equation used to calculate the number of samples for a particular RBW and window bandwidth factor.

Where:
Nd = number of data samples in time record
NENBW = normalized equivalent noise bandwidth
fs = sample rate of Signal Hound device (= 40 MHz for BB60C)
RBW = desired resolution bandwidth

Take the following example showing the FM broadcast band using the user-provided resolution bandwidth of 30.33 kHz using a Nuttall window. This particular Nuttall window has a NENBW = 2.0212.

Signal Hound Spike program with a variable resolution bandwidth of 30.33 kHz and a Nuttall window controlling a BB60C. The BB60C uses a fixed sample rate of 40 MHz. This particular Nuttall window has a NENBW = 2.0212. These values mean that the length of the data segment must be Nd = (40e6)(2.0212)/(30.33e3) = 2665.61 samples. Samples cannot be fractional. Therefore, the number of samples used must either be 2665 or 2666. Most likely (a guess on my part), the value is rounded to the nearest integer, meaning that this would be 2666 samples. The record is windowed with the Nuttall window, zero padded to the next, highest power-of-2 (4096), then input to the FFT routine.

Since we're talking about the Spike software, there's one other aspect of the spectral display. With the fixed sample rate (40 MHz) and the length of the time record (8192 points once zero padded), this means that the binwidth is (40e6)/(4096) = 9765.6 Hz. Given the set span of 25 MHz, this requires a total of (25e6)/(9765.6 Hz) = 2560 points. Note that that is the length of the sweep (shown in the lower, righthand corner just underneath the "Stop" frequency of the display.

The Detector

As if this wasn't complicated enough, there are a couple of other parameters with respect to spectral displays. When spectrum analyzers began switching from analog to digital displays in the mid 1970s, they discovered a problem. Analog displays, because they were continuous in frequency, showed every, possible spectral point. Digital displays were different. Digital displays are similar to the screen on which you're reading this. They have a finite resolution. Engineers had to figure out how to display an infinite number of points on a finite display. The local oscillator (LO) tuner steps at some fraction of the resolution bandwidth. The RBW, in turn, is a fraction of the overall span. This means that a display may have thousands of points of spectral data, but only hundreds of actual display points. Some mechanism must be used to reduce the spectral points to the available display points. This led to the use of detectors. There are a myriad of different detector types, but their purpose is the same. A detector reduces the number of spectral points collected to those that can be displayed on the available screen size.

Spectral displays showing different detector types and their effect on the spectral display. (Image source: "Hewlett-Packard 8566A Spectrum Analyzer Operation", Hewlett-Packard, November 1978.)

Digital systems add an additional parameter, time. The reason for this harks back to the concept of windowing (discussed above). While windowing reduces issues related to spectral leakage (poor dynamic range, scalloping loss), it also reduces the amount of signal available to process.

This shows how a time record will appear before (red) and after (black) being windowed. Note that the red part of the display is part of the signal that has been attenuated if not completely eliminated. That's signal loss.

To deal with this problem, some systems now use overlapping windows. This means the system collects a time record, then subdivides the time record into a series of overlapping, windowed time records.

To avoid the problem of too much signal loss as well as to deal with potentially losing short-duration signals that occur near the ends of a window, systems employ overlapping windows. This is a 4096-point time record that has been subdivided into three 2048 point time records. Each of the subdivided records is windowed, fed into the DFT or FFT, and either displayed, or used to feed a detector similar to those discussed earlier. In this case, the points are not spread out in frequency, but in time. Each spectral point will be represented by a number of points determined by the number of overlapping windows. For example, this time record shown would have each spectral point represented by three points. A detector of some type (sample, normal, maximum, minimum, average) would be used to decide which point or points to use to display each point.

Most, basic SDRs do not provide overlapping windows to create spectral displays. Signal Hound's Spike is no ordinary SDR software. It's default is to collect a certain time, subdivide the collected time record into a series of overlapping windowed time records (with the length of each windowed time record determined by the resolution bandwidth), zeropad each record such that it is a length that is a power-of-2, calculate the FFT of each record, then use the detector to calculate the actual displayed value.

The amount of time with which Spike collects data is listed on the right of the screen as "Swp Time". The default value is 1 msec. Spike will attempt to collect 1 msec of data for each step of the tuner. With its 40 MHz sampling rate, its collecting (40e6)(1e-3) = 40,000 samples for each step. Given that most resolution bandwidths only require a few hundred to a few thousand samples per time record, this provides the ability for Spike to create many overlapping windowed time records.

Spike screen showing the requested sweep time (rightmost column) and measured sweep time (lower entry).

Take, for example, a spectral trace with 100 kHz RBW and the Nutall window. The number of data points would be:

Nd = (40e6)(2.01212)/(100e3) = 808.48 ≈ 808 points

The amount of time that the digitizer is actively collecting data samples is called the acquisition time. The FFT will need 1617 samples to provide the requested 100 kHz RBW. The first 1617 samples will come from the beginning of the acquired 40,000 sample time record. After that, the samples chosen for each subdivision is determined by the amount of overlap. The amount of overlap is determined by the window chosen. Windows that suppress more of the signal require greater overlap to compensate for it. For the particular Nuttall window used, the optimum amount of overlap will be roughly 66%. This equates to roughly (2/3)(808) = 539. This means that the second data set will use 539 samples from the first data set, and only 808 - 539 = 269 new samples. It will continue this until all 40000 samples have been used. This will allow for roughly (40000)/269 ≈ 149 FFT records. This, in turn, means that each frequency point will be represented by 149 different samples.

Which leads back to the detector. Spike provides four detectors with which we can choose from this dataset. These are sample, minimum, maximum, and average. Spike also allows for the display of something called "min/max". In this case, probably every displayed odd sample is the "max" value, while every displayed even sample is the "min" value.

All of this, the acquisition time, plus the time required to calculate all of the FFTs and display the final result, called the processing time, leads to the measured sweep time. That's the value displayed below the spectral trace.

The Binwidth and Span

The last part is to pull out the number of frequency points needed for the desired span. Digital displays use discrete frequency points. The span must be an integer number of frequency points. This means that arbitrary spans are not possible. It can only be within 1/2 of a binwidth.

Signal Hound's Spike display provides the number of points used to create the desired span. This display shows a span of 2.5 MHz. Just below the lower, right corner of the display, Spike lists the number of frequency points used to create this span. In this case, it's 8192. This means that Spike is using a binwidth of roughly 305.176 Hz. Given how Spike uses zeropadding to create power-of-2 time record lengths and how it has a fixed sample rate 40 MHz), the time record length can be calculated as (40e6)/(305.176) = 131072, or 217 samples.

Summary of Steps to Create Digital Spectral Display

This is the flow of a basic spectral display. This does not take into account zeropadding, overlapping windows, or detection.

Step #1) Collect the data samples into a time record. These are the data samples that will ultimately be fed into the fast Fourier transform (FFT). This particular time record consists of 700 samples.

Step #2) Window the data. This is how the windowed time record appears. Again, the window does nothing more than weight the amplitudes of the samples in the time record. By having the ends approach or be set to zero, this alleviates much of the scalloping loss and spectral leakage when the time record is fed into the DFT algorithm.

Step #3) Calculate the FFT of the windowed time record. This is the spectrum of the windowed time record after it has been passed through the FFT. The last part of this step is to calculate the power of each spectral point to make it either a "dB" or (if calibrated) "dBm".

Resolution Bandwidth As Stated in Various Programs

I've played around with many, different software defined radios. This includes the already-mentioned Signal Hound BB60C, the Great Scott Gadget's HackRF One, several, different RTL-SDRs, the LimeSDR Mini, and a SDRplay RSP1A. All are controlled from software, whether it's GQRX, Gnu Radio Companion, Airspy's SDR#, HDSDR, or CubicSDR. All of the SDRs provide complex samples to this software, and the software performs the calculations that create the spectral displays. All of these programs provide spectral displays. Most do not provide resolution bandwidth (RBW) values, despite the fact that they do have measurable resolution bandwidths.

Spectral displays from CubicSDR. This program does not provide any information on the available RBW.
Spectral displays from GQRX. This provides a "RBW" measurement in the upper, righthand corner. This is under the "FFT Settings" tab. However, this is not actually "RBW"; this is bin width, which we'll discuss below.
Spectral displays from HDSDR. This shows a RBW value just above the baseband waterfall, and probably refers to the RBW of the baseband (demodulated). There's no information on the RBW of the RF spectral display and waterfall on the top of the window.
Spectral display from Gnu Radio Companion using the "QT GUI Frequency Sink" block. This does not provide any information on the RBW.
Spectral display from Airspy. While Airspy does not provide any information on the RBW, it does provide all of the information necessary to calculate it.
Spectral display from Spektrum program. This program allows you to set the sample rate and bin width, but does not provide any information on the windowing used for the FFT.
Spectral display of Signal Hound Spike software. This shows the RBW both above the spectral display and in the user selection window in the lower, righthand corner. Spike uses the Signal Hound API, which is able to create a variable-width RBW that is user settable. (UPDATE 2022-09-10: The flattop window NENBW was set to 3.2 for this version of Spike, but it was changed to the standard Stanford Research flattop NENBW = 3.7702 as of version 3.5.21.)

CORRECTION: Based on a misreading (my bad) of the Signal Hound BB60C Manual, I first stated that the sample rate of the BB60C was 40 MHz, then I corrected that to 80 MHz. So, which is it? It's 40 MHz. How do I know that? Two places. First, here's the problematic statement in the BB60C manual (my emphasis added):

From the ADC, digitized IF data is handed off to an FPGA where it is packetized. The Cypress FX3 peripheral controller streams the packetized data over a USB 3.0 link to the PC, where 80 million, 14-bit ADC samples per second are processed into a spectrum sweep or I/Q data stream.

The key is "processed into a spectrum sweep or I/Q data stream." In other words, it's 80 million samples, but they've not been turned into IQ samples as that term is understood. An IQ sample is actually two samples, an I (in-phase) and Q (quadrature), that, together, are considered one "IQ sample".

This leads to the second way I know that the sample rate is actually 40 MHz. The Signal Hound BB60 API shows a table for the "bbConfigureIQ" statement. The first line of the table shows "Sample Rate (IQ pairs/s)", and a decimation rate of "1". This is thus the sample rate of the system.

Sigh. I've corrected the post. Again. Hopefully for the last time.

Here's a Random Fact...