Cube Mini Solution
Dependencies: mbed QEI MPU6050 BLE_API nRF51822 MCP4725 eMPL_MPU6050
PID_Cntrl.h@24:c953b74ed88b, 2020-08-28 (annotated)
- Committer:
- BoulusAJ
- Date:
- Fri Aug 28 09:23:40 2020 +0000
- Revision:
- 24:c953b74ed88b
- Parent:
- 20:b142ae11a12a
Prototype 2 - August 28, 2020.; Controller working well with updated parameters; State machine still needs updates
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
BoulusAJ | 16:ff375f62a95f | 1 | #ifndef PID_Cntrl_H_ |
BoulusAJ | 16:ff375f62a95f | 2 | #define PID_Cntrl_H_ |
BoulusAJ | 0:8e87cdf07037 | 3 | |
BoulusAJ | 0:8e87cdf07037 | 4 | // PID Controller Class |
BoulusAJ | 0:8e87cdf07037 | 5 | class PID_Cntrl |
BoulusAJ | 0:8e87cdf07037 | 6 | { |
BoulusAJ | 0:8e87cdf07037 | 7 | public: |
BoulusAJ | 0:8e87cdf07037 | 8 | |
BoulusAJ | 0:8e87cdf07037 | 9 | PID_Cntrl(float Kp, float Ki, float Kd, float Tf, float Ts, float uMin, float uMax); |
BoulusAJ | 0:8e87cdf07037 | 10 | |
BoulusAJ | 0:8e87cdf07037 | 11 | float operator()(float error) { |
BoulusAJ | 0:8e87cdf07037 | 12 | return update((double)error); |
BoulusAJ | 0:8e87cdf07037 | 13 | } |
BoulusAJ | 0:8e87cdf07037 | 14 | |
BoulusAJ | 0:8e87cdf07037 | 15 | virtual ~PID_Cntrl(); |
BoulusAJ | 0:8e87cdf07037 | 16 | |
BoulusAJ | 20:b142ae11a12a | 17 | float reset(float initValue); |
BoulusAJ | 0:8e87cdf07037 | 18 | float update(double error); |
BoulusAJ | 0:8e87cdf07037 | 19 | |
BoulusAJ | 0:8e87cdf07037 | 20 | private: |
BoulusAJ | 0:8e87cdf07037 | 21 | |
BoulusAJ | 0:8e87cdf07037 | 22 | // controller parameters (member variables) |
BoulusAJ | 0:8e87cdf07037 | 23 | float Kp_, Ki_, Kd_, Tf_, Ts_, uMin_, uMax_; |
BoulusAJ | 0:8e87cdf07037 | 24 | |
BoulusAJ | 0:8e87cdf07037 | 25 | // storage for signals (member variables) |
BoulusAJ | 0:8e87cdf07037 | 26 | float P_new, I_new, D_new, PID_output, P_old, I_old, D_old, delta_error, error, e_old; |
BoulusAJ | 0:8e87cdf07037 | 27 | }; |
BoulusAJ | 0:8e87cdf07037 | 28 | #endif |