Flying Sea Glider / Mbed 2 deprecated 2019_19feb19_jcw_noSD

Dependencies:   mbed MODSERIAL FATFileSystem

Committer:
mkelly10
Date:
Fri Oct 20 11:41:22 2017 +0000
Revision:
9:d5fcdcb3c89d
Tested 10/19/17 Folders

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mkelly10 9:d5fcdcb3c89d 1 #ifndef MBED_DEPTHCONTROLLER_H
mkelly10 9:d5fcdcb3c89d 2 #define MBED_DEPTHCONTROLLER_H
mkelly10 9:d5fcdcb3c89d 3
mkelly10 9:d5fcdcb3c89d 4 #include "mbed.h"
mkelly10 9:d5fcdcb3c89d 5
mkelly10 9:d5fcdcb3c89d 6 class PIDController
mkelly10 9:d5fcdcb3c89d 7 {
mkelly10 9:d5fcdcb3c89d 8 public:
mkelly10 9:d5fcdcb3c89d 9 PIDController();
mkelly10 9:d5fcdcb3c89d 10
mkelly10 9:d5fcdcb3c89d 11 void update(float position, float velocity, float dt);
mkelly10 9:d5fcdcb3c89d 12
mkelly10 9:d5fcdcb3c89d 13 float getOutput();
mkelly10 9:d5fcdcb3c89d 14
mkelly10 9:d5fcdcb3c89d 15 void setPgain(float gain);
mkelly10 9:d5fcdcb3c89d 16 void setIgain(float gain);
mkelly10 9:d5fcdcb3c89d 17 void setDgain(float gain);
mkelly10 9:d5fcdcb3c89d 18
mkelly10 9:d5fcdcb3c89d 19 void writeSetPoint(float cmd);
mkelly10 9:d5fcdcb3c89d 20
mkelly10 9:d5fcdcb3c89d 21 void setHiLimit(float limit);
mkelly10 9:d5fcdcb3c89d 22 void setLoLimit(float limit);
mkelly10 9:d5fcdcb3c89d 23
mkelly10 9:d5fcdcb3c89d 24 void toggleDeadBand(bool toggle); //implement this
mkelly10 9:d5fcdcb3c89d 25 void setDeadBand(float deadband); //implement this
mkelly10 9:d5fcdcb3c89d 26
mkelly10 9:d5fcdcb3c89d 27 protected:
mkelly10 9:d5fcdcb3c89d 28 float _setPoint;
mkelly10 9:d5fcdcb3c89d 29 float _Pgain;
mkelly10 9:d5fcdcb3c89d 30 float _Dgain;
mkelly10 9:d5fcdcb3c89d 31 float _Igain;
mkelly10 9:d5fcdcb3c89d 32
mkelly10 9:d5fcdcb3c89d 33 float _hiLimit; //these variables clamp the allowable set points
mkelly10 9:d5fcdcb3c89d 34 float _loLimit; //these variables clamp the allowable set points
mkelly10 9:d5fcdcb3c89d 35
mkelly10 9:d5fcdcb3c89d 36 float _error;
mkelly10 9:d5fcdcb3c89d 37 float _deadband;
mkelly10 9:d5fcdcb3c89d 38 bool _deadbandFlag;
mkelly10 9:d5fcdcb3c89d 39
mkelly10 9:d5fcdcb3c89d 40 float _integral;
mkelly10 9:d5fcdcb3c89d 41 float _lastTime;
mkelly10 9:d5fcdcb3c89d 42 float _dt;
mkelly10 9:d5fcdcb3c89d 43
mkelly10 9:d5fcdcb3c89d 44
mkelly10 9:d5fcdcb3c89d 45 float _output;
mkelly10 9:d5fcdcb3c89d 46
mkelly10 9:d5fcdcb3c89d 47 // bool configFlag;
mkelly10 9:d5fcdcb3c89d 48 // int readConfiguration();
mkelly10 9:d5fcdcb3c89d 49
mkelly10 9:d5fcdcb3c89d 50 };
mkelly10 9:d5fcdcb3c89d 51
mkelly10 9:d5fcdcb3c89d 52 template <typename T>
mkelly10 9:d5fcdcb3c89d 53 T clamp(T value, T min, T max)
mkelly10 9:d5fcdcb3c89d 54 {
mkelly10 9:d5fcdcb3c89d 55 if(value < min) {
mkelly10 9:d5fcdcb3c89d 56 return min;
mkelly10 9:d5fcdcb3c89d 57 } else if(value > max) {
mkelly10 9:d5fcdcb3c89d 58 return max;
mkelly10 9:d5fcdcb3c89d 59 } else {
mkelly10 9:d5fcdcb3c89d 60 return value;
mkelly10 9:d5fcdcb3c89d 61 }
mkelly10 9:d5fcdcb3c89d 62 };
mkelly10 9:d5fcdcb3c89d 63
mkelly10 9:d5fcdcb3c89d 64 #endif