The physical meaning of FFT algorithm

Source: Internet
Author: User
Tags cos modulus

FFT is a high-speed algorithm for discrete Fourier transform, which can transform a signal
to the frequency domain. Some signals are very unsightly in the time domain, but as
When the fruit is transformed into the frequency domain, it is very easy to see the features. That's a lot of signals.
Analyze the reason of using FFT transform. In addition, the FFT enables the spectrum of a signal to be
Extracted, which is often used in spectral analysis.

Although very many people know what the FFT is, what can be used to do, how to
Do, but do not know what the result after the FFT is, how to decide to use
How many points to do the FFT.

Now the circle is based on practical experience to say the detailed physical meaning of the FFT results.
An analog signal, after the ADC sample, becomes a digital signal. Sample
Theorem tells us that the sample frequency is more than twice times the signal frequency, which I
No more wordy here.

The digital signal obtained by the sample can be converted by FFT. n A sample point,
After the FFT, we can get the FFT result of n points. To facilitate the FFT
operation, usually n takes 2 of the entire number of times.

If the sample frequency is FS, the signal frequency F, the sample count is N. So FFT
The result then is a complex number of n points. Each point corresponds to a frequency
Point. The modulus of this point is the amplitude characteristic under the frequency value. Detailed with the original
What does the amplitude of the signal matter? If the peak value of the original signal is a, then the FFT
The modulo value of each point (except the first point DC component) of the result is a
N/twice times. And the first point is the DC component, its modulus is the DC component
of n times. And the phase of each point is the phase of the signal at that frequency.
The first point represents the DC component (that is, 0Hz), and the last point n is the next
Point (In fact this point does not exist, here is if the first n+1 point, Also
Can be seen as a two-and-a-half, and half to the last, of the first point.
Sample frequency FS, which is divided by N-1 points evenly into n equal parts, the frequency of each point
Add it in turn?. For example, a point n is expressed as a frequency of: fn= (n-1) *fs/n.
As can be seen from the above formula, FN can distinguish the frequency as fs/n, if
Sampling frequency FS is 1024Hz, the sample number is 1024 points, you can distinguish to 1Hz.
1024Hz sample rate of 1024 points, just 1 seconds, that is, the sample 1 seconds
Time signal and do the FFT, the result can be analyzed to 1Hz, if the sample 2 seconds
Signal and do the FFT, the result can be analyzed to 0.5Hz. If you want to increase the frequency
Resolution, you must add a sample point, that is, the sample time. Frequency resolution and
Sampling time is the reciprocal relationship.
If a point n is represented by a complex a+bi after the FFT, then the modulus of the complex number is
An= Radical A*a+b*b, Phase is pn=atan2 (b,a). Based on the above results,
The expression of the corresponding signal of N point (n≠1, and N<=N/2) can be calculated as:
an/(N/2) *cos (2*PI*FN*T+PN), or 2*an/n*cos (2*PI*FN*T+PN).
For the n=1 point signal, is the DC component, the amplitude is a1/n.
Because of the symmetry of the FFT results, we usually only use the results from the first half,
The result is less than half the sample frequency.

Well, said for a long while, look at the formula also dizzy, the following circle with a practical
Signal to do the explanation.

If we have a signal, it contains 2V DC components at a frequency of 50Hz,
The phase is 30 degrees, the amplitude is 3V AC signal, and a frequency of 75Hz,
An AC signal with a phase of 90 degrees and a amplitude of 1.5V. The mathematical expression is for example the following:

S=2+3*cos (2*pi*50*t-pi*30/180) +1.5*cos (2*pi*75*t+pi*90/180)

The Cos in the formula is in radians, so 30 degrees and 90 degrees are converted into radians respectively.
We sample this signal at a sample rate of 256Hz, a total of 256 points.
According to our analysis above, fn= (n-1) *fs/n, we are able to know that every two
The spacing between points is 1Hz, and the frequency of the nth point is n-1. Our signal.
There are 3 frequencies: 0Hz, 50Hz, 75Hz, should be at the 1th Point, the 51st Point,
At the 76th point there is a spike, and the other points should be close to 0. What is the actual situation?
Let's look at the modulus of the results of the FFT.

Figure 1 FFT results
We can see that in the 1th, 51st, and 76th vicinity there are
A larger value. We will take a closer look at the data near these three points:
1 points: 512+0i
2 points: -2.6195e-14-1.4162e-13i
3 points: -2.8586e-14-1.1898e-13i

50 points: -6.2076e-13-2.1713e-12i
51 Points: 332.55-192i
52 Points: -1.6707e-12-1.5241e-12i

75 point: -2.2199e-13-1.0076e-12i
76 points: 3.4315E-12 + 192i
77 points: -3.0263E-14 +7.5609e-13i
  
     obviously, the value of 1 points, 51 points, 76 points is relatively large, near the point value
is very small, can feel is 0, that is, at those frequency points of the signal amplitude of 0.
Next, let's calculate the amplitude values for each point. The three-point modulo values are calculated separately, and the
results are as follows:
1 points: 51 points: 384
76 points: 192
    According to the formula, the DC component can be calculated as: 512/n=512/256=2; The amplitude of the
50Hz signal is: 384/(N/2) =384/(256/2) =3;75hz signal
Amplitude is 192/(N/2) =192/(256/2) = 1.5. It can be seen that the amplitude of the
from spectrum analysis is correct.
    then calculate the phase information. The DC signal does not have a phase, and it is not necessary to control
. The phase of the 50Hz signal is calculated first, atan2 ( -192, 332.55) =-0.5236, the
result is radians, and the conversion angle is 180* ( -0.5236)/pi=-30.0001. Then
calculate the phase of the 75Hz signal, atan2 (192, 3.4315E-12) =1.5708 radians,
converted to an angle is 180*1.5708/pi=90.0002. It can be seen that the phase is also true.
based on the FFT results and the above analysis, we are able to write out the expression of the signal
, which is the signal we started to provide.

Summary: If the sample frequency is FS, the sample count is N, after doing the FFT, a
A point n (n starting from 1) is expressed as: fn= (n-1) *fs/n; modulo value of the point
Divide by N/2 is the amplitude of the signal at the corresponding frequency (for the DC signal is divided by
N); The phase of the point is the phase of the signal at the corresponding frequency. Calculation of phase
Available functions atan2 (b,a) calculation. ATAN2 (b,a) is the angle at which coordinates (a, b) are obtained.
range from-pi to pi. To be accurate to xhz, you need to take a sample length of 1/x seconds
Signal, and do the FFT. To increase the frequency resolution, you need to add a sample point,
This is unrealistic in some practical applications and needs to be completed in a short period of time.
Analysis. The method of solving the problem has the frequency subdivision method, the relatively simple method is
A short time signal is taken, then a certain number of 0 is added at the back to make its length
To achieve the required points, and then do the FFT, which to a certain extent, can improve the frequency resolution.
The detailed frequency subdivision method can be used to refer to relevant literatures.

[Appendix: Matlab program used in this test data]
Close all; % close All pictures first
adc=2; % DC component Amplitude
a1=3; % frequency F1 the amplitude of the signal
a2=1.5; % frequency F2 the amplitude of the signal
f1=50; % Signal 1 frequency (HZ)
f2=75; % Signal 2 frequency (HZ)
fs=256; % Sample frequency (Hz)
p1=-30; % Signal 1 phase (degrees)
p2=90; % signal phase (degrees)
n=256; % of sample points
T=[0:1/FS:N/FS]; % Sample Time

% signal
S=adc+a1*cos (2*pi*f1*t+pi*p1/180) +a2*cos (2*pi*f2*t+pi*p2/180);
% Show Original signal
Plot (S);
Title (' original signal ');

Figure
Y = FFT (s,n); % do FFT transform
Ayy = (ABS (Y)); % modulus
Plot (Ayy (1:n)); % shows the original FFT modulo value result
Title (' FFT mode value ');

Figure
ayy=ayy/(N/2); % converted to actual amplitude
Ayy (1) =ayy (1)/2;
f= ([1:n]-1) *fs/n; % converted to actual frequency value
Plot (F (1:N/2), Ayy (1:N/2)); % display of converted FFT modulus results
Title (' Amplitude-frequency graph ');

Figure
PYY=[1:N/2];
For I=1:N/2
Pyy (i) =phase (Y (i)); % calculation phase
Pyy (i) =pyy (i) *180/pi; % Conversion to angle
End
Plot (F (1:N/2), Pyy (1:N/2)); % Display phase diagram
Title (' Phase-frequency graph ');

The physical meaning of FFT algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.