pid

Dependents:   OneCircleRobot

Fork of PID by Kiko Ishimoto

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PID.h Source File

PID.h

00001 
00002 #ifndef PID_H
00003 #define PID_H
00004 
00005 #include "mbed.h"
00006 class PID
00007 {
00008 protected:
00009     PID(const PID& p);
00010     PID& operator=(const PID &p) {
00011         return *this;
00012     }
00013 public:
00014 
00015     void PIDctrl();
00016     void InputLimits(float max,float min);
00017     void OutputLimits(float max,float min);
00018     PID(float tauKc, float tauKi, float tauKd ,Timer *T);
00019     void setbias(float bias_){bias=bias_;}
00020     float s_dErrIntg ,dErr_prev;
00021     void start();
00022     void pid_reset();
00023     void setInterval(float inter);
00024     //Getters.
00025     void stop();
00026     float dTarget;
00027     float dPoint;
00028     // PI制御ゲイン
00029     float GAIN_P ;//1.5 // 比例ゲイン
00030     float GAIN_I ;//2.8 // 積分ゲイン
00031     float GAIN_D ;//0.2
00032     float data;
00033     double dErrDiff;
00034     
00035     float userInt;
00036     float userDiff;
00037     float userProp;
00038     bool intF;
00039     bool diffF;
00040     bool propF;
00041 private:
00042     float bias;
00043     float OutMax;
00044     float InMax;
00045     float OutMin;
00046     float InMin;
00047     float OutSpan;
00048     float InSpan;
00049     Timer *timer;
00050     float prev_time;
00051     float gettime() {
00052         float a = timer->read()-prev_time;
00053         prev_time=timer->read();
00054         return a;
00055     }
00056     Ticker T;
00057     float interval;
00058 
00059 };
00060 
00061 #endif