PID用ライブラリ ※位置型PIDと速度型PIDの選択式
Dependents: Tourobo2022_TBCMotorDriver
Diff: Pid.h
- Revision:
- 0:630126b8994f
- Child:
- 1:4bc4c63ea283
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Pid.h Wed Dec 19 15:46:32 2018 +0000 @@ -0,0 +1,27 @@ +#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); + + float getDuty(); + + private: + + float KP,KI,KD,PERIOD,duty,now,before; + float p,i,d,e,e1,e2; + short MODE; + //Timer pid; +}; + +#endif \ No newline at end of file