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: WheelControl/P.h
- Revision:
- 3:01b5e80d842d
- Parent:
- 1:813f4b17ae65
--- a/WheelControl/P.h Sun Mar 03 00:55:10 2019 +0000
+++ b/WheelControl/P.h Sat Mar 09 14:27:48 2019 +0000
@@ -40,7 +40,9 @@
float compute(float curVal_)
{
float temp = ((control-curVal_)*gain)+curVal_; //amplify difference by gain and add to current value
- temp = (((temp-inMin)/(inMin - inMin))*(outMax-outMin))+outMin; //scales temp to the correct output Limits
+ temp = (((temp-inMin)/(inMax - inMin))*(outMax-outMin))+outMin; //scales temp to the correct output Limits
+ if (temp > 1.0f ) {temp = 1.0f;}
+ if (temp < -1.0f) {temp = -1.0f;}
return temp; //return the scaled value
}