EMG controlling calibration + filters biorobotics group 13 BMT

Dependencies:   HIDScope biquadFilter mbed

Files at this revision

API Documentation at this revision

Comitter:
RichellBooyink
Date:
Tue Oct 20 19:41:02 2015 +0000
Parent:
9:21e427de5ada
Commit message:
Alles staat nu in 1 code. Het zou moeten werken. Inclusief kalibratie en t waarden (treshold waarden)

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 21e427de5ada -r e51b4c73131a main.cpp
--- a/main.cpp	Tue Oct 20 14:08:43 2015 +0000
+++ b/main.cpp	Tue Oct 20 19:41:02 2015 +0000
@@ -9,7 +9,7 @@
 Timer Timer_Calibration;
 Ticker EMG_Control;
 
-bool Cali;
+bool Cali = false;
 double TimeCali = 5;
 
 // Filter1 = High pass filter tot 20 Hz
@@ -49,7 +49,7 @@
     return y;
 }
 
-void Filters_bicepsleft()
+void MyController()
 {
     // Biceps left
     u1 = EMG_bicepsleft.read();
@@ -151,7 +151,13 @@
     y36 = biquad (u35, flp1_v1, flp1_v2, flp1_a1, flp1_a2, flp1_b0* 0.010386, flp1_b1* 0.010386, flp1_b2* 0.010386);
     u36 = y36;
     final_filter4 = biquad(u36, flp2_v1, flp2_v2, flp2_a1, flp2_a2, flp2_b0*0.000109, flp2_b1*0.000109, flp2_b2*0.000109);
-
+    
+    scope.set (0,final_filter1);
+    scope.set (1,final_filter2);
+    scope.set (2,final_filter3);
+    scope.set (3,final_filter4);
+    scope.send ();
+    
     if (Cali == true) {
         if (final_filter1 >= fblmax) {
             fblmax=final_filter1;
@@ -173,24 +179,13 @@
     }
 }
 
-// Send signals to HIDScope
-void Filters_EMG ()
-{
-    scope.set (0,final_filter1);
-    scope.set (1,final_filter2);
-    scope.set (2,final_filter3);
-    scope.set (3,final_filter4);
-    scope.send ();
-}
-
 int main ()
 {
-    EMG_Control.attach_us(Filters_EMG,1e3);
+    EMG_Control.attach_us(MyController,1e3);
     Timer_Calibration.start();
     if (Timer_Calibration < TimeCali) {
         Cali = true;
-    }
-    if (Timer_Calibration > TimeCali) {
+    } else {
         Cali = false;
     }
     Timer_Calibration.stop();