Tobias Vögeli
/
GRT_VC_PIDT1
pr7
PID_Cntrl.h@2:1ded9d10f322, 2019-05-14 (annotated)
- Committer:
- voegetob
- Date:
- Tue May 14 15:29:24 2019 +0000
- Revision:
- 2:1ded9d10f322
- Parent:
- 1:92f175969d90
pr7
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
altb2 | 0:05dd1de8cc3f | 1 | #ifndef PID_CNTRL_H_ |
altb2 | 0:05dd1de8cc3f | 2 | #define PID_CNTRL_H_ |
altb2 | 0:05dd1de8cc3f | 3 | |
pmic | 1:92f175969d90 | 4 | // PID Controller Class |
altb2 | 0:05dd1de8cc3f | 5 | class PID_Cntrl |
altb2 | 0:05dd1de8cc3f | 6 | { |
altb2 | 0:05dd1de8cc3f | 7 | public: |
altb2 | 0:05dd1de8cc3f | 8 | |
pmic | 1:92f175969d90 | 9 | PID_Cntrl(float Kp, float Ki, float Kd, float Tf, float Ts, float uMin, float uMax); |
altb2 | 0:05dd1de8cc3f | 10 | |
altb2 | 0:05dd1de8cc3f | 11 | float operator()(float error) { |
altb2 | 0:05dd1de8cc3f | 12 | return update((double)error); |
altb2 | 0:05dd1de8cc3f | 13 | } |
altb2 | 0:05dd1de8cc3f | 14 | |
altb2 | 0:05dd1de8cc3f | 15 | virtual ~PID_Cntrl(); |
altb2 | 0:05dd1de8cc3f | 16 | |
altb2 | 0:05dd1de8cc3f | 17 | void reset(float initValue); |
altb2 | 0:05dd1de8cc3f | 18 | float update(double error); |
altb2 | 0:05dd1de8cc3f | 19 | |
altb2 | 0:05dd1de8cc3f | 20 | private: |
altb2 | 0:05dd1de8cc3f | 21 | |
pmic | 1:92f175969d90 | 22 | // controller parameters (member variables) |
voegetob | 2:1ded9d10f322 | 23 | float Kp, Ki, Kd, Tf, Ts, uMin, uMax; |
pmic | 1:92f175969d90 | 24 | |
pmic | 1:92f175969d90 | 25 | // storage for signals (member variables) |
voegetob | 2:1ded9d10f322 | 26 | float e_old, uI_old, uD_old; |
altb2 | 0:05dd1de8cc3f | 27 | }; |
altb2 | 0:05dd1de8cc3f | 28 | |
pmic | 1:92f175969d90 | 29 | #endif |
pmic | 1:92f175969d90 | 30 |