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.
Dependencies: mbed
Diff: PID.h
- Revision:
- 6:477382219bcf
- Parent:
- 5:f1613df66ceb
- Child:
- 8:5ed6685f6edd
--- a/PID.h Mon Mar 25 22:42:31 2019 +0000
+++ b/PID.h Tue Mar 26 16:19:47 2019 +0000
@@ -37,15 +37,15 @@
controlAction = prevControlAction - (PrevErr*Kp_) + (Kp_*currErr)+ (Ki_*Ts*currErr) + ((Kd_/Ts)*(currErr - PrevErr - PrevErr + PrevPrevErr));
-
- if (controlAction > *inMax_) {controlAction = *inMax_;}
- if (controlAction < *inMin_) {controlAction = *inMin_;}
prevControlAction = controlAction;
PrevPrevErr = PrevErr;
PrevErr = currErr;
//scale the control Action to the correct output limits and output
- return ((((controlAction)- *inMin_)/(*inMax_ - *inMin_)) * (outMax_ - outMin_)) + outMin_;
+ controlAction = ((((controlAction)- *inMin_)/(*inMax_ - *inMin_)) * (outMax_ - outMin_)) + outMin_;
+
+ if (controlAction > outMax_) {return outMax_;} else if (controlAction < outMin_) {return outMin_;} else {return controlAction;}
+
}
void setSetPoint(float _sP)