Universal PID library

Dependents:   WRS2019_master FourOmniMecha WRS2020_mecanum_node

PID.h

Committer:
sgrsn
Date:
2019-12-14
Revision:
0:873985df821c

File content as of revision 0:873985df821c:

#ifndef PID_H
#define PID_H
#include "mbed.h"

/*sample code

*/

class PID
{
    public:
        PID(Timer *T);
        
        float controlP(float target, float current, float new_Kp);
        float controlPI(float target, float current);
        float controlPID(float target, float current);
        
        void setParameter(float new_Kp, float new_Ki, float new_Kd);
        void setParameter(float new_Ku, float new_Pu);
        void setParameterPI(float new_Ku, float new_Pu);
        void reset();

        float Ku;
        float Pu;
        float Kp;
        float Ti;
        float Td;
        float Ki;
        float Kd;
        
        private:
        Timer *timer;
        float integral;
        float last_error;
        float current_time;
        float last_time;
};

#endif