try this for a change

Dependencies:   HIDScope MODSERIAL QEI biquadFilter mbed

Fork of EMG_5 by Ralph Gerlings

Revision:
38:32c7e08bb281
Parent:
37:6ac3e70787d1
Child:
39:c15f84af49fd
--- a/main.cpp	Fri Nov 03 02:04:58 2017 +0000
+++ b/main.cpp	Fri Nov 03 02:19:10 2017 +0000
@@ -665,15 +665,15 @@
 // check to see if motor1 needs to be activated
 void SetMotor1() {
     //PIDcalculation1();
-    filter();
+    //filter();
     count1 = Encoder1.getPulses();
     angle1 += (0.0981 * count1);
     while (angle1<setpoint1 || angle1>setpoint1) {
         if (angle1<setpoint1){
-        motor1direction = 1; // counterclockwise rotation
+        motor1direction = 0; // counterclockwise rotation
         }
-        else {
-        motor1direction = 0; // clockwise rotation
+        else if (angle1>setpoint1){
+        motor1direction = 1; // clockwise rotation
         }
         if (angle1<setpoint1 || angle1>setpoint1) {
         motor1pwm = 0.5;
@@ -686,16 +686,16 @@
 
 // check if motor1 needs to be activated
 void SetMotor2() {
-    filter();
+    //filter();
     //PIDcalculation2();
     count2 = Encoder2.getPulses();
     angle2 += (0.0981 * count2);
     while (angle2<setpoint2 || angle2>setpoint2) {
-        if (angle2<setpoint1){
-        motor1direction = 1; // counterclockwise rotation
+        if (angle2<setpoint2){
+        motor1direction = 0; // counterclockwise rotation
         }
-        else {
-        motor1direction = 0; // clockwise rotation
+        else  if (angle2>setpoint2){
+        motor1direction = 1; // clockwise rotation
         }
         if (angle2<setpoint2 || angle2>setpoint2) {
         motor2pwm = 0.5;