Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Motor PID Ping mbed millis
Fork of MainProgram_BaseBaru_19Feb by
Revision 41:336a19289c2d, committed 2017-02-18
- Comitter:
- gustavaditya
- Date:
- Sat Feb 18 11:33:00 2017 +0000
- Parent:
- 40:5b937cac959a
- Commit message:
- Update 19 Februari 2017 Pk. 18.32
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Feb 18 03:24:05 2017 +0000
+++ b/main.cpp Sat Feb 18 11:33:00 2017 +0000
@@ -61,10 +61,10 @@
double last_error = 0, current_error, sum_error = 0;
double last_error2 = 0, current_error2, sum_error2 = 0;
float rpm, rpm2;
-float target_rpm = 13.0, target_rpm2 = 15.0;
-const float maxRPM = 27, minRPM = 0; // Limit 25 atau 27
+float target_rpm = 15.0, target_rpm2 = 17.0;
+const float maxRPM = 28, minRPM = 0; // Limit 25 atau 27
-const float pwmPowerUp = 0.7;
+const float pwmPowerUp = 0.8;
const float pwmPowerDown = -0.9;
float jarak_ping=0;
@@ -241,13 +241,13 @@
if (target_rpm>maxRPM-2){
target_rpm = maxRPM-2;
}
- if (target_rpm<minRPM){
+ if (target_rpm<minRPM+8){
target_rpm = minRPM;
}
if (target_rpm2>maxRPM){
target_rpm2 = maxRPM;
}
- if (target_rpm2<minRPM+2){
+ if (target_rpm2<minRPM+2+8){
target_rpm2 = minRPM+2;
}
}
@@ -381,11 +381,11 @@
else if(!limitTengah){
isReload = true;
}
- else if(jarak_ping > 4){
+ else if((jarak_ping > 4) && !flag_Pneu){
powerScrew.speed(pwmPowerUp);
}
- else if(jarak_ping < 3) {
- powerScrew.speed(pwmPowerDown);
+ else if((jarak_ping < 3.5 ) && !flag_Pneu) {
+ powerScrew.speed(-0.1);
}
else{
powerScrew.brake(1);
@@ -472,7 +472,10 @@
wait_ms(1000);
// initializing encoder
+ pneumatik =1;
+
setCenter();
+
wait_ms(500);
//initializing PING
@@ -483,8 +486,8 @@
while(1)
{
// interupsi pembacaan PING setiap 30 ms
- if(millis() - previousMillis4 >= 30){
- jarak_ping = pingAtas.Read_cm()/2;
+ if(millis() - previousMillis4 >= 5){ //30
+ jarak_ping = (float)pingAtas.Read_cm()/2;
pingAtas.Send();
previousMillis4 = millis();
@@ -503,7 +506,7 @@
aktuator();
launcher();
reloader();
- if ((millis()-previousMillis3 >= 425)&&(flag_Pneu)){
+ if ((millis()-previousMillis3 >= 370)&&(flag_Pneu)){
pneumatik = 1;
flag_Pneu = false;
}
