Hi all,
I am reading samples from ADXL via ADC (Teensy 4). I have it in buffer and then I need apply bandpass filter to calculate acceleration for 500-7500Hz and for velocity for 10-1000Hz. Anybody knows code for this type of bandpass filter?
I am trying this but no clue if is it correct. I am testing it with signal generator, sine wave. For example when I set 300Hz and 0,02V RMS I can see 0,8gRMS and if I set 2000Hz I can see 0,6gRMS. (gRMS = pow(every sample from ADC,2) then sqrt of sum). In my opinion, if I set 2000Hz sine then I have to see near zero gRMS, right?
https://www.norwegiancreations.com/2016/03/arduino-tutorial-simple-high-pass-band-pass-and-band-stop-filtering/
Thanks
Michal
I am reading samples from ADXL via ADC (Teensy 4). I have it in buffer and then I need apply bandpass filter to calculate acceleration for 500-7500Hz and for velocity for 10-1000Hz. Anybody knows code for this type of bandpass filter?
I am trying this but no clue if is it correct. I am testing it with signal generator, sine wave. For example when I set 300Hz and 0,02V RMS I can see 0,8gRMS and if I set 2000Hz I can see 0,6gRMS. (gRMS = pow(every sample from ADC,2) then sqrt of sum). In my opinion, if I set 2000Hz sine then I have to see near zero gRMS, right?
https://www.norwegiancreations.com/2016/03/arduino-tutorial-simple-high-pass-band-pass-and-band-stop-filtering/
Code:
float EMA_a_low = 0.001; //10Hz
float EMA_a_high = 0.3; //500Hz
float EMA_S_low = 0;
float EMA_S_high = 0;
float highpass = 0;
float bandpass = 0;
for (k = 0 ; k < TOTAL_SAMPLES; k++)
{
g = data_from_adc[k];
EMA_S_low = (EMA_a_low*g) + ((1-EMA_a_low)*EMA_S_low);
EMA_S_high = (EMA_a_high*g) + ((1-EMA_a_high)*EMA_S_high);
highpass = g - EMA_S_low;
g_buffer[counter] = EMA_S_high - EMA_S_low;
}
Thanks
Michal