for dror
Revision 1:b738a8164729, committed 2019-12-25
- Comitter:
- noamnahum
- Date:
- Wed Dec 25 09:00:32 2019 +0000
- Parent:
- 0:6e12a3e5af19
- Commit message:
- code change
Changed in this revision
PID.cpp | Show annotated file Show diff for this revision Revisions of this file |
PID.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 6e12a3e5af19 -r b738a8164729 PID.cpp --- a/PID.cpp Thu Sep 02 16:48:10 2010 +0000 +++ b/PID.cpp Wed Dec 25 09:00:32 2019 +0000 @@ -57,8 +57,8 @@ //Default the limits to the full range of I/O: 3.3V //Make sure to set these to more appropriate limits for //your application. - setInputLimits(0.0, 3.3); - setOutputLimits(0.0, 3.3); + setInputLimits(20, 90.0); + setOutputLimits(-1, 1); tSample_ = interval; @@ -259,8 +259,8 @@ controllerOutput_ = scaledBias + Kc_ * (error + (tauR_ * accError_) - (tauD_ * dMeas)); //Make sure the computed output is within output constraints. - if (controllerOutput_ < 0.0) { - controllerOutput_ = 0.0; + if (controllerOutput_ < -1.0) { + controllerOutput_ = -1.0; } else if (controllerOutput_ > 1.0) { controllerOutput_ = 1.0; }
diff -r 6e12a3e5af19 -r b738a8164729 PID.h --- a/PID.h Thu Sep 02 16:48:10 2010 +0000 +++ b/PID.h Wed Dec 25 09:00:32 2019 +0000 @@ -1,81 +1,16 @@ -/** - * @author Aaron Berk - * - * @section LICENSE - * - * Copyright (c) 2010 ARM Limited - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @section DESCRIPTION - * - * A PID controller is a widely used feedback controller commonly found in - * industry. - * - * This library is a port of Brett Beauregard's Arduino PID library: - * - * http://www.arduino.cc/playground/Code/PIDLibrary - * - * The wikipedia article on PID controllers is a good place to start on - * understanding how they work: - * - * http://en.wikipedia.org/wiki/PID_controller - * - * For a clear and elegant explanation of how to implement and tune a - * controller, the controlguru website by Douglas J. Cooper (who also happened - * to be Brett's controls professor) is an excellent reference: - * - * http://www.controlguru.com/ - */ + #ifndef PID_H #define PID_H -/** - * Includes - */ #include "mbed.h" -/** - * Defines - */ -#define MANUAL_MODE 0 -#define AUTO_MODE 1 -/** - * Proportional-integral-derivative controller. - */ class PID { public: - /** - * Constructor. - * - * Sets default limits [0-3.3V], calculates tuning parameters, and sets - * manual mode with no bias. - * - * @param Kc - Tuning parameter - * @param tauI - Tuning parameter - * @param tauD - Tuning parameter - * @param interval PID calculation performed every interval seconds. - */ + PID(float Kc, float tauI, float tauD, float interval); /**