Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
pid.h
- Committer:
- jasonliujc
- Date:
- 2015-12-05
- Revision:
- 11:8faa068940f1
- Parent:
- 10:332a4ad5911d
File content as of revision 11:8faa068940f1:
#ifndef PID_H
#define PID_H
#include"mbed.h"
#include "util.h"
class ctrl{
public:
ctrl(){
setKp(0);
setKi(0);
setKd(0);
setprevErr(0);
setErr(0);
setCorrection(0);
floategrater=1;
decay=1;
TErr=0;
RErr=0;
prevTime=0;
timer.start();
}
void setKp(float num);
void setKi(float num);
void setKd(float num);
void setprevErr(float num);
void setErr(float num);
void setCorrection(float num);
float pctrl();
float ictrl();
float dctrl();
float getT();
float getR();
float total();
void adjust(float xSpeed,float L, float R);
void setErr();
void updateErr(float e);
private:
float error;
float ki;
float kd;
float prevTime;
float kp;
float prevErr;
float correction;
float floategrater;
float decay;
float TErr;
float RErr;
Timer timer;
};
#endif //PID_H
//#ifndef PID_H
//#define PID_H
//
//#include "mbed.h"
//
//class PIDController
//{
//public:
// PIDController(void (*output)(float), float (*error)(void),
// float Kp, float Ki, float Kd,
// float dt = .1) :
// m_Kp(Kp), m_Ki(Ki), m_Kd(Kd),
// m_dt(dt), m_integral(0), m_pError(0)
// {
// m_out = output;
// m_error = error;
// };
//
// void onLoop();
// void reset();
//private:
// float iController(float error);
// float dController(float error);
//
// float m_integral;
// float m_pError;
//
// float m_dt;
//
// float m_Kp, m_Ki, m_Kd;
// void (*m_out)(float);
// float (*m_error)(void);
//};
//
//
