Help to calculate FFT from IQ data

Status
Not open for further replies.

tjhoeft

Member
Joined
Jan 8, 2016
Messages
3
Hello all,
I am relatively new to digital signal processing and software defined radio. I recently purchased a HackRF one to experiment with. After going through Mike Ossmann's great video tutorial series, I decided that I wanted to play around with calculating my own frequency transform given raw IQ timeseries samples. I've played around with the FFT in the kilohertz range but never in the gigahertz range. I am trying to write an FFT algorithm to process the 2.4 GHz ISM band.

From my understanding of the FFT, one needs to choose the upper frequency bound that they choose to observe and collect twice the number of samples. However, this does not seem to make sense when I observe GNU radio plot the FFT. According to my calculations, the sample rate of the hack RF would require almost 11 minutes of data before being able to calculate an accurate FFT snapshot. How then can GNU radio produce its FFT snapshots almost instantaneously?

I talked to an engineer friend of mine who said that this is largely dependent on the data acquisition hardware. He mentioned that hardware requires the use of intermediate frequencies in order to generate measurements corresponding to the gigahertz range. And as a result of using intermediate frequencies, there is an associated instantaneous bandwidth. This is where things get fuzzy for me. I understood from school that the Nyquist criterion is relative to the maximum frequency expected to be observed. However, I understood from my friend that the Nyquist criterion is applied to the instantaneous bandwidth in order to determine the minimum number of samples required. That's a huge difference between 2.4 GHz and 20 MHz of instantaneous bandwidth for the hack RF.

As a software developer, I want to learn how to calculate spectra given the IQ timeseries data input from the hack RF. Currently, it does not make sense. If I use the 2.4 GHz frequency as my Nyquist criterion, the FFT will be huge and high in time complexity. If I use the 20 MHz frequency as my Nyquist criterion, the FFT will be relatively small and low in time complexity, but I'm not sure what that really means. Is the spectrum somehow shifted? Is there another transform involved? Or is my friend just plain wrong?

I'm looking for ideas and examples. Any help would be much appreciated.

Thank you very much,
TJ
 

slicerwizard

Member
Joined
Sep 19, 2002
Messages
7,643
Location
Toronto, Ontario
From my understanding of the FFT, one needs to choose the upper frequency bound that they choose to observe and collect twice the number of samples.
No. The number of input I/Q pairs should be a power of 2, typically a few k (like 4096) up to 1 M (1048576) or more. The choice is typically driven by the I/Q sampling rate, e.g. how much data can be gathered in a tenth of a second or so, and then used to update a display ~10 times per second.

Also, doubling the number of FFT inputs will quadruple the processor load, which will set an upper limit based on the capabilities of your machine. Larger sizes also overload CPU caches, which leads to stalls while cache lines are refilled.

Fewer samples = faster, coarse, blocky spectrum display

More samples = slower, higher resolution display showing finer details
 

tjhoeft

Member
Joined
Jan 8, 2016
Messages
3
Min samples for 2.5GHz resolution

Thank you very much for your response. If I understand what you’re saying, I will need to capture and maintain a buffer of IQ data having a buffer size that is a power of two; and that is a requirement of the FFT algorithm.

I would like to write my own data acquisition code to calculate FFT snapshots in order to interpret Wi-Fi signals. If I would like to calculate a FFT having a Nyquist frequency of 2.5 GHz and I have a piece of hardware like the HackRF serving as my data acquisition unit (sample rate of 10 MHz and bandwidth of 20 MHz), I should be able to calculate FFT snapshots similar to existing Wi-Fi cards.

If I’m attempting to calculate a frequency at 2.5 GHz, the Nyquist criterion states that I will need double the number of samples (5 billion samples). On the other hand if I use the metric that you provided of 1/10 of a second time slice and my sample rate is 10 MHz, then I would expect I would only have 1 million samples to work with. That 1 million samples is far below the 5 billion samples needed to resolve the 2.5 GHz upper bound.

When you mention the greater number of samples collected implies the greater the frequency resolution, intuitively that makes sense. Still, isn’t the lower bound associated with measuring 2.5 GHz still 5 billion samples? Or more specifically, how do I calculate the minimum number of samples that I require in order to emulate what’s going on in a Wi-Fi card?

I appreciate any help,
TJ
 

DSheirer

Member
Premium Subscriber
Joined
Feb 15, 2010
Messages
582
Location
Fulton, NY
From my understanding of the FFT, one needs to choose the upper frequency bound that they choose to observe and collect twice the number of samples. However, this does not seem to make sense when I observe GNU radio plot the FFT. According to my calculations, the sample rate of the hack RF would require almost 11 minutes of data before being able to calculate an accurate FFT snapshot. How then can GNU radio produce its FFT snapshots almost instantaneously?

You might be confusing the center tuned frequency with the bandwidth/sample rate frequency. When you select your center frequency (2.4 GHz), the HackRF is down-converting (mixing) the signal to baseband (0 Hz) before it begins sampling the signal. So, if you choose a sample rate of 10 MHz, the HackRF ADC is sampling a signal that appears to be centered at -5 Mhz to +5 MHz. Without the down-conversion, the sample rate would have to be extremely large and you would be sampling everything from 0 to 2.4 GHz.

The Nyquist criterion applies to the sample rate and bandwidth. In order to accurately capture a 10 MHz wide chunk of spectrum, you need to sample that spectrum with twice the bandwidth (20 MHz) for real samples or sample at 10 MHz for complex (I/Q) samples. The 10 MHz wide chunk of spectrum will be centered about your center tuned frequency with 5 MHz to the left ( 2.4 GHz - 5 MHz) and 5 MHz to the right ( 2.4 GHz + 5 MHz).

The size of your FFT (number of bins) will dictate the frequency resolution of each bin. A 4-point FFT would give you 4 bins with each bin representing the sum of the signals in each 2.5 MHz chunk of spectrum. The 4 bins would represent the full bandwidth (4 x 2.5 MHz = 10 MHz). The frequency for the center of each bin would be: 2.4 GHz - 3.75 MHz, 2.4 GHz - 1.25 MHz, 2.4 GHz + 1.25 MHz, and 2.4 GHz + 3.75 MHz.

As Andy indicated, choosing an FFT bin size that is a power of 2 allows you to calculate the FFT using the more efficient DFT algorithm.

cheers,
Denny
 
Last edited:

tjhoeft

Member
Joined
Jan 8, 2016
Messages
3
Thank you!

I think I understand it much better now. I appreciated your detailed response! Time to jump in and experiment.

Thanks again,
TJ
 
Status
Not open for further replies.
Top