โปรแกรมของบอร์ด Motion

Dependencies:   BEAR_Reciever Motor eeprom iSerial mbed

Fork of DogPID by Digital B14

Revision:
34:0cf04acfe422
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pidcontrol.h	Wed Feb 03 14:39:39 2016 +0000
@@ -0,0 +1,49 @@
+#ifndef _PIDCONTROL_H_
+#define _PIDCONTROL_H_
+
+#include "mbed.h"
+
+class PID{
+    public:
+        PID();
+        PID(float p,float i,float d);
+        void setGoal(float ref);
+        //float getGoal();    
+        void setCurrent(float sensor);
+        float compute();
+        
+        void setMargin(float gap);
+        float getMargin();
+        void setIntegalLimit(float limit);
+        float getIntegalLimit();
+        
+        float getErrorNow();
+        float getErrorLast();
+        float getErrorDiff();
+        float getErrorIntegal();
+        
+        void setKp(float);
+        void setKi(float);
+        void setKd(float);
+        
+        float getKp();
+        float getKi();
+        float getKd();
+        
+    private:
+        float e_n;      //error now
+        float e_n_1;    //error last time
+        float e_i;      //error integal
+        float il;       //integal limit
+        float margin;    //output margin
+        
+        float Kp,Ki,Kd;    
+ 
+        float setpoint;
+        float input;    
+        float output;
+};
+    
+
+
+#endif
\ No newline at end of file