hari ini
Dependencies: DigitDisplay Motor PID Ping mbed millis
Fork of DagonFly__RoadToJapan_11Mei by
Revision 48:3006386dc8df, committed 2017-05-13
- Comitter:
- Najib_irvani
- Date:
- Sat May 13 07:27:51 2017 +0000
- Parent:
- 47:6cac4f1a3c8e
- Commit message:
- baru hari ini
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 6cac4f1a3c8e -r 3006386dc8df main.cpp --- a/main.cpp Sat May 13 05:47:10 2017 +0000 +++ b/main.cpp Sat May 13 07:27:51 2017 +0000 @@ -74,9 +74,9 @@ const float pwmPowerDown = -1.0; double jarak_ping=0; -double ping_target = 14; +double ping_target = 16; double ping_current_error, ping_previous_error1 = 0, ping_sum_error=0; -double ping_Kp = -0.2747, ping_Kd =0, ping_Ts=10; +double ping_Kp = -0.3747, ping_Ki =0, ping_Ts=10; double ping_pwm, ping_previous_pwm = 0; // Variable Bawah @@ -676,7 +676,8 @@ ping_current_error = (double) (ping_target-jarak_ping); 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_pwm = (double) ping_Kp*ping_current_error + ping_Ki*(ping_sum_error+ping_current_error)*ping_Ts; + ping_sum_error = ping_sum_error+ping_current_error; pc.printf("%.2f\n", jarak_ping); powerScrew.speed(ping_pwm);