Pakai akselerasi

Dependencies:   DigitDisplay Motor PID Ping mbed millis

Fork of MainProgram_BaseBaru_fix_omni_5April_fix by KRAI 2017

Files at this revision

API Documentation at this revision

Comitter:
gustavaditya
Date:
Wed Apr 05 16:04:08 2017 +0000
Parent:
44:452c214d9cf5
Commit message:
Pakai akselerasi

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Apr 05 12:54:03 2017 +0000
+++ b/main.cpp	Wed Apr 05 16:04:08 2017 +0000
@@ -78,6 +78,9 @@
 float PIVOT             = 0.17;      // PWM Pivot Kanan, Pivot Kiri
 float tuneDpn           = 0.80;     // Tunning PWM motor Depan
 float tuneBlk           = 0.80;     // Tunning PWM motor belakang
+float tuneAksel         = 0.6;
+int aksel               = 0;
+float tuneAkselBlk      = 0.4;
 float tuneR             = 0.78;
 float tuneL             = 0.72;
 float serong            = 0.4;
@@ -307,6 +310,11 @@
         // Power Screw Down
         caseJoystick = 12;       
     } 
+    else
+    {
+        tuneAksel = 0.6;
+        aksel = 0;
+    }
     
     return(caseJoystick);
 }
@@ -521,8 +529,12 @@
         case (3) : 
         {
             // Kanan
-            motorDpn.speed(-tuneDpn);
-            motorBlk.speed(tuneBlk);
+            aksel++;
+            if (aksel>300)
+                tuneAksel = 0.9;
+            
+            motorDpn.speed(-tuneAksel);
+            motorBlk.speed(tuneAksel);
             motorR.brake(1);
             motorL.brake(1);
             break;
@@ -530,8 +542,12 @@
         case (4) : 
         {
             // Kiri
-            motorDpn.speed(tuneDpn);
-            motorBlk.speed(-tuneBlk);
+            aksel++;
+            if (aksel>300)
+                tuneAksel = 0.9;
+                
+            motorDpn.speed(tuneAksel);
+            motorBlk.speed(-tuneAksel);
             motorR.brake(1);
             motorL.brake(1);
             break;
@@ -539,8 +555,12 @@
         case (8) : 
         {
             // Maju
-            motorR.speed(tuneR);
-            motorL.speed(-tuneL);
+            aksel++;
+            if (aksel>300)
+                tuneAksel = 0.9;
+            
+            motorR.speed(tuneAksel);
+            motorL.speed(-tuneAksel);
             motorDpn.brake(1);
             motorBlk.brake(1);
             break;
@@ -548,8 +568,12 @@
         case (9) : 
         {
             // Mundur
-            motorR.speed(-tuneR);
-            motorL.speed(tuneL);
+            aksel++;
+            if (aksel>300)
+                tuneAksel = 0.9;
+            
+            motorR.speed(-tuneAksel);
+            motorL.speed(tuneAksel);
             motorDpn.brake(1);
             motorBlk.brake(1);
             break;
@@ -585,6 +609,7 @@
                 previousMillis3 = millis();
                 flag_Pneu = true;
                 ready = false;
+                
             }
             break;
         }
@@ -628,6 +653,8 @@
         }
         default : 
         {
+            tuneAksel = 0.6;
+            aksel = 0;
             motorDpn.brake(1);
             motorBlk.brake(1);
             motorR.brake(1);