FFT is a fast algorithm for discrete Fourier transform, which can transform a signal
to the frequency domain. Some signals are difficult to see in the time domain, but as
After the conversion to the frequency domain, it is easy to see the characteristics. That's a lot of signals.
The reason of using FFT transform is analyzed. In addition, the FFT can convert the spectrum of a signal
Extracted, which is often used in spectral analysis.
Although many people know what the FFT is, what can be used to do, how to
Do, but do not know what the results after the FFT mean, how to decide to use
How many points to do the FFT.
Now the circle is based on practical experience to say the specific physical meaning of the FFT results.
An analog signal, once sampled by the ADC, becomes a digital signal. Sampling
Theorem tells us that the sampling frequency is more than twice times the signal frequency, which I
No more wordy here.
By sampling the digital signal, you can do the FFT transformation. N Sample points,
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.
Assuming that the sampling 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. Specifically with the original
What does the amplitude of the signal matter?Assuming the peak of the original signal is a, then the FFT
The modulo value of each point of the result (except the first point DC component) 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 the hypothetical n+1 point, Also
You can see that the first point is divided into two halves and the other half is moved to the last).
Sampling frequency FS, which is evenly divided into n equal portions by N-1 points, the frequency of each point
Increases in turn. For example, the frequency represented by a point n is: fn= (n-1) *fs/n.
As can be seen from the above formula, FN can tell the frequency to be fs/n,If
The sampling frequency FS is 1024Hz and the sampling point is 1024 points, then the 1Hz can be distinguished.
Sampling rate of 1024Hz sampling 1024 points, just 1 seconds, that is, sampling 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 increase the number of sampling points,The sampling time is also known. Frequency resolution and
The sampling time is the reciprocal relationship.
Assuming that a certain point n is represented by a complex number a+bi, then the modulus of this 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 real
Signal to do the explanation.
Suppose we have a signal that contains a 2V DC component 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 as follows:
S=2+3*cos (2*pi*50*t-pi*30/180) +1.5*cos (2*pi*75*t+pi*90/180)
The COS parameter in the formula is radians, so 30 degrees and 90 degrees are converted to radians respectively.
We sampled this signal at a sample rate of 256Hz and sampled 256 points in total.
According to our above analysis,fn= (n-1) *fs/n, we can 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 peak, and the other points should be close to 0. What is the actual situation?
Let's look at the modulus of the result of the FFT.
Figure 1 FFT results
We can see that in the 1th, 51st, and 76th vicinity there are
relatively large values. 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 Points: -2.2199e-13-1.0076e-12i
76 points: 3.4315E-12 + 192i
77 Points: -3.0263E-14 +7.5609e-13i
Obviously, the values of 1, 51, and 76 are relatively large, and the point value near it
are small and can be thought of as 0, that is, the signal amplitude at those frequency points is 0.
Next, we calculate the amplitude values of each point. Calculate the modulo values of these three points, respectively,
The results are as follows:
1 points: 512
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
The amplitude is 192/(N/2) =192/(256/2) = 1.5. Visible, from spectrum analysis.
The amplitude is correct.
The phase information is then computed. The DC signal has no phase, no tube
It. 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. Again
Calculates the phase of the 75Hz signal, atan2 (192, 3.4315E-12) =1.5708 radians,
The conversion 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 can write the signal expression.
, it's the signal we're starting to provide.
Summary: assuming that the sampling frequency is FS, the sample number 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
Dividing by N/2 is the amplitude of the signal at the expected frequency (the DC signal is divided by
N); The phase of the point is the phase of the signal at the expected 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, a sample length of 1/x seconds is required
Signal, and do the FFT. to increase the frequency resolution, you need to increase the number of sampling points
This is unrealistic in some practical applications and needs to be done in a short period of time
Analysis. The method of solving this problem has the frequency subdivision method, the relatively simple method is
The sampling compares a short time signal and then supplements a certain number of 0 at the back to make its length
To achieve the required number of points, and then do the FFT, which to a certain extent, can improve the frequency resolution.
The specific frequency subdivision method can 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; % 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 ');
This is the circle to participate in the End Blog Contest article, I hope you support
Circle, click on the upper left corner of the "top", a vote for the circle, thank you.
Detailed explanation of the FFT (reproduced online)