Simple PID controller class with output clamp
Diff: PIDcontroller.h
- Revision:
- 0:070ecbe87363
- Child:
- 1:946d71f8afc6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PIDcontroller.h Tue Jul 04 19:21:16 2017 +0000 @@ -0,0 +1,29 @@ +#include "mbed.h" + +#ifndef _PIDCONTROLLER_H +#define _PIDCONTROLLER_H + +class PID +{ + public: + + PID(); + void reset(void); + void setReference(float ref); + void setCoefficients(float Kp, float Ki, float Kd); + void setOutputLimits(float min, float max); + float processNewValue(float input); + float getControllerOutput(void); + + private: + + float target; + float kp, ki, kd; + float integral,derivative; + float error,previous_error; + float outputMin,outputMax; + + Timer t; +}; + +#endif \ No newline at end of file