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: DigitDisplay Motor PID Ping mbed millis
Fork of DagonFly__RoadToJapan_15Mei_Ultimate by
Revision 48:3006386dc8df, committed 2017-05-13
- Comitter:
- Najib_irvani
- Date:
- Sat May 13 07:27:51 2017 +0000
- Parent:
- 47:6cac4f1a3c8e
- Child:
- 49:0c9148ab8585
- Commit message:
- baru hari ini
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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);
