![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
tugas akhir
Dependencies: Motor mbed millis
Fork of DagonFly__RoadToJapan_15Mei_Ultimate by
Diff: main.cpp
- Revision:
- 39:11358f3f61ff
- Parent:
- 38:3ef6754bd8d8
- Child:
- 40:5b937cac959a
--- a/main.cpp Fri Feb 17 13:05:02 2017 +0000 +++ b/main.cpp Sat Feb 18 00:37:33 2017 +0000 @@ -55,17 +55,17 @@ // Variable Atas double speed, speed2; -const double maxSpeed = 0.95; +const double maxSpeed = 0.95, minSpeed = 0.0; const double kpA=0.6757, kdA=0.6757, kiA=0.00006757; double p,i,d; double p2,i2,d2; double last_error = 0, current_error, sum_error = 0; double last_error2 = 0, current_error2, sum_error2 = 0; float rpm, rpm2; -float target_rpm = 12.0, target_rpm2 = 16.0; +float target_rpm = 13.0, target_rpm2 = 15.0; const float maxRPM = 27, minRPM = 0; // Limit 25 atau 27 -const float pwmPowerUp = 0.78; +const float pwmPowerUp = 0.7; const float pwmPowerDown = -0.9; // Variable Bawah @@ -311,16 +311,16 @@ case (6) : { // Target Pulse PID ++ Motor Depan - target_rpm2 = target_rpm2++; - target_rpm = target_rpm++; + target_rpm2 = target_rpm2+1.0; + target_rpm = target_rpm+1.0; init_rpm(); break; } case (7) : { // Target Pulse PID -- Motor Depan - target_rpm2 = target_rpm2--; - target_rpm = target_rpm--; + target_rpm2 = target_rpm2-1.0; + target_rpm = target_rpm-1.0; init_rpm(); break; } @@ -348,7 +348,8 @@ { // Power Screw Up //powerScrew.speed(pwmPowerUp); - ReloadOn = !ReloadOn; + //ReloadOn = !ReloadOn; + powerScrew.speed(pwmPowerUp); break; } case (12) : @@ -361,26 +362,24 @@ { motorDpn.brake(1); motorBlk.brake(1); - // aktuator(); - /* if (!infraAtas) - { + if(isReload){ + powerScrew.speed(pwmPowerDown); + if(!limitBawah){ + isReload = false; + ReloadOn = false; + } + } + else if(!limitTengah){ + isReload = true; + } + else{ powerScrew.brake(1); } - if (!limitTengah) - { - case_joy = 12; - aktuator(); - } - if (!limitBawah) - { - case_joy = 11; - aktuator(); - }*/ } } // End Switch } - void reloader() +/*void reloader() { if(ReloadOn){ if(isReload){ @@ -403,7 +402,7 @@ else{ powerScrew.brake(1); } -} +}*/ void launcher() @@ -427,6 +426,9 @@ if(speed > maxSpeed){ launcherBlk.speed(maxSpeed); } + else if ( speed < minSpeed){ + launcherBlk.speed(minSpeed); + } else { launcherBlk.speed(speed); } @@ -448,6 +450,9 @@ if (speed2 > maxSpeed){ launcherDpn.speed(maxSpeed); } + else if ( speed < minSpeed){ + launcherDpn.speed(minSpeed); + } else{ launcherDpn.speed(speed2); } @@ -491,7 +496,7 @@ case_joy = case_joystick(); aktuator(); launcher(); - reloader(); + //reloader(); if ((millis()-previousMillis3 >= 425)&&(flag_Pneu)){ pneumatik = 1; flag_Pneu = false;