updated for quadcopter
Dependents: Autonomous_quadcopter
Fork of PID by
Revision 7:8ee2f9ba6ac3, committed 2018-05-22
- Comitter:
- edy05
- Date:
- Tue May 22 19:37:34 2018 +0000
- Parent:
- 6:02717c0e74ce
- Commit message:
- Changed zero error, added stabalize functions, setLandingPoint()
Changed in this revision
PID.cpp | Show annotated file Show diff for this revision Revisions of this file |
PID.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 02717c0e74ce -r 8ee2f9ba6ac3 PID.cpp --- a/PID.cpp Tue May 15 10:34:07 2018 +0000 +++ b/PID.cpp Tue May 22 19:37:34 2018 +0000 @@ -218,6 +218,11 @@ } +void PID::setLandingPoint(float sp) { + setPoint_ = sp; + +} + void PID::setProcessValue(float pv) { processVariable_ = pv; @@ -251,7 +256,7 @@ } float error = scaledSP - scaledPV; - if(error < 0.005 && error > -0.001){ + if(error < 0.002 && error > -0.001){ error = 0; if(stabelized_ == false){ printf("stabelized \n\r"); @@ -268,7 +273,6 @@ //integrate if it is not. This is to prevent reset-windup. if (!(prevControllerOutput_ >= 1 && error > 0) && !(prevControllerOutput_ <= 0 && error < 0)) { accError_ += error; - } //Compute the current slope of the input signal. @@ -321,6 +325,10 @@ return stabelized_; } +void PID::setNotStabelized(){ + stabelized_ = false; +} + float PID::getInMin() { return inMin_;
diff -r 02717c0e74ce -r 8ee2f9ba6ac3 PID.h --- a/PID.h Tue May 15 10:34:07 2018 +0000 +++ b/PID.h Tue May 22 19:37:34 2018 +0000 @@ -160,6 +160,10 @@ //if quadcopter reach stable level bool quadStabilized(void); + + void setNotStabelized(void); + + void setLandingPoint(float); //Getters. float getInMin();