FFT: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
No edit summary
No edit summary
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:Block Docs]]
[[Category:Block Docs]]
This block takes in a vector of floats or complex values and calculates the [https://en.wikipedia.org/wiki/Fast_Fourier_transform FFT].  If all you do is want to see the frequency domain of a signal, the [[QT GUI Frequency Sink]] is more user friendly.  Note that even if the input signal is real, the output will be complex, so you must use a [[Complex to Mag]] or similar block if you want to see magnitude.  
This block takes in a vector of floats or complex values and calculates the [https://en.wikipedia.org/wiki/Fast_Fourier_transform FFT].  If all you do is want to see the frequency domain of a signal, the [[QT GUI Frequency Sink]] is more user friendly.   
 
Note that even if the input signal is real, the output will be complex, so you must use a [[Complex to Mag]] or similar block if you want to see magnitude.  


== Parameters ==
== Parameters ==
Line 11: Line 13:


; Window
; Window
: Type of window to apply to each set of samples before the FFT is taken, default is a blackmanharris window. The argument of the window.blackmanharris() function is simply how many points in the window, which must match the FFT size.
: Type of window to apply to each set of samples before the FFT is taken, default is a blackmanharris window. The argument of the window.blackmanharris() function is simply how many points in the window, which must match the FFT size. If an empty window "[]" is supplied then no windowing math is performed.
 
; Shift
; Shift
: Whether or not to do an "fft shift" which puts DC (0 Hz) in the center.  If you are not sure what this means, leave it set to Yes. Only active when input type is complex.
: Whether or not to do an "fft shift" which puts DC (0 Hz) in the center.  If you are not sure what this means, leave it set to Yes. Only active when input type is complex.
Line 21: Line 22:
== Example Flowgraph ==
== Example Flowgraph ==


This flowgraph shows how the FFT block can be used to reproduce the behavior of the [[QT GUI Frequency Sink]] block.  Both outputs match (besides an arbitrary scaling factor), but using the FFT block directly requires converting from a stream to vector, and performing the magnitude and log manually.  
This flowgraph shows how the FFT block can be used to reproduce the behavior of the [[QT GUI Frequency Sink]] block.  Both outputs match, but using the FFT block directly requires converting from a stream to vector, and performing the magnitude and log manually.
 
[[File:Psd1.PNG]]
 
The 'fast multiply const' block multiplies by 1/vector_length. The Log10 block multiplies also by 10 (n=10).
 
[[File:Psd2.PNG|1500px]]
 
Injecting a constant value waveform (amplitude of 1) and applying a rectangular window gives us an impulse (Dirac delta). The peak value has its maximum value at 0 dBfs, telling us that the reference is a vector containing ones.


[[File:Fft-ex.png|700px]]
[[File:Psd3.PNG|1500px]]


[[File:Fft-ex-output.png|700px]]


== Source Files ==
== Source Files ==
Line 39: Line 47:


; Public header files
; Public header files
: [https://github.com/gnuradio/gnuradio/blob/master/gr-fft/include/gnuradio/fft/fft_vcc.h Complex input Public header file]
: [https://github.com/gnuradio/gnuradio/blob/master/gr-fft/include/gnuradio/fft/fft_vcc.h Complex input]
: [https://github.com/gnuradio/gnuradio/blob/master/gr-fft/include/gnuradio/fft/fft_vfc.h Real input ]
: [https://github.com/gnuradio/gnuradio/blob/master/gr-fft/include/gnuradio/fft/fft_vfc.h Real input ]


; Block definition
; Block definition
: [https://github.com/gnuradio/gnuradio/blob/master/gr-fft/grc/fft_fft_vxx.block.yml GRC yaml]
: [https://github.com/gnuradio/gnuradio/blob/master/gr-fft/grc/fft_fft_vxx.block.yml GRC yaml]

Latest revision as of 19:38, 26 May 2022

This block takes in a vector of floats or complex values and calculates the FFT. If all you do is want to see the frequency domain of a signal, the QT GUI Frequency Sink is more user friendly.

Note that even if the input signal is real, the output will be complex, so you must use a Complex to Mag or similar block if you want to see magnitude.

Parameters

FFT Size
Number of samples used in each FFT calculation, which also determines how many points are in the output.
Forward/Reverse
Whether to do an FFT or IFFT.
Window
Type of window to apply to each set of samples before the FFT is taken, default is a blackmanharris window. The argument of the window.blackmanharris() function is simply how many points in the window, which must match the FFT size. If an empty window "[]" is supplied then no windowing math is performed.
Shift
Whether or not to do an "fft shift" which puts DC (0 Hz) in the center. If you are not sure what this means, leave it set to Yes. Only active when input type is complex.
Num Threads
Number of threads to assign to perform the FFTs.

Example Flowgraph

This flowgraph shows how the FFT block can be used to reproduce the behavior of the QT GUI Frequency Sink block. Both outputs match, but using the FFT block directly requires converting from a stream to vector, and performing the magnitude and log manually.

Psd1.PNG

The 'fast multiply const' block multiplies by 1/vector_length. The Log10 block multiplies also by 10 (n=10).

Psd2.PNG

Injecting a constant value waveform (amplitude of 1) and applying a rectangular window gives us an impulse (Dirac delta). The peak value has its maximum value at 0 dBfs, telling us that the reference is a vector containing ones.

Psd3.PNG


Source Files

C++ files
Complex input
Real input
Core algorithms
Header files
Complex input
Real input
Public header files
Complex input
Real input
Block definition
GRC yaml