Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HIDScope MODSERIAL TextLCD mbed-dsp mbed
Fork of EMGmeten by
Revision 1:b7a9fcf50776, committed 2014-10-28
- Comitter:
- lauradeheus
- Date:
- Tue Oct 28 14:37:59 2014 +0000
- Parent:
- 0:b68a6d0451b8
- Child:
- 2:5d64e4c95f5c
- Commit message:
- Bandpass and rectifying correct
Changed in this revision
| EMGmeten.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/EMGmeten.cpp Tue Oct 28 14:23:05 2014 +0000
+++ b/EMGmeten.cpp Tue Oct 28 14:37:59 2014 +0000
@@ -6,11 +6,14 @@
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};
+arm_biquad_casd_df1_inst_f32 lowpass_1; //99Hz
+arm_biquad_casd_df1_inst_f32 lowpass_2; //3Hz
+arm_biquad_casd_df1_inst_f32 highpass; //20Hz
+float lowpass_1_const[] = {0.978030479206560 , 1.956060958413119 , 0.978030479206560 , -1.955578240315036 , -0.956543676511203};
+float lowpass_1_states[4];
+float lowpass_2_const[] = {0.002080567135492 , 0.004161134270985 , 0.002080567135492 , 1.866892279711715 , 0.875214548253684};
+float lowpass_2_states[4];
+float highpass_const[] = {0.638945525159022 , -1.277891050318045 , 0.638945525159022 , 1.142980502539901 , -0.412801598096189};
float highpass_states[4];
void looper()
@@ -22,7 +25,9 @@
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 );
+ arm_biquad_cascade_df1_f32(&lowpass_1, &filtered_emg, &filtered_emg, 1 );
+ filtered_emg = fabs(filtered_emg);
+ //arm_biquad_cascade_df1_f32(&lowpass_2, &filtered_emg, &filtered_emg, 1 );
scope.set(0,emg_value); //uint value
scope.set(1,filtered_emg); //processed float
@@ -33,8 +38,9 @@
{
Ticker log_timer;
- arm_biquad_cascade_df1_init_f32(&lowpass,1 , lowpass_const, lowpass_states);
+ arm_biquad_cascade_df1_init_f32(&lowpass_1,1 , lowpass_1_const, lowpass_1_states);
arm_biquad_cascade_df1_init_f32(&highpass,1 , highpass_const, highpass_states);
+ //arm_biquad_cascade_df1_init_f32(&lowpass_2,1 , lowpass_2_const, lowpass_2_states);
log_timer.attach(looper, 0.005);
