biorobotics group 19 , 2 november
Fork of SigInterpreterv2 by
Revision 3:096e6a7bd90b, committed 2016-11-02
- Comitter:
- fabian101
- Date:
- Wed Nov 02 15:39:01 2016 +0000
- Parent:
- 2:ad96602f71c0
- Commit message:
- biorobotics group 19 , 2 november
Changed in this revision
SigInterpreter.cpp | Show annotated file Show diff for this revision Revisions of this file |
SigInterpreter.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r ad96602f71c0 -r 096e6a7bd90b SigInterpreter.cpp --- a/SigInterpreter.cpp Fri Oct 28 12:48:27 2016 +0000 +++ b/SigInterpreter.cpp Wed Nov 02 15:39:01 2016 +0000 @@ -1,11 +1,44 @@ #include "SigInterpreter.h" -BiQuadChain bqc; -BiQuad bq1(a1_1,a2_1,b0_1,b1_1,b2_1); -BiQuad bq2(a1_2,a2_2,b0_2,b1_2,b2_2); -BiQuad bq3(a1_3,a2_3,b0_3,b1_3,b2_3); -BiQuad bq4(a1_4,a2_4,b0_4,b1_4,b2_4); -BiQuad bq5(a1_5,a2_5,b0_5,b1_5,b2_5); +/* +const double b0_1 = 0.86746769957; +const double b1_1 = -1.73493539914; +const double b2_1 = 0.86746769957; +const double a1_1 = -1.72399696946; +const double a2_1 = 0.74581276783; + +const double b0_2 = 0.93721236427; +const double b1_2 = -1.87442472855; +const double b2_2 = 0.93721236427; +const double a1_2 = -1.82350353127; +const double a2_2 = 0.8862430266; + +*/ +BiQuad bq1_1(-1.72399696946,0.74581276783,0.86746769957,-1.73493539914,0.86746769957); +BiQuad bq1_2(-1.82350353127,0.8862430266,0.93721236427,-1.87442472855,0.93721236427); +BiQuad bq1_3( 3.00955e-10, 3.00615e-10, 0.00000e+00, -9.75178e-01, 0.00000e+00 ); +BiQuad bq1_4( 1.00000e+00, 2.00183e+00, 1.00183e+00, -1.95953e+00, 9.60149e-01 ); +BiQuad bq1_5( 1.00000e+00, 1.99930e+00, 9.99302e-01, -1.98396e+00, 9.84588e-01 ); + +BiQuad bq2_1(-1.72399696946,0.74581276783,0.86746769957,-1.73493539914,0.86746769957); +BiQuad bq2_2(-1.82350353127,0.8862430266,0.93721236427,-1.87442472855,0.93721236427); +BiQuad bq2_3( 3.00955e-10, 3.00615e-10, 0.00000e+00, -9.75178e-01, 0.00000e+00 ); +BiQuad bq2_4( 1.00000e+00, 2.00183e+00, 1.00183e+00, -1.95953e+00, 9.60149e-01 ); +BiQuad bq2_5( 1.00000e+00, 1.99930e+00, 9.99302e-01, -1.98396e+00, 9.84588e-01 ); + +BiQuad bq3_1(-1.72399696946,0.74581276783,0.86746769957,-1.73493539914,0.86746769957); +BiQuad bq3_2(-1.82350353127,0.8862430266,0.93721236427,-1.87442472855,0.93721236427); +BiQuad bq3_3( 3.00955e-10, 3.00615e-10, 0.00000e+00, -9.75178e-01, 0.00000e+00 ); +BiQuad bq3_4( 1.00000e+00, 2.00183e+00, 1.00183e+00, -1.95953e+00, 9.60149e-01 ); +BiQuad bq3_5( 1.00000e+00, 1.99930e+00, 9.99302e-01, -1.98396e+00, 9.84588e-01 ); + +BiQuad bq4_1(-1.72399696946,0.74581276783,0.86746769957,-1.73493539914,0.86746769957); +BiQuad bq4_2(-1.82350353127,0.8862430266,0.93721236427,-1.87442472855,0.93721236427); +BiQuad bq4_3( 3.00955e-10, 3.00615e-10, 0.00000e+00, -9.75178e-01, 0.00000e+00 ); +BiQuad bq4_4( 1.00000e+00, 2.00183e+00, 1.00183e+00, -1.95953e+00, 9.60149e-01 ); +BiQuad bq4_5( 1.00000e+00, 1.99930e+00, 9.99302e-01, -1.98396e+00, 9.84588e-01 ); + + AnalogIn emg1(A0); AnalogIn emg2(A1); @@ -17,32 +50,28 @@ } -double SigInterpreter::readValue(int sig) { +float SigInterpreter::readValue(int sig) { // returns the amplitude of EMG signal if(sig > 4 || sig < 1) { // nope - return 0.0; // check later of dit idd goeie shit is + return 0.0; } if (sig == 1) { - float input = emg1.read(); - return (filter(input)); + return (filter1(emg1.read())); } if (sig == 2) { - float input = emg2.read(); - return (filter(input)); + return (filter2(emg2.read())); } if (sig == 3) { - float input = emg3.read(); - return (filter(input)); + return (filter3(emg3.read())); } if (sig == 4) { - float input = emg4.read(); - return (filter(input)); + return (filter4(emg4.read())); } else { @@ -50,19 +79,52 @@ } } -double SigInterpreter::filter(float input){ +float SigInterpreter::filter1(float input){ - float highpass1 = bq1.step(input); + highpass1 = bq1_1.step(input); + highpass2 = bq1_2.step(highpass1); + rect = fabs(highpass2); + lowpass1 = bq1_3.step(rect); + lowpass2 = bq1_4.step(lowpass1); + lowpass3 = bq1_5.step(lowpass2); + + return lowpass3; +} - float highpass2 = bq2.step(highpass1); - /* - float lowpass1 = bq3.step(highpass2); - - float lowpass2 = bq4.step(lowpass1); +float SigInterpreter::filter2(float input){ + + highpass1 = bq2_1.step(input); + highpass2 = bq2_2.step(highpass1); + rect = fabs(highpass2); + lowpass1 = bq2_3.step(rect); + lowpass2 = bq2_4.step(lowpass1); + lowpass3 = bq2_5.step(lowpass2); - float lowpass3 = bq5.step(lowpass2); - */ - - return fabs(input); + return lowpass3; } +float SigInterpreter::filter3(float input){ + + highpass1 = bq3_1.step(input); + highpass2 = bq3_2.step(highpass1); + rect = fabs(highpass2); + lowpass1 = bq3_3.step(rect); + lowpass2 = bq3_4.step(lowpass1); + lowpass3 = bq3_5.step(lowpass2); + + return lowpass3; +} + +float SigInterpreter::filter4(float input){ + + highpass1 = bq4_1.step(input); + highpass2 = bq4_2.step(highpass1); + rect = fabs(highpass2); + lowpass1 = bq4_3.step(rect); + lowpass2 = bq4_4.step(lowpass1); + lowpass3 = bq4_5.step(lowpass2); + + return lowpass3; +} + +
diff -r ad96602f71c0 -r 096e6a7bd90b SigInterpreter.h --- a/SigInterpreter.h Fri Oct 28 12:48:27 2016 +0000 +++ b/SigInterpreter.h Wed Nov 02 15:39:01 2016 +0000 @@ -3,17 +3,23 @@ #include "initialize.h" - - class SigInterpreter { public: SigInterpreter(); - double readValue(int); - double filter(float); + float readValue(int); + float filter1(float); + float filter2(float); + float filter3(float); + float filter4(float); private: - + float highpass1; + float highpass2; + float rect; + float lowpass1; + float lowpass2; + float lowpass3; }; #endif /* SIGINTERPRETER_H */