Eindversie. LU: 07-11-13.

Dependencies:   MODSERIAL mbed Encoder

Files at this revision

API Documentation at this revision

Comitter:
Socrates
Date:
Tue Oct 15 19:51:13 2013 +0000
Parent:
0:b13a317308d1
Child:
2:3dab90d3aac2
Commit message:
Voordat ik de filters aanpas. 21:50 op 15-1013;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Oct 15 14:08:58 2013 +0000
+++ b/main.cpp	Tue Oct 15 19:51:13 2013 +0000
@@ -15,23 +15,39 @@
 int main()
 {
     Ticker looptimer;
-    looptimer.attach(setlooptimerflag,0.001);
-    float x,y,y1,x1,z1,yabs,z,yabs1;
-    //const float ts=0.001;
+    const float ts=0.001;
+    looptimer.attach(setlooptimerflag,ts);
+    float x,y,y1,x1,z1,yabs,z,yabs1,k,numh1,numh2,denh1,denh2,numl1,numl2,denl1,denl2;
     x1=0;
     y1=0;
     z1=0;
     yabs1=0;
+    numh1=0;
+    numh2=0;
+    denh1=0;
+    denh2=0;
+    numl1=0;
+    numl2=0;
+    denl1=0;
+    denl2=0;
     pc.baud(115200);
 
     while(1) {
         while(looptimerflag != true);
         looptimerflag = false;
-        x=emg.read();
-        y=(y1/1.001-(0.9969/1.001)*x1+(0.9978565/1.001)*x);
+        k=emg.read();
+        x=(k-0.5)*2.0;
+        
+        //High pass, 1 Hz
+        y=(y1/1.000994230391224-(0.996868235770807/1.000994230391224)*x1+(0.997865599482850/1.000994230391224)*x);
+
+        //Rectify
         yabs=abs(y);
-        z=(z1/1.001-(0.006244/1.001)*yabs1+(0.006238/1.001)*yabs);
-        pc.printf("%f\n\r",z);
+
+        //Low pass, 1 Hz
+        z=(z1/1.000987999680353-(0.006244035046343/1.000987999680353)*yabs1+(0.006237787927252/1.000987999680353)*yabs);
+        
+        pc.printf("%f\n\r",yabs);
         x1=x;
         y1=y;
         z1=z;