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:
- 8:5ed6685f6edd
- Parent:
- 6:477382219bcf
- Child:
- 13:521d6c6e7042
--- a/PID.h Thu Mar 28 01:07:54 2019 +0000
+++ b/PID.h Sun Mar 31 20:31:30 2019 +0000
@@ -28,14 +28,12 @@
float compute (float currVal)
{
- float currErr = setPoint - (currVal);
+ float currErr = setPoint - currVal;
float controlAction;
- if (currVal > *inMax_) {*inMax_ = currVal;}
- if (currVal < *inMin_) {*inMin_ = currVal;}
-
-
-
+ //if (currVal > *inMax_) {*inMax_ = currVal; *inMin_ = -1.0f*currVal;}
+ //if (currVal < *inMin_) {*inMin_ = currVal; *inMax_ = -1.0f*currVal;}
+
controlAction = prevControlAction - (PrevErr*Kp_) + (Kp_*currErr)+ (Ki_*Ts*currErr) + ((Kd_/Ts)*(currErr - PrevErr - PrevErr + PrevPrevErr));
prevControlAction = controlAction;