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.
Fork of BX-car by
Revision 16:7ada30380595, committed 2014-06-30
- Comitter:
- physicsgood
- Date:
- Mon Jun 30 03:13:49 2014 +0000
- Parent:
- 15:3fa780990a6a
- Commit message:
- 11
Changed in this revision
controller.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 3fa780990a6a -r 7ada30380595 controller.cpp --- a/controller.cpp Mon Jun 30 02:54:45 2014 +0000 +++ b/controller.cpp Mon Jun 30 03:13:49 2014 +0000 @@ -195,12 +195,13 @@ float centerB = sp; // center of black float error = centerB - centerR; if(error > -8 && error <8){ - return 0.085; + return Kp; } else if((error < -8 && error > -20)||(error > 8 && error < 40)){ - return 0.085 + Kp*error; + //return 0.085 + Kp*error; + return Kp; } - else return 0.085; + else return Kp;
diff -r 3fa780990a6a -r 7ada30380595 main.cpp --- a/main.cpp Mon Jun 30 02:54:45 2014 +0000 +++ b/main.cpp Mon Jun 30 03:13:49 2014 +0000 @@ -32,7 +32,7 @@ //out_min out_max servo range // -DigitalOut task_pin(PTD1); +DigitalOut task_pin(PTD1);` TSISensor tsi; int main() { @@ -150,25 +150,9 @@ pc.printf("angle: %f\r\n",PID_v); //pc.printf("%f %d %d speed :%f bk_center %f PID:%f \r\n",cam_to_M_ctrlr.de_v,cam.de_v,cam.de_v2,motor,b_r_c,PID_v); //b_r_c range 0~128 - /*error = 20 - b_r_c; - integral = 0.3 * integral + error; //0.3 is the factor to make old datas become smaller - derivative = error - last_error; - - //turn = error*Kp + integral*Ki + derivative*Kd; - - if(error < -8 && error >8){ - servo.set_angle(0.085); - } - else if (error > 8 && error <108){ - servo.set_angle(0.085+turn); - } - else if (error <-8 && error>-20){ - servo.set_angle(0.085+turn); - }*/ - last_error = error; - servo.set_angle(0.05); + servo.set_angle(PID_v);