Forum Rule: Always post complete source code & details to reproduce any issue!

Hi all,
I do not want to post my code because it is not important for now.
I wan to use Tennsy 4.0 and ADXL1005 (eval board) to measure mm/s.
I will read samples from pin A0 to buffer of size 16384. (every reading every 50 micros)
I will use alpha low and alpha hight to have filter bandpass 10-1000Hz.
I will use Arduino FFT library and process the buffer with Hanning window.
Then I will calculate m/s2 for every frequency and then total m/s2

BUT - arduino FFT library calculate magnitude - no amplitude - and the result is not ok.

How to calculate amplitude?
Any suggestion for this case?
Thak you!

Michal  Reply With Quote

2. First an accelerometer gives acceleration readings, m/s^2, not m/s

Secondly magnitude _is_ amplitude (without the phase).

To calculate totals you have to add magnitude-squared, which is proportional to power, which adds linearly (amplitudes
only add linearly for coherent waves, and different frequency bins are by definition non-coherent).  Reply With Quote

3. OK, I have

#define BUFFER_SIZE 16384

{
pole=0;
startTimerValue = timer.begin(TIMER, period);
timer.priority (0);

}
void TIMER()
{
}
{
asm volatile("dsb");
}

Then calculation:

void CALCULATE_MM ()
{

period = 50;
delay (2000);

alpha_LOW = 0.003;// 10hz
alpha_HIGH =0.145;// 1000 Hz

Arms = 0;
Vrms = 0;
SUM_Vrms = 0;
SUM_Vrms_2 = 0;
for(int i=0 ;i <(BUFFER_SIZE); i++)
{
micros_0 = 0;
Filter_LOWPASS = (BUFFER_ADC[i] * alpha_LOW) + (Filter_LOWPASS * (1.0 - alpha_LOW));
Filter_HIGHPASS = (BUFFER_ADC[i]* alpha_HIGH) + (Filter_HIGHPASS * (1.0 - alpha_HIGH));
Filter_BANDPASS = Filter_HIGHPASS-Filter_LOWPASS;
vReal[i] = Filter_BANDPASS / BUFFER_SIZE;
vImag[i] = 0;
while(micros_0 < period)
{
}
}
FFT.Windowing(vReal, BUFFER_SIZE, FFT_WIN_TYP_HANN, FFT_FORWARD);
FFT.Compute(vReal, vImag, BUFFER_SIZE, FFT_FORWARD);
FFT.ComplexToMagnitude(vReal, vImag,BUFFER_SIZE);

for(int i=1;i <(BUFFER_SIZE/16); i++)

{
//1 - frequency
f = (i * 1.0 * 20000) /BUFFER_SIZE;
//2 - m/s^2
Arms = vReal[i]*9.8;
//3 - mm/s
Vrms = (1000*Arms)/(6.28*(f));
// 4 SUM
SUM_Vrms = SUM_Vrms + Vrms;
}
// 5 power2
SUM_Vrms_2 =sqrt(SUM_Vrms);
// 6 peak to peak
SUM_Vrms_PP= SUM_Vrms_2;
// 7 0 to peak
SUM_Vrms_0P= SUM_Vrms_PP/2;
// 8 RMS
SUM_Vrms_RMS= 0.707*SUM_Vrms_0P;
}

Any suggestion?  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•