Problems with motor #2
Fork of PID by
Revision 2:b214010a0c1b, committed 2013-07-02
- Comitter:
- gabdo
- Date:
- Tue Jul 02 21:03:30 2013 +0000
- Parent:
- 1:01f3ec7bd956
- Child:
- 3:8172f254dff4
- Commit message:
- Problems with motor #2
Changed in this revision
PID.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/PID.cpp Sat Jun 08 19:31:29 2013 +0000 +++ b/PID.cpp Tue Jul 02 21:03:30 2013 +0000 @@ -31,10 +31,10 @@ float proportionalControl, integralControl, derivativeControl; // How far away we are from the target - currentError = targetPosition - currentPosition; + currentError += targetPosition - currentPosition; // Sum of the errors the controller has incurred over time - integralError += currentError * dt; + integralError = currentError * dt; // Cap the sum of errors to prevent excessive correction if (integralError < -windupGainGuard) { integralError = -windupGainGuard;