Yuta Togashi / PID

Dependents:   Tourobo2022_TBCMotorDriver

Pid.h

Committer:
YutaTogashi
Date:
2019-09-10
Revision:
2:7fede27af6ca
Parent:
1:4bc4c63ea283
Child:
4:3c2651359136

File content as of revision 2:7fede27af6ca:

#ifndef PID_H
#define PID_H

#include "mbed.h"

enum MODE_NUMBER{
    POSITION_PID,
    SPEED_PID,
};

class Pid {
    public:
        void setup(float Kp,float Ki,float Kd,short PidMode = 0,float period = 0.01f);
        
        void calculate(float targetValue,float nowValue,bool enableErrorIntegration=true);
        
        void reset();
        
        float getDuty();
  
    private:
        
        float KP,KI,KD,PERIOD,duty,now,before;
        float p,i,d,e,e1,e2;
        short MODE;
        //Timer pid;
};

#endif