Simple PID controller class with output clamp

Dependents:   NXPCUPcar

PIDcontroller.h

Committer:
Clarkk
Date:
2017-07-04
Revision:
0:070ecbe87363
Child:
1:946d71f8afc6

File content as of revision 0:070ecbe87363:

#include "mbed.h"

#ifndef _PIDCONTROLLER_H
#define _PIDCONTROLLER_H

class PID
{
    public:

    PID();
    void reset(void);
    void setReference(float ref);
    void setCoefficients(float Kp, float Ki, float Kd);
    void setOutputLimits(float min, float max);
    float processNewValue(float input);
    float getControllerOutput(void);
    
    private:

    float target;    
    float kp, ki, kd;
    float integral,derivative;
    float error,previous_error;
    float outputMin,outputMax;
    
    Timer t;
};

#endif