double peaks in FFT matlab
22 views (last 30 days)
I am trying to generate FFT with matlab code for the time based forces acting on a machine tool. The difference I am using is that I am not taking the absolute value of forces but I am normalizing them and I am not doubling the values of the FFT.
here is my code
spindle_speed = 960; % speed is in rpm
N = 3; %Number of teeth in cutter
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = (inv((spindle_speed/60))*1000)*50; % Length of signal 62.5 for one machine tool cycle
delta_T = 0;
t = (0+delta_T:(L-1))*T; % Time vector
f = Fs*(0:(L/2))/L; % frequency vector
% FFT in Y
Analytical_Fourier_Y = fft(Fy_Total_Teeth,,1);
P2 = Analytical_Fourier_Y/L;
P1 = P2(1:L/2+1);
P1(2:end-1) = 1*P1(2:end-1);
% FFT in X
Analytical_Fourier_X = fft(Fx_Total_Teeth,,1);
P2_x = Analytical_Fourier_X/L;
P1_x = P2_x(1:L/2+1);
The problem I am facing is that when my delta_T = 0, then my fft is correct as shown below:
delta_T influences the Fy_Total_Teeth and Fx_Total_Teeth
but when my delta_T = 50 or any other integer, then my FFT gives double peaks, as shown below:
Does anyone know, how to improve the FFT results when delta_T is not zero.
David Goodmanson on 19 Oct 2020
the fft is a complex function. Are you plotting only the real part?
This problem is occurring because your delta_T operation is not delaying the entire signal. It is merely chopping off the first part of the signal, and changing the total number of points.
Let's say the signal contains an exact integral number of oscillations in the time window at some frequency. (By the look of your data there are several such frequencies). The result is a sharp spike in the fft at that frequency (two spikes if you plot all the frequencies, positive and negative). Once you chop off part of the time window you don't have an exact integral number of oscillations any more, which means that you don't get the sharp spike and some of the energy content spills into adjacent frequencies. That causes the behavior in your lower plots.
The example below shows the result for a single frequency. I didn't bother with scaling the frequency grid or scalilng the fft output or cutting out half the frequencies for the plot, since the effect doesn't depend on any of that.
The first plot shows real spikes, appropriate for the cosine function. The second plot shows the problem with truncation.
Time delay leads to phase shifts in the frequency domain. The third plot with true delay shows complex spikes due to the phase shift. But unlilke with truncation, they are still spikes.
n = 1000;
t = 0:n-1;
y = cos(2*pi*t/25); % exactly 40 cycles
yf = fft(y);
t7 = 7:n-1;
y = cos(2*pi*t7/25); % not an exact number of cycles
yf = fft(y);
% true delay
td = t + 7;
y = cos(2*pi*td/25);
yf = fft(y);