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 PID by
Revision 3:7f0ed54318df, committed 2016-11-08
- Comitter:
- HangL
- Date:
- Tue Nov 08 21:19:04 2016 +0000
- Parent:
- 2:0fff4827f3b6
- Commit message:
Changed in this revision
| PID.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/PID.cpp Sun Nov 06 18:07:12 2016 +0000
+++ b/PID.cpp Tue Nov 08 21:19:04 2016 +0000
@@ -1,8 +1,8 @@
#include "PID.h"
-float Stand_Kc=120.0;float Stand_tauI=0.004;float Stand_tauD=0.0007;
-float Speed_Kc=0.0;float Speed_tauI=0.0;float Speed_tauD=0.0;
+float Stand_Kc=86.4/*84.0*//*120.0*/;float Stand_tauI=0.0288/*0.0028*//*0.004 and if times 10 is better!*/;float Stand_tauD=0.000504/*0.000504*//*0.0007*/;
+float Speed_Kc=/*3.0*/40.0;float Speed_tauI=/*0.015*/0.20;float Speed_tauD=0.0;//20,0.1better than 26.0,0.13
//PID::PID(float Kc, float tauI, float tauD, float interval)
PID::PID(float interval)
{
@@ -239,12 +239,20 @@
}
float PID::Speedcompute(double Stepper,double Target)
{
- static double Bias,PWM,Last_bias;
+ static double Bias,PWM,/*Last_bias,*/Integral_bias;
+ Stepper=Stepper/10;
Bias=Stepper-Target;
- PWM+=Speed_Kc*(Bias-Last_bias)+Speed_tauI*Bias;
- Last_bias=Bias;
+ /////////////////////////////////////
+ Stepper*=0.7;
+ Stepper+=Bias*0.3;
+ Integral_bias+=Stepper;
+ // Integral_bias+=Bias;
+ // PWM+=Speed_Kc*(Bias-Last_bias)+Speed_tauI*Bias;
+ PWM=Stepper*Speed_Kc+Integral_bias*Speed_tauI;
+ // Last_bias=Bias;
return PWM;
}
+
float PID::getInMin() {
return inMin_;
