pid
Fork of PID by
PID.h@5:3519920d064d, 2015-09-23 (annotated)
- Committer:
- kikoaac
- Date:
- Wed Sep 23 06:01:32 2015 +0000
- Revision:
- 5:3519920d064d
- Parent:
- 3:34f4f22b18e7
- Child:
- 6:775c9421fe3b
?????????
;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aberk | 0:6e12a3e5af19 | 1 | |
aberk | 0:6e12a3e5af19 | 2 | #ifndef PID_H |
aberk | 0:6e12a3e5af19 | 3 | #define PID_H |
aberk | 0:6e12a3e5af19 | 4 | |
aberk | 0:6e12a3e5af19 | 5 | #include "mbed.h" |
kikoaac | 5:3519920d064d | 6 | class PID |
kikoaac | 5:3519920d064d | 7 | { |
kikoaac | 5:3519920d064d | 8 | protected: |
kikoaac | 5:3519920d064d | 9 | PID(const PID& p); |
kikoaac | 5:3519920d064d | 10 | PID& operator=(const PID &p) { |
kikoaac | 5:3519920d064d | 11 | return *this; |
kikoaac | 5:3519920d064d | 12 | } |
kikoaac | 5:3519920d064d | 13 | void PIDctrl(); |
kikoaac | 5:3519920d064d | 14 | public: |
kikoaac | 5:3519920d064d | 15 | void InputLimits(float max,float min); |
kikoaac | 5:3519920d064d | 16 | void OutputLimits(float max,float min); |
kikoaac | 5:3519920d064d | 17 | PID(float tauKc, float tauKi, float tauKd ,Timer *T); |
kikoaac | 5:3519920d064d | 18 | |
kikoaac | 5:3519920d064d | 19 | double s_dErrIntg ,dErr_prev; |
kikoaac | 5:3519920d064d | 20 | void start(); |
kikoaac | 5:3519920d064d | 21 | void pid_reset(); |
kikoaac | 5:3519920d064d | 22 | void setInterval(double inter); |
kikoaac | 5:3519920d064d | 23 | //Getters. |
kikoaac | 5:3519920d064d | 24 | void stop(); |
kikoaac | 5:3519920d064d | 25 | double dTarget; |
kikoaac | 5:3519920d064d | 26 | double dPoint; |
kikoaac | 5:3519920d064d | 27 | // PI制御ゲイン |
kikoaac | 5:3519920d064d | 28 | double GAIN_P ;//1.5 // 比例ゲイン |
kikoaac | 5:3519920d064d | 29 | double GAIN_I ;//2.8 // 積分ゲイン |
kikoaac | 5:3519920d064d | 30 | double GAIN_D ;//0.2 |
kikoaac | 5:3519920d064d | 31 | double data; |
kikoaac | 5:3519920d064d | 32 | private: |
kikoaac | 5:3519920d064d | 33 | float OutMax; |
kikoaac | 5:3519920d064d | 34 | float InMax; |
kikoaac | 5:3519920d064d | 35 | float OutMin; |
kikoaac | 5:3519920d064d | 36 | float InMin; |
kikoaac | 5:3519920d064d | 37 | float OutSpan; |
kikoaac | 5:3519920d064d | 38 | float InSpan; |
kikoaac | 5:3519920d064d | 39 | Timer *timer; |
kikoaac | 5:3519920d064d | 40 | float gettime() { |
kikoaac | 5:3519920d064d | 41 | static float prev_time; |
kikoaac | 5:3519920d064d | 42 | float a = timer->read()-prev_time; |
kikoaac | 5:3519920d064d | 43 | prev_time=timer->read(); |
kikoaac | 5:3519920d064d | 44 | return a; |
kikoaac | 5:3519920d064d | 45 | } |
kikoaac | 5:3519920d064d | 46 | //Ticker T; |
kikoaac | 5:3519920d064d | 47 | float interval; |
kikoaac | 5:3519920d064d | 48 | |
aberk | 0:6e12a3e5af19 | 49 | }; |
aberk | 0:6e12a3e5af19 | 50 | |
kikoaac | 5:3519920d064d | 51 | #endif |