1
$\begingroup$

I was doing some basic work recently using an FFT to process real valued data that consists of two tones. The tones always have the same spacing and are never present in the signal together. We can assume the following parameters

  • Tone A: 300 Hz
  • Tone B: 1300 Hz
  • Sample Rate: 44100

My tone spacing is 1000 Hz. I want my FFT to identify the presence of either tone. If I understand correctly the bins of the FFT have a width of 44100/N where N is the length of the FFT. So if I just set N=128 I have a bin width of 344.5 Hz. This is reliable enough to identify each tone, since the two tones are at least 5 bins apart.

But this requires each tone to present for at least N*2, to even have a chance of identifying it uniquely it would seem. I cannot guarantee my sample of my FFT are input "in sync" with whatever is generating the tones. Realistically the number seems to be something more like N*4 for reliable identification.

The obvious solution is to make N smaller, but then the bins with two tones eventually merge. So my thought was why not just analyze the harmonics of the signal? Before doing the frequency-domain analysis, I can just apply a time domain filter to generate the harmonics of the incoming signal. The tone spacing should double at each harmonic.

Before each sample is sent to the FFT, I just multiplied each sample with itself. This generates the second harmonic of the input signals. This has the effect of making the signal DC. This is easy enough to ignore by just removing the top and bottom bins of the FFT from my analysis (I don't think they are useful anyways). Now my tone spacing is doubled, so I can halve N in my FFT to get the same result. The signal sample rate is still the same.

Obvious drawbacks

  1. Signal is 100% DC after generating 2nd harmonic
  2. Signal bandwidth is now S/4 instead of S/2

Neither of these seem to be serious drawbacks. Is there some other drawback of pitfall to this approach for analyzing a signal? Am I not actually gaining useful resolution in this process & it just looks like it does?

$\endgroup$
7
  • 1
    $\begingroup$ There can be pitfalls with this approach in the presence of noise. Squaring a signal will reduce the signal-to-noise ratio, so it can negatively impact your detection performance when the input SNR is sufficiently low. I'm not sure what you mean by "Signal is 100% DC" though. To answer your final question, no, you aren't gaining any useful resolution, because there is no additional information in the squared signal that wasn't there before. I'm not clear on exactly what your end goal is, so I'm not sure of a different approach to suggest. $\endgroup$
    – Jason R
    Commented Jan 4, 2023 at 4:53
  • $\begingroup$ We can assume the following parameters: are you saying you’ll always be looking around 300 and 1300 hz? Or you’ll always have two tones 1000hz apart but could be anywhere in the spectrum? $\endgroup$
    – Jdip
    Commented Jan 4, 2023 at 8:25
  • $\begingroup$ the second one. There could be some drift in the tones, but the spacing would maintain 1000 Hz. $\endgroup$
    – Eric Urban
    Commented Jan 4, 2023 at 14:47
  • $\begingroup$ With $N = 128$ the bin width is actually $344.5\,\texttt{Hz}$. Still, with interpolation you can increase the precision of your spectrum. Zero-pad your signal before taking the FFT. $\endgroup$
    – Jdip
    Commented Jan 5, 2023 at 10:53
  • $\begingroup$ Wouldn't that only be the case for an FFT of a complex signal? $\endgroup$
    – Eric Urban
    Commented Jan 5, 2023 at 11:14

2 Answers 2

1
$\begingroup$

I wonder if matched filtering (correlating with templates of both a 300Hz and a 1300Hz tone might be more robust than using an fft here?

$\endgroup$
0
$\begingroup$

Your frequency resolution is $f_s/N = 44100/128 = 344.5 \,\texttt{Hz}$. Like you said, that means that you can have two frequency components $1000\,\texttt{Hz}$ apart and be able to differentiate between them, as long as they fall exactly in the correct bins.

What you need is then to increase the precision of your spectral representation by zero-padding.

For example, with a sampling rate $f_s = 44100\,\texttt{Hz}$ and $\texttt{FFT}$ length $N = 128$, without zero-padding, your frequency bins are (in $\texttt{Hz}$): $$0, 344.5, 689, 1033, 1378, \dots$$ so for an input signal with two components at $300\,\texttt{Hz}$ and $1300\,\texttt{Hz}$, you'll have peaks at the bins corresponding to $344.5\,\texttt{Hz}$ and $1378\,\texttt{Hz}$.

Zero pad to, say, $N = 4096$, and you now have frequency bins at $$ 0, 10.7, \dots, 301.46, \dots, 1302.76, \dots$$ Now your peaks will fall in bins that correspond to frequencies closer to your true input frequencies.

I also suggest windowing your data before taking the $\texttt{FFT}$ to avoid excessive spectral leakage.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.