dear josh
Dependencies: DigitDisplay Motor PID Ping mbed millis
Fork of DagonFly__RoadToJapan_15Mei by
Revision 51:292c5807a93f, committed 2017-05-15
- Comitter:
- Najib_irvani
- Date:
- Mon May 15 12:51:35 2017 +0000
- Parent:
- 50:8bc9dbca2ffa
- Commit message:
- dear josh
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 8bc9dbca2ffa -r 292c5807a93f main.cpp --- a/main.cpp Mon May 15 07:08:30 2017 +0000 +++ b/main.cpp Mon May 15 12:51:35 2017 +0000 @@ -74,9 +74,9 @@ const float pwmPowerDown = -1.0; double jarak_ping=0; -double ping_target = 15; +double ping_target = 17; double ping_current_error, ping_previous_error1 = 0, ping_sum_error=0; -double ping_Kp = -0.2747, ping_Kd = -0.535, ping_Ts=10; +double ping_Kp = -0.3747, ping_Kd = -0.535, ping_Ts=10; double ping_pwm, ping_previous_pwm = 0; // Variable Bawah @@ -677,8 +677,11 @@ ping_sum_error += ping_current_error*ping_Ts; ping_pwm = (double) ping_Kp*ping_current_error + ping_Kd*(ping_current_error-ping_previous_error1)/ping_Ts; - //ping_sum_error = ping_sum_error+ping_current_error; + if ((ping_pwm<0.7) && (ping_pwm>0.0)) ping_pwm = 0.7; + if ((ping_pwm>-0.5) && (ping_pwm<0.0)) ping_pwm = -0.5; + if (ping_pwm>1) ping_pwm=1; + if (ping_pwm<-1) ping_pwm=-1; pc.printf("%.2f\n", jarak_ping); powerScrew.speed(ping_pwm); @@ -818,9 +821,6 @@ if ((millis()-previousMillis3 >= 230)&&(flag_Pneu)){ pneumatik = 1; flag_Pneu = false; - //if (millis()-previousMillis6 >= 100){ - // ReloadOn = !ReloadOn; - //} } } else