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:
- 4:208f5279143a
- Parent:
- 3:01b5e80d842d
- Child:
- 5:f1613df66ceb
--- a/WheelControl/P.h Sat Mar 09 14:27:48 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-//CURRENTLY EMPTY BUT I MAY JUST MAKE A NEW CLASS FOR THE P CONTROL
-class P
-{
- private:
- float inMin;
- float inMax;
- float control;
-
- float outMin;
- float outMax;
-
- float gain;
-
-
- public:
- P(float G)
- {
- gain = G;
- inMin = 0.0f;
- inMax = 3.3f;
- outMin = 0.0f;
- outMax = 1.0f;
- control = 0;
- }
-
- void setInputLimits(float inMin_, float inMax_)
- {
- if (inMin_ > inMax_) {return;} //cant be true can it
- inMin = inMin_;
- inMax = inMax_;
- }
-
- void setOutputLimits(float outMin_, float outMax_)
- {
- if (outMin_ > outMax_) {return;}
- outMin = outMin_;
- outMax = outMax_;
- }
-
- float compute(float curVal_)
- {
- float temp = ((control-curVal_)*gain)+curVal_; //amplify difference by gain and add to current value
- 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
- }
-
- void setControl(float wantedVal_)
- {
- if (wantedVal_ > inMax) {control = inMax;}
- else if (wantedVal_ <inMin) {control = inMin;}
- else {control = wantedVal_;}
- }
-
- float returnControl(void)
- {
- return control;
- }
-
-};
\ No newline at end of file