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 MODSERIAL FATFileSystem
Diff: Controller/controller.hpp
- Revision:
- 9:d5fcdcb3c89d
diff -r 70412939a506 -r d5fcdcb3c89d Controller/controller.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Controller/controller.hpp Fri Oct 20 11:41:22 2017 +0000
@@ -0,0 +1,64 @@
+#ifndef MBED_DEPTHCONTROLLER_H
+#define MBED_DEPTHCONTROLLER_H
+
+#include "mbed.h"
+
+class PIDController
+{
+public:
+ PIDController();
+
+ void update(float position, float velocity, float dt);
+
+ float getOutput();
+
+ void setPgain(float gain);
+ void setIgain(float gain);
+ void setDgain(float gain);
+
+ void writeSetPoint(float cmd);
+
+ void setHiLimit(float limit);
+ void setLoLimit(float limit);
+
+ void toggleDeadBand(bool toggle); //implement this
+ void setDeadBand(float deadband); //implement this
+
+protected:
+ float _setPoint;
+ float _Pgain;
+ float _Dgain;
+ float _Igain;
+
+ float _hiLimit; //these variables clamp the allowable set points
+ float _loLimit; //these variables clamp the allowable set points
+
+ float _error;
+ float _deadband;
+ bool _deadbandFlag;
+
+ float _integral;
+ float _lastTime;
+ float _dt;
+
+
+ float _output;
+
+ // bool configFlag;
+ // int readConfiguration();
+
+};
+
+template <typename T>
+T clamp(T value, T min, T max)
+{
+ if(value < min) {
+ return min;
+ } else if(value > max) {
+ return max;
+ } else {
+ return value;
+ }
+};
+
+#endif
\ No newline at end of file