Bandpass, notch, abs en laagdoorlaat 3H
Dependencies: HIDScope MODSERIAL TextLCD mbed-dsp mbed
Fork of EMGmeten by
Diff: EMGmeten.cpp
- Revision:
- 0:b68a6d0451b8
- Child:
- 1:b7a9fcf50776
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EMGmeten.cpp Tue Oct 28 14:23:05 2014 +0000 @@ -0,0 +1,47 @@ +#include "mbed.h" +#include "HIDScope.h" + +#include "arm_math.h" + +AnalogIn emg(PTB1); //Analog input +HIDScope scope(2); + +arm_biquad_casd_df1_inst_f32 lowpass; +arm_biquad_casd_df1_inst_f32 highpass; +float lowpass_const[] = {0.978030479206560 , 1.956060958413119 , 0.978030479206560 , -1.955578240315036 , -0.956543676511203}; +float lowpass_states[4]; +float highpass_const[] = {0.638945525159022, -1.277891050318045, 0.638945525159022 , 1.142980502539901 , -0.412801598096189}; +float highpass_states[4]; + +void looper() +{ + uint16_t emg_value; + float filtered_emg; + float emg_value_f32; + emg_value = emg.read_u16(); // read direct ADC result, converted to 16 bit integer (0..2^16 = 0..65536 = 0..3.3V) + emg_value_f32 = emg.read(); + + arm_biquad_cascade_df1_f32(&highpass, &emg_value_f32, &filtered_emg, 1 ); + arm_biquad_cascade_df1_f32(&lowpass, &filtered_emg, &filtered_emg, 1 ); + + scope.set(0,emg_value); //uint value + scope.set(1,filtered_emg); //processed float + scope.send(); +} + +int main() +{ + Ticker log_timer; + + arm_biquad_cascade_df1_init_f32(&lowpass,1 , lowpass_const, lowpass_states); + arm_biquad_cascade_df1_init_f32(&highpass,1 , highpass_const, highpass_states); + + log_timer.attach(looper, 0.005); + + while(1) //Loop + { + /*Empty!*/ + /*Everything is handled by the interrupt routine now!*/ + } +} + \ No newline at end of file