To perform FFT (Fast Fourier Transform) analysis on vibration sensor data in MATLAB
To perform FFT (Fast Fourier Transform) analysis on vibration sensor data in MATLAB, follow this structured guide. FFT helps convert time-domain vibration signals into the frequency domain, revealing dominant frequencies and their amplitudes, which is critical for diagnosing machinery faults (e.g., imbalance, misalignment, bearing defects).
Step 1: Load and Preprocess the Data
Import Time-Domain Data
Assume your vibration data is stored in a CSV or text file with two columns: time (s) and amplitude (e.g., acceleration in m/s²).
% Load data data = readtable('vibration_data.csv'); time = data.Time; % Time vector amplitude = data.Amplitude;% Vibration signal
Check Sampling Rate
Calculate the sampling frequency (fs):
Fs = 1 / (time(2) - time(1)); % Sampling frequency (Hz) N = length(amplitude); % Number of data points
Step 2: Preprocess the Signal
Detrend the Data
Remove DC offset or linear trends:
amplitude = detrend(amplitude);
Apply a Window Function
Reduce spectral leakage using a Hanning window:
window = hann(N); amplitude_windowed = amplitude .* window;
Step 3: Perform FFT
Compute the FFT
Y = fft(amplitude_windowed); % Compute FFT P2 = abs(Y/N); % Two-sided spectrum P1 = P2(1:N/2+1); % Single-sided spectrum P1(2:end-1) = 2*P1(2:end-1); % Adjust for energy in single-sided
Define Frequency Axis
f = Fs * (0:(N/2)) / N; % Frequency vector (Hz)
Step 4: Plot the Frequency Spectrum
figure; plot(f, P1); title('Single-Sided Amplitude Spectrum'); xlabel('Frequency (Hz)'); ylabel('Amplitude'); grid on;
Step 5: Identify Dominant Frequencies
Find Peaks
Use MATLAB’s findpeaks
to detect significant frequencies:
[peaks, locs] = findpeaks(P1, f, 'MinPeakHeight', 0.1*max(P1), 'MinPeakDistance', 1);
Display Peaks
hold on; plot(locs, peaks, 'ro'); legend('Spectrum', 'Dominant Frequencies');
Step 6: Analyze Results
- Peak Frequencies: Compare dominant frequencies (fpeak) with known fault frequencies (e.g., rotational speed harmonics).
- Amplitude: Higher amplitudes at specific frequencies indicate resonance or defects.
Example Workflow for Simulated Data
% Simulate a vibration signal with 10 Hz and 30 Hz components Fs = 1000; % Sampling frequency (Hz) t = 0:1/Fs:1-1/Fs; % Time vector (1 second) f1 = 10; % Frequency 1 (Hz) f2 = 30; % Frequency 2 (Hz) amplitude = 0.7*sin(2*pi*f1*t) + 1.2*sin(2*pi*f2*t) + 0.1*randn(size(t)); % Perform FFT Y = fft(amplitude); P2 = abs(Y/length(t)); P1 = P2(1:length(t)/2+1); P1(2:end-1) = 2*P1(2:end-1); f = Fs*(0:(length(t)/2))/length(t); % Plot plot(f, P1); xlabel('Frequency (Hz)'); ylabel('Amplitude');
Key Considerations
- Aliasing: Ensure fs>2×fmax (Nyquist theorem).
- Zero-Padding: Use
NFFT = 2^nextpow2(N)
to improve frequency resolution. - Averaging: For noisy data, use
pwelch
for power spectral density (PSD) estimation:[pxx, f] = pwelch(amplitude, hann(512), 256, 512, Fs); plot(f, 10*log10(pxx)); % Plot in dB
- Log Scale: Visualize small amplitudes with a logarithmic y-axis:
semilogy(f, P1);
Troubleshooting
- Low Amplitude Peaks: Check signal-to-noise ratio (SNR) and apply filtering (e.g.,
lowpass
orbandpass
). - Frequency Resolution: Increase data acquisition time (T=N/fs).
- Non-Stationary Signals: Use Short-Time FFT (
spectrogram
) for time-frequency analysis:spectrogram(amplitude, hann(256), 128, 256, Fs, 'yaxis');
By following these steps, you can effectively analyze vibration sensor data to diagnose mechanical issues or validate system dynamics.