now with PID controler XXXD

Dependencies:   HIDScope MODSERIAL QEI biquadFilter mbed

Fork of another_try_from_scratch_on_emg by Daniqe Kottelenberg

Revision:
37:60dd2e42bf8f
Parent:
15:bb4a6c7836d8
Child:
38:23601b26bb84
--- a/main.cpp	Mon Oct 24 11:24:50 2016 +0000
+++ b/main.cpp	Fri Oct 28 12:53:42 2016 +0000
@@ -19,14 +19,18 @@
 int    onoffsignal=0;
 double cut_off_value=0.08; //gespecifeerd door floortje
 
-BiQuad filterhigh(9.5654e-01,-1.9131e+00,9.5654e-01,-1.9112e+00,9.1498e-01);
-BiQuad filterlow (6.2942e-06, 1.2588e-05,6.2942e-06,-1.9929e+00,9.9292e-01);
+BiQuad filterhigh(9.1497e-01, -1.8299e+00, 9.1497e-01, -1.8227e+00, 8.3718e-01); //
+BiQuad filterlow ( 3.9130e-05  , 7.8260e-05  , 3.9130e-05,   -1.9822e+00 ,  9.8239e-01); //   
+BiQuad notch1(9.9115e-01  ,-1.8853e+00 ,  9.9115e-01 , -1.8909e+00  , 9.9103e-01);
+BiQuad notch2( 1.0000e+00 , -1.9022e+00,   1.0000e+00 , -1.8965e+00 ,  9.9127e-01);
 
 //functions which are called in ticker
 void filter(){
         emg_biceps_right=emg_biceps_right_in.read();                            //read the emg value from the elektrodes
         emg_filtered_high_biceps_right= filterhigh.step(emg_biceps_right);
-        emg_abs_biceps_right=fabs(emg_filtered_high_biceps_right); //fabs because float
+        double emg_filtered_notch1=notch1.step(emg_filtered_high_biceps_right);
+        double emg_filtered_notch2=notch2.step(emg_filtered_notch1);
+        emg_abs_biceps_right=fabs(emg_filtered_notch2); //fabs because float
         emg_filtered_biceps_right=filterlow.step(emg_abs_biceps_right);
         led=!led;
         
@@ -34,13 +38,13 @@
         {onoffsignal=1;}
           
         else 
-        {onoffsignal=0;}
+       {onoffsignal=0;}
                       
         //send signals  to scope
-        scope.set(0, emg_biceps_right );           //set emg signal to scope in channel 1
-        scope.set(1, emg_filtered_biceps_right);    
-        scope.set(2, onoffsignal);
-        scope.send();                       //send all the signals to the scope
+        scope.set(0, emg_filtered_notch2 );           //set emg signal to scope in channel 1
+        scope.set(1, emg_abs_biceps_right);    
+        scope.set(2, emg_filtered_biceps_right);
+       scope.send();                       //send all the signals to the scope
                 }
 
 //program