pid
Revision 2:9dd174ee5ffc, committed 2019-11-19
- Comitter:
- sink
- Date:
- Tue Nov 19 09:42:59 2019 +0000
- Parent:
- 1:09b63bc8f46a
- Commit message:
- ?
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 09b63bc8f46a -r 9dd174ee5ffc PID.cpp --- a/PID.cpp Tue Jul 23 04:51:27 2019 +0000 +++ b/PID.cpp Tue Nov 19 09:42:59 2019 +0000 @@ -1,18 +1,18 @@ #include "PID.h" -PID::PID(double INT_TIME){ - _time = INT_TIME; +PID::PID(double _INT_TIME){ + _time = _INT_TIME; + _pre_err = 0; reset(); } -void PID::set(double P, double I, double D){ - _p = P; - _i = I; - _d = D; +void PID::set(double _P, double _I, double _D){ + _p = _P; + _i = _I; + _d = _D; } double PID::con (double _error){ - static double _pre_err = 0.0; double _result = 0; _result += _error * _p; @@ -32,4 +32,8 @@ _i = 0.0; _d = 0.0; _integ = 0.0; +} + +void PID::Ireset(){ + _integ = 0.0; } \ No newline at end of file
diff -r 09b63bc8f46a -r 9dd174ee5ffc PID.h --- a/PID.h Tue Jul 23 04:51:27 2019 +0000 +++ b/PID.h Tue Nov 19 09:42:59 2019 +0000 @@ -7,16 +7,18 @@ class PID { public: - PID(double INT_TIME); + PID(double _INT_TIME); - void set(double P, double I, double D); + void set(double _P, double _I, double _D); - double con (double error); + double con (double _error); void reset(); + void Ireset(); private: + double _pre_err; double _time; double _p; double _i;