Libary for control.
PID_Cntrl.h@4:1cbd6af9836c, 2021-04-22 (annotated)
- Committer:
- pmic
- Date:
- Thu Apr 22 06:57:43 2021 +0000
- Revision:
- 4:1cbd6af9836c
- Child:
- 6:e93f67d98616
Succsellfully tested IIF_Filter-class and PID_Cntrl-class.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pmic | 4:1cbd6af9836c | 1 | #ifndef PID_CNTRL_H_ |
pmic | 4:1cbd6af9836c | 2 | #define PID_CNTRL_H_ |
pmic | 4:1cbd6af9836c | 3 | |
pmic | 4:1cbd6af9836c | 4 | class PID_Cntrl |
pmic | 4:1cbd6af9836c | 5 | { |
pmic | 4:1cbd6af9836c | 6 | |
pmic | 4:1cbd6af9836c | 7 | public: |
pmic | 4:1cbd6af9836c | 8 | |
pmic | 4:1cbd6af9836c | 9 | PID_Cntrl(float I, float Ts, float uMin, float uMax); |
pmic | 4:1cbd6af9836c | 10 | PID_Cntrl(float P, float I, float Ts, float uMin, float uMax); |
pmic | 4:1cbd6af9836c | 11 | PID_Cntrl(float P, float I, float D, float Ts, float uMin, float uMax); |
pmic | 4:1cbd6af9836c | 12 | PID_Cntrl(float P, float I, float D, float tau_f, float Ts, float uMin, float uMax); |
pmic | 4:1cbd6af9836c | 13 | PID_Cntrl(float P, float I, float D, float tau_f, float tau_ro, float Ts, float uMin, float uMax); |
pmic | 4:1cbd6af9836c | 14 | |
pmic | 4:1cbd6af9836c | 15 | PID_Cntrl() {}; |
pmic | 4:1cbd6af9836c | 16 | |
pmic | 4:1cbd6af9836c | 17 | float operator()(float e) |
pmic | 4:1cbd6af9836c | 18 | { |
pmic | 4:1cbd6af9836c | 19 | return update(e); |
pmic | 4:1cbd6af9836c | 20 | } |
pmic | 4:1cbd6af9836c | 21 | float operator()(float e, float y) |
pmic | 4:1cbd6af9836c | 22 | { |
pmic | 4:1cbd6af9836c | 23 | return update(e, y); |
pmic | 4:1cbd6af9836c | 24 | } |
pmic | 4:1cbd6af9836c | 25 | |
pmic | 4:1cbd6af9836c | 26 | virtual ~PID_Cntrl(); |
pmic | 4:1cbd6af9836c | 27 | |
pmic | 4:1cbd6af9836c | 28 | void reset(float initValue); |
pmic | 4:1cbd6af9836c | 29 | |
pmic | 4:1cbd6af9836c | 30 | void setCoefficients(float I, float Ts, float uMin, float uMax); |
pmic | 4:1cbd6af9836c | 31 | void setCoefficients(float P, float I, float Ts, float uMin, float uMax); |
pmic | 4:1cbd6af9836c | 32 | void setCoefficients(float P, float I, float D, float Ts, float uMin, float uMax); |
pmic | 4:1cbd6af9836c | 33 | void setCoefficients(float P, float I, float D, float tau_f, float Ts, float uMin, float uMax); |
pmic | 4:1cbd6af9836c | 34 | void setCoefficients(float P, float I, float D, float tau_f, float tau_ro, float Ts, float uMin, float uMax); |
pmic | 4:1cbd6af9836c | 35 | |
pmic | 4:1cbd6af9836c | 36 | void setCoeff_P(float P); |
pmic | 4:1cbd6af9836c | 37 | void setCoeff_I(float D); |
pmic | 4:1cbd6af9836c | 38 | void setCoeff_D(float D); |
pmic | 4:1cbd6af9836c | 39 | |
pmic | 4:1cbd6af9836c | 40 | void scale_PIDT2_param(float scale); |
pmic | 4:1cbd6af9836c | 41 | |
pmic | 4:1cbd6af9836c | 42 | float update(float e); |
pmic | 4:1cbd6af9836c | 43 | float update(float e, float y); |
pmic | 4:1cbd6af9836c | 44 | |
pmic | 4:1cbd6af9836c | 45 | bool update_param(int cntrlr_param, float value); |
pmic | 4:1cbd6af9836c | 46 | |
pmic | 4:1cbd6af9836c | 47 | void set_limits(float uMin, float uMax); |
pmic | 4:1cbd6af9836c | 48 | |
pmic | 4:1cbd6af9836c | 49 | float get_ulimit(); |
pmic | 4:1cbd6af9836c | 50 | float get_P_gain(); |
pmic | 4:1cbd6af9836c | 51 | float get_bd(); |
pmic | 4:1cbd6af9836c | 52 | float get_ad(); |
pmic | 4:1cbd6af9836c | 53 | |
pmic | 4:1cbd6af9836c | 54 | private: |
pmic | 4:1cbd6af9836c | 55 | |
pmic | 4:1cbd6af9836c | 56 | float IPart, Dpart, d_old, u_old, uf; |
pmic | 4:1cbd6af9836c | 57 | float P, I, D, tau_f, tau_ro, Ts, uMin, uMax; |
pmic | 4:1cbd6af9836c | 58 | float bi, bd, ad, bf, af; |
pmic | 4:1cbd6af9836c | 59 | float P_init, I_init, D_init; |
pmic | 4:1cbd6af9836c | 60 | |
pmic | 4:1cbd6af9836c | 61 | void setInternalCoefficients(float P, float I, float D, float tau_f, float tau_ro, float Ts); |
pmic | 4:1cbd6af9836c | 62 | |
pmic | 4:1cbd6af9836c | 63 | void updateCoeff_I(float I, float Ts); |
pmic | 4:1cbd6af9836c | 64 | void updateCoeff_D(float D, float Ts, float tau_f); |
pmic | 4:1cbd6af9836c | 65 | void updateCoeff_RO(float Ts, float tau_ro); |
pmic | 4:1cbd6af9836c | 66 | |
pmic | 4:1cbd6af9836c | 67 | float saturate(float u, float uMin, float uMax); |
pmic | 4:1cbd6af9836c | 68 | |
pmic | 4:1cbd6af9836c | 69 | }; |
pmic | 4:1cbd6af9836c | 70 | |
pmic | 4:1cbd6af9836c | 71 | #endif |