0
$\begingroup$

I have collected data from an oscillating system where angle values change over time and I am interested in identifying frequencies in my oscillations.

Given that my sampling frequency is $f_s = 1$ GHz (i.e sampling period of 1 nanosecond), I have provided $f_s$ to the software I am using in order to obtain the DFT because I want the DFT output data to tell me directly what frequencies in Hz are present in my raw data of oscillations.

Is this the correct thing to do? In other words, if I want the DFT output to show me directly, with no manipulations, what frequencies, in Hz, are in my raw data by looking at the peaks in the plotted DFT data, did I do the right thing? Should I have instead normalized my sampling frequency or manipulated it in some other way before providing it to the FFT algorithm?

$\endgroup$
1
  • $\begingroup$ "I have provided $f_s$ to the software I am using" - this sounds like the software is designed to "understand" that. If it does, indeed, account for $f_s$ properly -- sure, you get an answer that's directly human-readable. But it sounds like maybe you're the one writing that software? Could you clarify by editing the question appropriately whether you wrote the software, and if not, what software you are using? $\endgroup$
    – TimWescott
    Commented Oct 23, 2022 at 23:25

1 Answer 1

1
$\begingroup$

Not sure what software you are using, but I'm going to assume a couple things here:

  1. Your software's DFT routine is implemented with an FFT (Fast Fourier Transform) of some kind.
  2. Regardless of if your software's DFT routine takes $f_s$ as an input or not, I'm guessing you can also specify $N_{\tt fft}$, the FFT length, as an input as well.

If you want to "read" the frequency content of your signal directly from a DFT plot, then you need to:

  1. Choose a frequency resolution $dF$ you're happy with (that's how much the frequency bins are going to be spaced about, i.e what frequencies you'll be able to read from your DFT output). The formula for frequency resolution is $$dF = \frac{f_s}{N_{\tt fft}}$$

  2. Derive the FFT length (how much of the signal you input to the FFT routine, including zero-padding): for such high sampling frequency, I'd recommend an appropriate power of 2, but that's not a hard requirement. For example, say you're happy with $dF = 1000\,\text{Hz}$, then $$N_{\tt fft} = 2^{\text{nextPow2}(f_s/1000)} = 2^{20}$$

  3. Call your DFT function: should look something like S = DFT(raw_signal, Nfft). If fs is indeed an input, then most likely your software has the plotting included and you can dis-regard points 4) and 5). The call to your DFT function would then be something like S = DFT(raw_signal, Nfft, fs)

  4. Create your frequency vector. Again, depending on the software used, S will be two-sided (it will include the negative frequencies) or not, but regardless you need to scale the x-axis based on $dF$: each frequency bin $n$ holds the frequency content at $n \cdot dF\,$ $\text{Hz}$ so your x-axis should look something like

    f = (0:dF:fs-dF)

  5. Plot the DFT magnitude and/or phase: that will look something like plot(f, abs(S)) for the magnitude.

Let me know if that helps. Please provide which software you are using, so I can tailor my answer better. If your software has the plotting already taken care of, then you most likely only need to consider points 1) through 3). Just know that under the hood, it's doing 4) and 5)

$\endgroup$
3
  • $\begingroup$ Thanks for your answer. I will admit, I'm a stranger to DSP so a lot of your answer has flown over my head. The software I'm using is called "JDSP" for the Java programming language and it's supposed to have MatLab-like APIs. 'fs" (at least this is what it's called in the docs) is indeed an input to the method to get my frequency bins (called "getFFTFreq") and a boolean to indicate if I want just the positive results is also an input. The documentation to this "getFFTFreq" method is found at: javadoc.io/doc/com.github.psambit9791/jdsp/latest/index.html - under "FastFourier" $\endgroup$ Commented Aug 22, 2022 at 3:43
  • $\begingroup$ Ok, so then go through 1) and 2) to define the parameters you need, and use the API provided to: - compute the frequency vector ("getFFTFreq") $f$ - compute the DFT $T$ - compute the Magnitude of $T$, $MAG$ - plot the frequency vector $f$ on the x-axis and the Magnitude $MAG$ on the y-axis. If you're asking how to use the API, that's a different question and you should spend time getting familiar with it before asking! $\endgroup$
    – Jdip
    Commented Aug 22, 2022 at 13:37
  • $\begingroup$ If you're still struggling, let me know, we can always take this to a chat room where I can provide more guidance. $\endgroup$
    – Jdip
    Commented Aug 22, 2022 at 13:43

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.