DECS_YoungCHA / Mbed 2 deprecated BTS_dc_motor

Dependencies:   mbed

Committer:
ohdoyoel
Date:
Tue Aug 23 08:55:01 2022 +0000
Revision:
1:fa0730bf53ef
hello~

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ohdoyoel 1:fa0730bf53ef 1 #include "mbed.h"
ohdoyoel 1:fa0730bf53ef 2
ohdoyoel 1:fa0730bf53ef 3 #ifndef PID_H
ohdoyoel 1:fa0730bf53ef 4 #define PID_H
ohdoyoel 1:fa0730bf53ef 5
ohdoyoel 1:fa0730bf53ef 6 #define PID_SCALE 668 // 2*334
ohdoyoel 1:fa0730bf53ef 7
ohdoyoel 1:fa0730bf53ef 8 class PID
ohdoyoel 1:fa0730bf53ef 9 {
ohdoyoel 1:fa0730bf53ef 10 public:
ohdoyoel 1:fa0730bf53ef 11
ohdoyoel 1:fa0730bf53ef 12 PID(float Kc, float Ki, float Kd, float interval);
ohdoyoel 1:fa0730bf53ef 13
ohdoyoel 1:fa0730bf53ef 14 void ReadCurrentValue(int CurrentValue); // current Encoder Value
ohdoyoel 1:fa0730bf53ef 15 void SetTargetValue(int targetValue); // set Target Value
ohdoyoel 1:fa0730bf53ef 16 // float Performance(void); // drive Motor ( return 0~1.0)
ohdoyoel 1:fa0730bf53ef 17
ohdoyoel 1:fa0730bf53ef 18 float Performance_Speed(void);
ohdoyoel 1:fa0730bf53ef 19 float Performance_Location(void);
ohdoyoel 1:fa0730bf53ef 20
ohdoyoel 1:fa0730bf53ef 21 void Reset(void);
ohdoyoel 1:fa0730bf53ef 22 void ResetError(void);
ohdoyoel 1:fa0730bf53ef 23
ohdoyoel 1:fa0730bf53ef 24 float getP();
ohdoyoel 1:fa0730bf53ef 25 void setP(float);
ohdoyoel 1:fa0730bf53ef 26 float getI();
ohdoyoel 1:fa0730bf53ef 27 void setI(float);
ohdoyoel 1:fa0730bf53ef 28 float getD();
ohdoyoel 1:fa0730bf53ef 29 void setD(float);
ohdoyoel 1:fa0730bf53ef 30
ohdoyoel 1:fa0730bf53ef 31 float ReadCurrentVelocity(void);
ohdoyoel 1:fa0730bf53ef 32
ohdoyoel 1:fa0730bf53ef 33 private:
ohdoyoel 1:fa0730bf53ef 34
ohdoyoel 1:fa0730bf53ef 35 float Kp_;
ohdoyoel 1:fa0730bf53ef 36 float Ki_;
ohdoyoel 1:fa0730bf53ef 37 float Kd_;
ohdoyoel 1:fa0730bf53ef 38 float interval_;
ohdoyoel 1:fa0730bf53ef 39
ohdoyoel 1:fa0730bf53ef 40 float err_;
ohdoyoel 1:fa0730bf53ef 41 float accErr_;
ohdoyoel 1:fa0730bf53ef 42
ohdoyoel 1:fa0730bf53ef 43 int CV_;
ohdoyoel 1:fa0730bf53ef 44 int TV_;
ohdoyoel 1:fa0730bf53ef 45 int prevCV_;
ohdoyoel 1:fa0730bf53ef 46
ohdoyoel 1:fa0730bf53ef 47 float controllerOutput_;
ohdoyoel 1:fa0730bf53ef 48
ohdoyoel 1:fa0730bf53ef 49 // speed control
ohdoyoel 1:fa0730bf53ef 50 float prevVelocity_;
ohdoyoel 1:fa0730bf53ef 51
ohdoyoel 1:fa0730bf53ef 52 // location control
ohdoyoel 1:fa0730bf53ef 53 float ScaledCV_;
ohdoyoel 1:fa0730bf53ef 54 float ScaledTV_;
ohdoyoel 1:fa0730bf53ef 55 float ScaledPrevCV_;
ohdoyoel 1:fa0730bf53ef 56
ohdoyoel 1:fa0730bf53ef 57 float Scale_;
ohdoyoel 1:fa0730bf53ef 58 };
ohdoyoel 1:fa0730bf53ef 59
ohdoyoel 1:fa0730bf53ef 60
ohdoyoel 1:fa0730bf53ef 61 #endif /* PID_H */
ohdoyoel 1:fa0730bf53ef 62