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

Dependents:   Tourobo2022_TBCMotorDriver

Committer:
YutaTogashi
Date:
Thu Dec 30 16:07:37 2021 +0000
Revision:
6:4074aded9b9d
Parent:
4:3c2651359136
20211231 add resetFunction now=0.0f,before=0.0f

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 4:3c2651359136 15 void setupLimit(float UpperLimit,float FallLimit);
YutaTogashi 4:3c2651359136 16
YutaTogashi 2:7fede27af6ca 17 void calculate(float targetValue,float nowValue,bool enableErrorIntegration=true);
YutaTogashi 0:630126b8994f 18
YutaTogashi 1:4bc4c63ea283 19 void reset();
YutaTogashi 1:4bc4c63ea283 20
YutaTogashi 0:630126b8994f 21 float getDuty();
YutaTogashi 0:630126b8994f 22
YutaTogashi 0:630126b8994f 23 private:
YutaTogashi 0:630126b8994f 24
YutaTogashi 4:3c2651359136 25 float KP,KI,KD,PERIOD,duty,now,before,upperLimit,fallLimit;
YutaTogashi 0:630126b8994f 26 float p,i,d,e,e1,e2;
YutaTogashi 0:630126b8994f 27 short MODE;
YutaTogashi 0:630126b8994f 28 //Timer pid;
YutaTogashi 0:630126b8994f 29 };
YutaTogashi 0:630126b8994f 30
YutaTogashi 0:630126b8994f 31 #endif