script zover

Dependencies:   HIDScope MODSERIAL mbed

Revision:
11:91d827c62a50
Parent:
9:cc60d28643cb
Child:
12:8604a4c1c708
--- a/main.cpp	Mon Oct 20 10:58:07 2014 +0000
+++ b/main.cpp	Wed Oct 22 09:24:13 2014 +0000
@@ -21,39 +21,39 @@
 
 #define TSAMP 0.001
 
-AnalogIn    emg0(PTB1);
+AnalogIn    emg1(PTB1);
 MODSERIAL pc(USBTX,USBRX);
 HIDScope scope(5);
 Ticker timer;
-float emg_value, ylp1, yhp1, yn;
+float emg_value1, ylp1, yhp1, yn1;
 volatile bool looptimerflag;
-float ysum = 0, yave=0 ;
+float ysum1 = 0, yave1=0 ;
 
 
 float readEMG()
 {
 
-    emg_value=emg0.read();
-    return emg_value;
+    emg_value1=emg1.read();
+    return emg_value1;
 }
 
-float notchfilter(float ylp1)
+float notchfilter1(float ylp1)
 {
-    static float yn,x1=0,x2=0,y1=0,y2=0,x;
+    static float yn1,x1=0,x2=0,y1=0,y2=0,x;
     x = ylp1;
-    yn = A0N*x + A1N*x1+A2N*x2+B1N*y1+B2N*y2;
+    yn1 = A0N*x + A1N*x1+A2N*x2+B1N*y1+B2N*y2;
     x2 = x1;
     x1 = x;
     y2 = y1;
-    y1 = yn;
-    return yn;
+    y1 = yn1;
+    return yn1;
 }
 
 
-float hpfilter1(float yn)
+float hpfilter1(float yn1)
 {
     static float x1=0,y1=0,x2=0, y2=0,x;
-    x = yn;
+    x = yn1;
     yhp1 = x + A1HP1*x1 + A0HP1*x2 - B1HP1*y1 - B0HP1*y2;
     x2 = x1;
     x1 = x;
@@ -77,11 +77,11 @@
 
 void viewer()
 {
-    scope.set(0,emg_value);
-    scope.set(1,yn);
+    scope.set(0,emg_value1);
+    scope.set(1,yn1);
     scope.set(2,yhp1);
     scope.set(3,ylp1);
-    scope.set(4,yave);
+    scope.set(4,yave1);
     
     scope.send();
 }
@@ -100,17 +100,17 @@
 
         while(!looptimerflag) /* do nothing */;
         looptimerflag = false;
-        emg_value =  readEMG();
-        yn = notchfilter(emg_value);
-        yhp1 = hpfilter1(yn);  //function hpfilter
+        emg_value1 =  readEMG();
+        yn1 = notchfilter1(emg_value1);
+        yhp1 = hpfilter1(yn1);  //function hpfilter
         ylp1 = lpfilter1(yhp1);       //function filter
        
-        ysum = ysum+sqrt(ylp1*ylp1);
+        ysum1 = ysum1+sqrt(ylp1*ylp1);
         n++;
        
         if(n==100) {
-            yave = abs(ysum/100);
-            ysum = 0;
+            yave1 = abs(ysum1/100);
+            ysum1 = 0;
             n = 0;
             }