I have a dataset with accelerations and I am specifically looking at the x-axis data. I want to show how I can pre-process the data to remove background noise and only look at 'large' / 'medium' events - I know this is a loose description, however I want to focus in on stand-out events and ignore the general noise.
The accelerometer is attached to a platform that moves across smooth, gravely and then large stepped surfaces at random times. I do not have access to the accelerometer datasheet I only know the sampling frequency. The dataset contains accelerometer data (a_x) and a time, which is in seconds. The sampling frequency is 100 hz.
I am using Octave, however a lot of my code has come from reading Matlab documentation.
I start by removing the mean from the a_x data.
dax = detrend(a_x,'constant');
I then perform an FFT and plot the amplitude spectrum
Y = fft(dax); L = length(a_x); Fs=100; %sample frequency P2 = abs(Y/L); P1 = P2(1:L/2+1); P1(2:end-1) = 2*P1(2:end-1); f = Fs*(0:(L/2))/L; plot(f,P1) title('Single-Sided Amplitude Spectrum of X(t)') xlabel('f (Hz)') ylabel('|P1(f)|')
The graph it produces is attached.
I now look at the graph and by eye note that, above a frequency of 35 Hz the data has very low amplitude, that is it looks 'constant' and I believe I should cut-off any frequency above 35 Hz. I now look at the 0 hz end of the graph and see a large peak here. I thought that detrending should have removed this, however that is not the case, so I believe that I want to cut-off any frequency around the 0 hz end of the spectrum. I feel on shaky ground with this interpretation, however I hope I am at least partially correct, because I now use this information to build the following filters.
Have I read the graph correctly? Should I do this by eye or mathematically determine the cut-offs?
I use a Butterworth filter to first remove the > 35 Hz noise:
[d,c] = butter(3, 0.7, 'low'); filterex_dax_low = filter(d,c,filterex_dax);
I hope that I am correct in both my choice of a Butterworth and the settings I choose (3rd order and frequency cut-off)?
I then apply a second Butterworth to remove the frequencies around 0 hz. With this I hope I am removing the DC-Offset of the accelerometer.
[b,a] = butter(3, 0.01, 'high'); filterex_dax = filter(b,a,dax);
Am I correct in my choice of Butterworth filter for high pass?
I suspect that there is a better way of approaching this removal of undersired frquencies however its not clear to me how to do this.
I now should have a signal that has been pre-processed so that I could perhaps perform integration on it to obtain velocities.
I know this is a long post, however I really want to understand the correct terminology as well as methodology so that I can apply to other sensor data.
Thanks Sam