EMG and motor script together, Not fully working yet,.

Dependencies:   Encoder MODSERIAL QEI biquadFilter mbed

Fork of Code_MotorEMG by Joost Herijgers

Revision:
12:ea9afe159eb1
Parent:
11:f23fe69ba3ef
Child:
13:3ad20c09b5b4
--- a/main.cpp	Wed Nov 01 11:36:04 2017 +0000
+++ b/main.cpp	Wed Nov 01 11:41:12 2017 +0000
@@ -305,10 +305,7 @@
 float          countzo;
 float          countzb;
 float          countzr;
-float          erroro;
-float          errorb;
-float          errorr;
- 
+
 float          hcounto;
 float          dcounto;
 float          hcountb;
@@ -358,18 +355,18 @@
 
 void MotorController1()
 {
-    int      reference_o = (int) (counto-hcounto);
+    int         reference_o = (int) (counto-hcounto);
     int         position_o = Encoder1.getPulses();
     
-    erroro = reference_o - position_o;
+    int error_o = reference_o - position_o;
     
-    pc.printf("Position_o = %i \n\r reference_o=%.2f\n\r",position_o,reference_o);
+    pc.printf("Position_o = %i \n\r reference_o=%i \n\r Error_o=%i\n\r" ,position_o,reference_o,error_o);
     
-    if (-100<erroro && erroro<100){
+    if (-100<error_o && error_o<100){
         motorValue1 = 0;
         }
     else {
-    motorValue1 = 0.1*P1(erroro, kpo);
+    motorValue1 = 0.1*P1(error_o, kpo);
     }    
     
     if (motorValue1 >=0) motor1DirectionPin=0;
@@ -390,7 +387,7 @@
     int reference_b = (int) (countb-hcountb);
     int position_b = Encoder2.getPulses();
 
-    errorb = reference_b - position_b;
+    int errorb = reference_b - position_b;
     
     pc.printf("position_b= %i", position_b);
     
@@ -419,7 +416,7 @@
     int reference_r = (int) (countr-hcountr);
     int position_r = Encoder3.getPulses();
         
-    errorr = reference_r - position_r;
+    int errorr = reference_r - position_r;
     
     pc.printf("position_r= %i", position_r);