FFT on unwanted vibration in rotational torque data with np.fft.fft()

55 Views Asked by At

I'm experimenting with some DFT analysis on a data set for a test apparatus. There's some small misalignment causing vibrations in torque sensors, and I'm wondering if I can filter that out. For now I'm just trying to identify the frequency peaks.

I've gotten results that have an x-axis frequency from 0 to ~15 Hz, which I believe is the Nyquist frequency of my sampling rate (~30 Hz.)

Issues:

  • The FFT plot (3rd plot) seems funny, it seems to be plotting overlapping curves, not a real function.

  • There's a peak at ~0 hz, which I can't make sense of. The machine is operating at ~240RPM, so I'd expect to see peaks at 4hz, or some evenly divisible number if there's periodic motion in the misalignment.

Relevant code:

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

#Import csv file:
df = pd.read_csv('FFT_data_sample_csv.csv')

N = len(df['Torque(nM) A']) #Number of samples
sample_duration = df['Time(s)'].iloc[-1] - df['Time(s)'].iloc[0] #Last sample time - first sample time
freq = N/sample_duration #Frequency is ~31 hz
T = 1/freq #Period (based on sampling)

X = np.fft.fft(df['Torque(nM) A'])
X_mag = np.abs(X) / N   #normalized magnitude by number of samples
freqPlot = np.fft.fftfreq(N, d=T)

fig, [ax1, ax2, ax3] = plt.subplots(nrows=3, ncols=1, figsize=(8, 8))
ax1.plot(df["Time(s)"], df["Torque(nM) A"])
ax1.set_title('Torque (nm) vs. Time (s)')
ax1.set_xlabel('Time (s)')
ax1.set_ylabel('Torque (nm)')

ax2.plot(df['Time(s)'], df['RPM A'])
ax2.set_title('RPM ')
ax2.set_xlabel('Time (s)')
ax2.set_ylabel('RPM')

ax3.plot(freqPlot, X_mag)
ax3.set_title('FFT Frequency')
ax3.set_xlabel('Frequency')
ax3.set_ylabel('Magnitude')
plt.subplots_adjust(top=.94, hspace=.4, bottom=.07)
plt.show()

Image of Plots:

Image of Plots

Most of this came from:

  1. https://www.youtube.com/watch?v=O0Y8FChBaFU
  2. https://pythonnumericalmethods.berkeley.edu/notebooks/chapter24.04-FFT-in-Python.html
0

There are 0 best solutions below