FFT is a fast Discrete Fourier transformation. Algorithm , You can change a signal to the frequency domain. Some signals are difficult to see in the time domain. However, after being transformed to the frequency domain, it is easy to see the features. This is why many signal analysis uses FFT. In addition, FFT can extract the spectrum of a signal, which is also frequently used in spectrum analysis.
Although many people know what FFT is, what it can be used for, and how to do it, they do not know what the result after FFT means, and how to decide how many points to use for FFT.
Now, the circle describes the physical meaning of the FFT result based on actual experience.
A analog signal is converted into a digital signal after ADC sampling. Sampling
The theorem tells us that the sampling frequency is twice the signal frequency.
Not here.
After sampling the digital signal, you can perform the FFT transformation. N sampling points,
After FFT, we can get the FFT result of N points. For convenience of FFT
Operation. N is usually the integer power of 2.
assume that the sampling frequency is FS, the signal frequency is f, and the sampling points are n. The result after FFT
is a plural number of N points. Each vertex corresponds to a frequency
vertex. The modulo value of this point is the amplitude characteristic of this frequency value. What is the relationship between the signal amplitude and the original
? Assuming that the peak value of the original signal is a, each vertex of the FFT
result (except the first vertex DC component) the modulo value of is n/2 times of a
. The first point is the DC component, and its modulo value is n times the DC component
. The phase of each vertex is the phase of the signal at this frequency.
the first vertex represents the DC component (0Hz), and the last vertex N is next
(in fact, This vertex does not exist, here is the n + 1 point, or
it can be seen that the first point is divided into two halves, and the other half is moved to the end) it indicates
sampling frequency fs, Which is evenly divided into N equal parts by the N-1 points in the middle, the frequency of each point increases in turn. For example, the frequency of a point N is: fn = (n-1) * fs/n.
as shown in the preceding formula, FN can tell that the sampling frequency is fs/n. If
the sampling frequency is FS 1024Hz and the sampling points are 1024 points, the resolution is 1Hz.
the sampling rate of 1024Hz is points, which is exactly 1 second. That is to say, sampling the signal of 1 second
and performing FFT, the result can be analyzed to 1Hz, if the signal between two seconds is sampled and FFT is performed, the result can be analyzed to 0.5Hz. If you want to increase the frequency
resolution, you must increase the number of sampling points, that is, the sampling time. The frequency resolution is reciprocal with the
sampling time.
assume that point N after FFT is expressed by the plural A + bi, then the modulo of this plural number is
An = root number A * A + B * B, the phase is Pn = atan2 (B, ). Based on the above results,
can calculate the expression of the signal corresponding to N points (n = 1, and n <= n/2) as follows:
An/(n/2) * Cos (2 * pI * fN * t + PN ), 2 * an/N * Cos (2 * pI * fN * t + PN ).
for signal n = 1, it is a DC component, and the amplitude is A1/n.
due to the symmetry of the FFT result, we usually only use the result of the first half.
that is, the result is less than half of the sampling frequency.
Well, after talking about it for a long time, the formula is also dizzy, and the following circle uses an actual
Signal.
Suppose we have a signal, which contains 2 v dc components, the frequency is 50Hz,
An AC signal with a phase of-30 degrees and a amplitude of 3 V, 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)
In the formula, cos parameters are radians, So-30 degrees and 90 degrees must be converted to radians respectively.
We sample this signal at a sampling rate of 256Hz, with a total sampling rate of points.
According to the 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 three frequencies: 0Hz, 50Hz, and 75Hz, which should be at 1st, 51st,
The peak value appears on the 76th points, and the other points should be close to 0. What is the actual situation?
Let's take a look at the modulo value of the FFT result.
Figure 1 FFT result
We can see that there are
A relatively large value. Let's take a closer look at the data near these three points:
: 512 + 0i
2:-2.6195e-14-1.4162e-13i
3:-2.8586e-14-1.1898e-13i
50:-6.2076e-13-2.1713e-12i
51: 332.55-192i
52:-1.6707e-12-1.5241e-12i
75:-2.2199e-13-1.0076e-12i
: 3.4315e-12 + 192i
: -3.0263e-14 + 7.5609e-13i
obviously, the values at, 51, and 76 are relatively large, and the nearby vertex values
are very small and can be considered as 0, that is, the signal amplitude at those frequency points is 0.
next, we will calculate the amplitude value of each point. Calculate the modulo values of the three points respectively.
The result is as follows:
: 512
: 384
: 192
according to the formula, the DC component is calculated as follows: 512/N = 512/256 = 2.
the signal amplitude of 50Hz is: 384/(n/2) = 384/(256/2) = 3; the
amplitude of the 75Hz signal is 192/(n/2) = 192/(256/2) = 1.5. It can be seen that the range
analyzed from the spectrum is correct.
then calculate the phase information. There is no phase for the DC signal, no need to worry about it
. Calculate the phase of the 50Hz signal, atan2 (-192,332.55) =-0.5236,
the result is a radian, and the conversion angle is 180 * (-0.5236)/PI =-30.0001.
calculate the 75Hz signal phase. atan2 (192, 3.4315e-12) = 1.5708 radian.
the conversion angle is 180*1.5708/PI = 90.0002. It can be seen that the phase is also correct.
Based on the FFT result and the above analysis and calculation, we can write the signal expression
, which is the signal we started to provide.
Conclusion: assume that the sampling frequency is FS and the number of sampling points is N. After FFT
A point of n (n starts from 1) indicates the frequency: fn = (n-1) * fs/N; the modulo VALUE OF THE POINT
Dividing by n/2 is the amplitude of the signal at the expected frequency (for the DC signal is divided
N); the phase at this point is the phase of the signal at the expected frequency. Phase Calculation
The function atan2 (B, A) can be used for calculation. Atan2 (B, A) is the angle of the coordinate (A, B ).
Degree value, ranging from-pi to pi. To be accurate to xhz, the sampling length must be 1/X seconds.
And perform 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 completed in a short period of time.
Analysis. The frequency subdivision method is used to solve this problem. The simplest method is
Sample a short period of time signal, and then add a certain number of 0 in the back to make the length
The number of required points is reached, and then FFT is performed, which can improve the frequency resolution to a certain extent.
For more information about the frequency subdivision method, see the relevant literature.
[Appendix: MATLAB used in this test dataProgram]
Close all; % Close all images first
ADC = 2;% DC component Amplitude
A1 = 3; % Frequency F1 Signal Amplitude
A2 = 1.5; % frequency F2 Signal Amplitude
F1 = 50;% Signal 1 frequency (HZ)
F2 = 75;% Signal 2 frequency (HZ)
FS = 256; % sampling frequency (HZ)
P1 =-30; % signal 1 phase (degree)
P2 = 90;% Signal phase (degree)
N = 256;% Sampling points
T = [0: 1/Fs: N/fs]; % sampling time
% Signal
S = ADC + A1 * Cos (2 * pI * F1 * t + pI * P1/180) + A2 * Cos (2 * pI * F2 * t + pI * P2/180 );
% Display original signal
Plot (s );
Title ('original sign ');
Figure;
Y = FFT (S, N); % for FFT Conversion
Ayy = (ABS (y); % modulo
Plot (Ayy (1: N); % displays the original FFT modulus result
Title ('fft modulus value ');
Figure;
Ayy = Ayy/(n/2 ); % To the actual RANGE
Ayy (1) = Ayy (1)/2;
F = ([1: N]-1) * fs/N; % is converted to the actual frequency value.
Plot (f (1: n/2), Ayy (1: n/2 )); % Display the converted FFT modulus result
Title ('amplitude-Frequency Curve Graph ');
Figure;
Pyy = [1: n/2];
For I = "1: n/2"
Pyy (I) = phase (Y (I); % calculate the phase
Pyy (I) = pyy (I) * 180/PI; % converts to angle
End;
Plot (f (1: n/2), pyy (1: n/2 )); % Display Phase Chart
Title ('Phase-Frequency Curve Graph ');