Alles in 1

Dependencies:   Encoder HIDScope MODSERIAL QEI mbed

Fork of RoboBird3 by Fernon Eijkhoudt

Revision:
29:7653adbbb101
Parent:
28:b7d01a55530f
Child:
30:37e778f27fce
--- a/main.cpp	Fri Oct 16 09:27:42 2015 +0000
+++ b/main.cpp	Fri Oct 16 10:35:24 2015 +0000
@@ -11,7 +11,7 @@
 QEI             Encoder(D10,D11,NC,32,QEI::X2_ENCODING); //Encoder
 DigitalOut      Direction2(D7);
 PwmOut          PowerMotor2(D6);
-QEI             BIER(D12,D13,NC,32,QEI::X2_ENCODING);
+QEI             Encoder2(D12,D13,NC,32,QEI::X2_ENCODING);
 PwmOut          PowerServo(D3);
 
 // Buttons & EMG (PotMeter)
@@ -30,7 +30,7 @@
 
 // Debugging
 Serial          pc(USBTX, USBRX);
-HIDScope        scope(3);
+HIDScope        scope(6);
 
 
 
@@ -120,9 +120,9 @@
             Errori2 = 0;
         }
         if (Error2>=0) {
-            Direction2 = 1;
+            Direction2 = 0;
         } else {
-            Direction2 = 0;
+            Direction2 = 1;
         }
         v2=Kp2*Error2 + Kd2*Errord2 + Ki2*Errori2;
     }
@@ -132,11 +132,14 @@
 {
     Pulses = Encoder.getPulses();
     Rotatie = (Pulses*twopi)/4200; 
-    Pulses2 = BIER.getPulses();
+    Pulses2 = Encoder2.getPulses();
     Rotatie2 = (Pulses2*twopi)/4200;
     scope.set(0,Goal);
     scope.set(1,Rotatie);
     scope.set(2,emg_value);
+    scope.set(3,Goal2);
+    scope.set(4,Rotatie2);
+    scope.set(5,emg_value2);
     scope.send();
 }
 void EMGsample()
@@ -179,7 +182,7 @@
     PowerServo.period_ms(20);
     while (true) {
         Encoder.reset();
-        BIER.reset();
+        Encoder2.reset();
         if (Button == 0) {
             Excecute =! Excecute;
         }
@@ -228,11 +231,11 @@
             if (Rotatie2 >= -turnlimit && Rotatie2 <= turnlimit && OutRange2 == false) { // EMG aansturing
                 if (emg_value2 >= T2 ) {
                     Direction2 = 1;
-                    v2 = 0.1;
+                    v2 = 0.05;
                 }
                 if (emg_value2 > T1 && emg_value2 < T2) {
                     Direction2 = 0;
-                    v2 = 0.1;
+                    v2 = 0.05;
                 }
                 if (emg_value2 <= T1) {
                     Direction2 = 0;