Basic emg filter setup
Dependencies: HIDScope mbed biquadFilter
Fork of EMG_Filter by
Revision 2:85984e2aee8d, committed 2015-09-25
- Comitter:
- mganseij
- Date:
- Fri Sep 25 08:19:05 2015 +0000
- Parent:
- 1:55620051895b
- Commit message:
- CHanging some filter code
Changed in this revision
biquadFilter.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 55620051895b -r 85984e2aee8d biquadFilter.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/biquadFilter.lib Fri Sep 25 08:19:05 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/tomlankhorst/code/biquadFilter/#e3bf917ae0a3
diff -r 55620051895b -r 85984e2aee8d main.cpp --- a/main.cpp Thu Sep 24 09:45:37 2015 +0000 +++ b/main.cpp Fri Sep 25 08:19:05 2015 +0000 @@ -2,6 +2,7 @@ #include "HIDScope.h" #include <cstring> #include <cmath> +#include "biquadFilter.h" AnalogIn input1(A0); // first EMG input AnalogIn input2(A1); // second EMG input @@ -60,7 +61,10 @@ memmove(outputs_previous, outputs_current, sizeof(outputs_previous)); // same for this output for(int n = 0; n <= 3; n++) { - outputs_current[n] = fabs(high_b1*inputs_current[n] + high_b2*inputs_previous[n] + high_b3*inputs_previous2[n] - high_a2*outputs_previous[n] - high_a3*outputs_previous2[n]) * (low_b1*inputs_current[n] + low_b2*inputs_previous[n] + low_b3*inputs_previous2[n] - low_a2*outputs_previous[n] - low_a3*outputs_previous2[n]); + outputs_current[n] = high_b1*inputs_current[n] + high_b2*inputs_previous[n] + high_b3*inputs_previous2[n] - high_a2*outputs_previous[n] - high_a3*outputs_previous2[n]; + outputs_current[n] = fabs(outputs_current[n]); + outputs_current[n] = (low_b1*inputs_current[n] + low_b2*inputs_previous[n] + low_b3*inputs_previous2[n] - low_a2*outputs_previous[n] - low_a3*outputs_previous2[n]); + outputs_current[n] = outputs_current[n]; } }