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: mbed
Diff: PID.cpp
- Revision:
- 6:688449345fff
- Parent:
- 0:9c49bdc7e402
- Child:
- 7:edd065946e9b
--- a/PID.cpp Wed Nov 22 02:33:33 2017 +0000
+++ b/PID.cpp Wed Nov 22 05:56:05 2017 +0000
@@ -15,6 +15,8 @@
{
double error = 0;
error= signed( counterM1- counterM2);
+ pc.printf("counter1: %6.6f",counterM1);
+ pc.printf("counter2: %6.6f",counterM2);
double P = Kp * error;
total_error = (total_error+error);
double I = Ki * total_error;
@@ -26,9 +28,9 @@
}
//encoder controlled
-const double Kp_e =1;
+const double Kp_e =.00001;
const double Ki_e = 0;
-const double Kd_e = 0.1;
+const double Kd_e = 0;
const double decay_e=1;
double total_error_e=0;
@@ -38,6 +40,11 @@
double PID_e(){
double error = 0;
error= signed ( LL_t.read_u16()-RR_t.read_u16());
+
+ // pc.printf("ledL: %d\n",LL_t.read_u16());
+ // pc.printf("LedR: %d\n",RR_t.read_u16());
+ // pc.printf("kp error: %8.8f\n",(signed ( LL_t.read_u16()-RR_t.read_u16()))*Kp_e);
+
double P = Kp_e * error;
total_error = (total_error+error);
double I = Ki_e * total_error;