Werkcollege opgave 23 september BMT K9

Dependencies:   Encoder HIDScope MODSERIAL mbed QEI biquadFilter

Revision:
23:c9c9c1d7864a
Parent:
22:14abcfdd1554
Child:
24:a1ce6a87103c
--- a/main.cpp	Fri Oct 09 08:40:14 2015 +0000
+++ b/main.cpp	Fri Oct 09 09:26:55 2015 +0000
@@ -13,8 +13,8 @@
 Ticker control_tick;
 
 //Define constants
-float emgL_L;
-float emgL_LH;
+float emgL_L, emgL_LH, emgLeft;
+double B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, MOVAVG_B;
 
 const float la1 = 0;
 const float la2 = 0.17156822136;
@@ -30,7 +30,7 @@
 const float hb2 = 0.8005910267; // Waarde van biquads via groep 1 2014
 biquadFilter Highpassfilter (ha1, ha2, hb0, hb1, hb2);
 
-HIDScope scope(3); // Aantal HIDScope kanalen
+HIDScope scope(4); // Aantal HIDScope kanalen
 
 void ControlGo() //Control flag
 {
@@ -46,11 +46,30 @@
     while(true) {
         
         if(control_go)
-        emgL_L = Lowpassfilter.step(emgL.read()); //emgL_L Linker bicep met lowpass filter
+        
+        // [EMG FILTEREN MET HIGH- EN LOWPASSFILTER] //
+        emgLeft = emgL.read();
+        emgLeft = fabs(emgLeft);
+        emgL_L = Lowpassfilter.step(emgLeft); //emgL_L Linker bicep met lowpass filter
         emgL_LH = Highpassfilter.step(emgL_L); //emgL_L met Highpassfilter
+        
+//        // [MOVING AVERAGE]//
+//        B0 = emgL_LH;
+//        MOVAVG_B=B0*0.1+B1*0.1+B2*0.1+B3*0.1+B4*0.1+B5*0.1+B6*0.1+B7*0.1+B8*0.1+B9*0.1;
+//        B9=B8;
+//        B8=B7;
+//        B7=B6;
+//        B6=B5;
+//        B5=B4;
+//        B4=B3;
+//        B3=B2;
+//        B2=B1;
+//        B1=B0;
+        
         scope.set(0,emgL.read());
         scope.set(1,emgL_L);
         scope.set(2,emgL_LH);
+       // scope.set(3,MOVAVG_B);
         scope.send();
         led1 = 1; //De led gaat flikkeren wanneer deze loop uitgevoerd wordt