script zover

Dependencies:   HIDScope MODSERIAL mbed

Revision:
16:f7881b420c83
Parent:
15:2adb036a191f
diff -r 2adb036a191f -r f7881b420c83 main.cpp
--- a/main.cpp	Wed Oct 22 13:28:24 2014 +0000
+++ b/main.cpp	Thu Oct 23 09:44:01 2014 +0000
@@ -3,6 +3,16 @@
 #include "HIDScope.h"
 #include <iostream>
 
+PwmOut m_speed1(PTA5);
+    DigitalOut m_dir1(PTA4);
+    PwmOut m_speed2(PTC8);
+    DigitalOut m_dir2(PTC9);    
+    
+    float s_speed1;
+    float s_dir1;
+    float s_speed2;
+    float s_dir2;
+
 #define A1LP    0.018180963222803
 #define A0LP     0.016544013176248
 #define B1LP    -1.718913340044714
@@ -20,18 +30,12 @@
 #define B2N -0.988036
 
 #define TSAMP 0.001
-
 #define TRESHOLD 0.03
-
-
 AnalogIn    emg1(PTB1);
 AnalogIn    emg2(PTB2);
 
-DigitalOut  red(LED1) ;
-DigitalOut  blue(LED2);
-
 MODSERIAL pc(USBTX,USBRX);
-HIDScope scope(4);
+HIDScope scope(5);
 Ticker timer;
 volatile bool looptimerflag;
 
@@ -136,6 +140,7 @@
     scope.set(1,yave1);
     scope.set(2,ylp2);
     scope.set(3,yave2);  
+    scope.set(4,y1);
     scope.send();
 }
 
@@ -184,6 +189,9 @@
 {
     pc.baud(115200);
     timer.attach(setlooptimerflag,TSAMP);
+     m_speed1=0;
+        m_speed2=0;
+    
     
     while(1) {
         while(!looptimerflag);
@@ -192,18 +200,20 @@
         
         emg_value1 =  readEMG1();  
         emg_value2 =  readEMG2();   
-        //yave1 = filter1(emg_value1);
+        yave1 = filter1(emg_value1);
         yave2 = filter2(emg_value2);
-        yave1 = 0.06;
+        
         if(yave1>TRESHOLD){
                   y1 = 1;
-                  blue = 1;
-                  red =0;
+                    cout<<y1<<endl;  
+                    m_speed1=y1;
+                    m_dir1=0;           
                   }
         else{
                   y1 = 0;
-                  red =0;
-                  blue =1;
+                  cout<<y1<<endl;
+                  m_speed1=y1;
+                  m_dir1=1;
                   }
         if(yave2>TRESHOLD){
                   y2 = 1;