PID用ライブラリ ※位置型PIDと速度型PIDの選択式

Dependents:   Tourobo2022_TBCMotorDriver

Committer:
YutaTogashi
Date:
Tue Sep 10 13:55:06 2019 +0000
Revision:
2:7fede27af6ca
Parent:
1:4bc4c63ea283
Child:
4:3c2651359136
20190910

Who changed what in which revision?

UserRevisionLine numberNew contents of line
YutaTogashi 0:630126b8994f 1 #ifndef PID_H
YutaTogashi 0:630126b8994f 2 #define PID_H
YutaTogashi 0:630126b8994f 3
YutaTogashi 0:630126b8994f 4 #include "mbed.h"
YutaTogashi 0:630126b8994f 5
YutaTogashi 0:630126b8994f 6 enum MODE_NUMBER{
YutaTogashi 0:630126b8994f 7 POSITION_PID,
YutaTogashi 0:630126b8994f 8 SPEED_PID,
YutaTogashi 0:630126b8994f 9 };
YutaTogashi 0:630126b8994f 10
YutaTogashi 0:630126b8994f 11 class Pid {
YutaTogashi 0:630126b8994f 12 public:
YutaTogashi 0:630126b8994f 13 void setup(float Kp,float Ki,float Kd,short PidMode = 0,float period = 0.01f);
YutaTogashi 0:630126b8994f 14
YutaTogashi 2:7fede27af6ca 15 void calculate(float targetValue,float nowValue,bool enableErrorIntegration=true);
YutaTogashi 0:630126b8994f 16
YutaTogashi 1:4bc4c63ea283 17 void reset();
YutaTogashi 1:4bc4c63ea283 18
YutaTogashi 0:630126b8994f 19 float getDuty();
YutaTogashi 0:630126b8994f 20
YutaTogashi 0:630126b8994f 21 private:
YutaTogashi 0:630126b8994f 22
YutaTogashi 0:630126b8994f 23 float KP,KI,KD,PERIOD,duty,now,before;
YutaTogashi 0:630126b8994f 24 float p,i,d,e,e1,e2;
YutaTogashi 0:630126b8994f 25 short MODE;
YutaTogashi 0:630126b8994f 26 //Timer pid;
YutaTogashi 0:630126b8994f 27 };
YutaTogashi 0:630126b8994f 28
YutaTogashi 0:630126b8994f 29 #endif