pid

Dependents:   OneCircleRobot

Fork of PID by Kiko Ishimoto

PID.h

Committer:
kikoaac
Date:
2015-10-30
Revision:
6:775c9421fe3b
Parent:
5:3519920d064d
Child:
7:66e3f3fd08d8

File content as of revision 6:775c9421fe3b:


#ifndef PID_H
#define PID_H

#include "mbed.h"
class PID
{
protected:
    PID(const PID& p);
    PID& operator=(const PID &p) {
        return *this;
    }
    void PIDctrl();
public:
    void InputLimits(float max,float min);
    void OutputLimits(float max,float min);
    PID(float tauKc, float tauKi, float tauKd ,Timer *T);
    void setbias(float bias_){bias=bias_;}
    double s_dErrIntg ,dErr_prev;
    void start();
    void pid_reset();
    void setInterval(double inter);
    //Getters.
    void stop();
    double dTarget;
    double dPoint;
    // PI制御ゲイン
    double GAIN_P ;//1.5 // 比例ゲイン
    double GAIN_I ;//2.8 // 積分ゲイン
    double GAIN_D ;//0.2
    double data;
private:
    float bias;
    float OutMax;
    float InMax;
    float OutMin;
    float InMin;
    float OutSpan;
    float InSpan;
    Timer *timer;
    float gettime() {
        static float prev_time;
        float a = timer->read()-prev_time;
        prev_time=timer->read();
        return a;
    }
    //Ticker T;
    float interval;

};

#endif