Hi all,
I want read ADXL from analog pin, for example 16384 samples and save values to buffer. Then I want apply FFT (hanning window) and get average value. But I think I have problem because Arduino library FFT has only Magnitude and no amplitude. So I have wrong data to get mV or mm/s.
Do you have any suggestion how make FFT with amplitude output for example in mV?
Thanks!
Michal
I want read ADXL from analog pin, for example 16384 samples and save values to buffer. Then I want apply FFT (hanning window) and get average value. But I think I have problem because Arduino library FFT has only Magnitude and no amplitude. So I have wrong data to get mV or mm/s.
Do you have any suggestion how make FFT with amplitude output for example in mV?
Thanks!
Michal
Code:
void rms()
{
suma = 0;
microseconds = micros();
for(int i=0; i<BUFFER_SIZE; i++)
{
vReal[i] = analogRead(A1);
vImag[i] = 0;
while(micros() - microseconds < sampling_period_us){
}
microseconds += sampling_period_us;
}
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= 0;i < BUFFER_SIZE - 1; i++)
{
frequency = (i * 1.0 * 20000) / BUFFER_SIZE;
magnitude = vReal[i];
suma = suma + magnitude;
}
suma = (suma / BUFFER_SIZE);
Serial.println(suma, 0);