Flying Sea Glider / Mbed 2 deprecated 2019_19feb19_jcw_noSD

Dependencies:   mbed MODSERIAL FATFileSystem

Revision:
9:d5fcdcb3c89d
--- /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