I'm trying to calculate the Ocean Wave Height using FFT and 3 axis accelerometer. My understating how to do it is :
I need to calculate the spectrum of A ( A=sqrt(ax^2+ay^2+az^2)) , by standard FFT function. This will give me the acceleration spectrum, Sa(f), which is the function of wave frequency, f.
To convert it to the more conventional elevation spectrum, Sz(f), I need to divide it by (2pif)^4, because acceleration of the circular wave motion is A=Z*(2pif)^2, while the spectrum is the squared magnitude, Sz~Z^2.
in brief the logic should be 👍
-
the accelerometter returns values between 0 and 4096 ( e.g. the actual 0 is the middle 2048 )
-
read the calibration values
aX
aY
aZ
assuming we need ( -, 0, +) values and the 0 is 2048 we adjust them to :
dX = aX - 2048
dY = aY - 2048
dZ = aZ - 2048
- calculate the calibration magnitude
cM = sqrt(dXdX + dYdY + dZ*dZ);
- calculate the coefficient to get the values in m/s
coefMS = 9.83 / cM
-------------- real-time calculations ---------
defaults:
SAMPLES[128]; // 128 values
SAMPLING_PERIOD = 250; // 250 milliseconds - e.g. 32 seconds for 128 values
SAMPLING_FREQUENCY = 4.0; // Hz ( 4 times every second)
calculations :
we assume that maximum wave frequency that we will measure is 30sec ( usually sea waves are about 20 sec max)
collect value for 32 sec every 250millis one value = sqrt(dXdX + dYdY + dZ*dZ) * coefMS; // to get it in m/s
after we get a 32 sec sampling and fill 128 values we use FFT :
FFT.Windowing(...);
FFT.Compute(...);
FFT.ComplexToMagnitude(...);
we calculate the peak
FFT.MajorPeak(...);
it returns peak interpolated frequency - pF and peak value pV
calculate the actual sea wave length in meters :
SEA_WAVE_LENGTH_IN_METERS = pV / ((2pipF)^4);
Does this sounds right to you ?
I'm trying to calculate the Ocean Wave Height using FFT and 3 axis accelerometer. My understating how to do it is :
I need to calculate the spectrum of A ( A=sqrt(ax^2+ay^2+az^2)) , by standard FFT function. This will give me the acceleration spectrum, Sa(f), which is the function of wave frequency, f.
To convert it to the more conventional elevation spectrum, Sz(f), I need to divide it by (2pif)^4, because acceleration of the circular wave motion is A=Z*(2pif)^2, while the spectrum is the squared magnitude, Sz~Z^2.
in brief the logic should be 👍
the accelerometter returns values between 0 and 4096 ( e.g. the actual 0 is the middle 2048 )
read the calibration values
aX
aY
aZ
assuming we need ( -, 0, +) values and the 0 is 2048 we adjust them to :
dX = aX - 2048
dY = aY - 2048
dZ = aZ - 2048
cM = sqrt(dXdX + dYdY + dZ*dZ);
coefMS = 9.83 / cM
-------------- real-time calculations ---------
defaults:
SAMPLES[128]; // 128 values
SAMPLING_PERIOD = 250; // 250 milliseconds - e.g. 32 seconds for 128 values
SAMPLING_FREQUENCY = 4.0; // Hz ( 4 times every second)
calculations :
we assume that maximum wave frequency that we will measure is 30sec ( usually sea waves are about 20 sec max)
collect value for 32 sec every 250millis one value = sqrt(dXdX + dYdY + dZ*dZ) * coefMS; // to get it in m/s
after we get a 32 sec sampling and fill 128 values we use FFT :
FFT.Windowing(...);
FFT.Compute(...);
FFT.ComplexToMagnitude(...);
we calculate the peak
FFT.MajorPeak(...);
it returns peak interpolated frequency - pF and peak value pV
calculate the actual sea wave length in meters :
SEA_WAVE_LENGTH_IN_METERS = pV / ((2pipF)^4);
Does this sounds right to you ?