![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
PID
Dependencies: BLE_API mbed nRF51822
PID.h@1:d3e12393b71d, 2017-01-12 (annotated)
- Committer:
- stoicancristi
- Date:
- Thu Jan 12 16:04:37 2017 +0000
- Revision:
- 1:d3e12393b71d
- Parent:
- 0:1f4d5c5491b8
v2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
stoicancristi | 0:1f4d5c5491b8 | 1 | #ifndef _PID_H_ |
stoicancristi | 0:1f4d5c5491b8 | 2 | #define _PID_H_ |
stoicancristi | 0:1f4d5c5491b8 | 3 | |
stoicancristi | 0:1f4d5c5491b8 | 4 | #include "mbed.h" |
stoicancristi | 0:1f4d5c5491b8 | 5 | #include "math.h" |
stoicancristi | 0:1f4d5c5491b8 | 6 | |
stoicancristi | 0:1f4d5c5491b8 | 7 | #define Te 100 |
stoicancristi | 1:d3e12393b71d | 8 | #define SUPERIOR_MARGIN 1 |
stoicancristi | 0:1f4d5c5491b8 | 9 | #define INFERIOR_MARGIN 0 |
stoicancristi | 0:1f4d5c5491b8 | 10 | |
stoicancristi | 0:1f4d5c5491b8 | 11 | typedef struct |
stoicancristi | 0:1f4d5c5491b8 | 12 | { |
stoicancristi | 0:1f4d5c5491b8 | 13 | float last_error; |
stoicancristi | 0:1f4d5c5491b8 | 14 | float integral; |
stoicancristi | 0:1f4d5c5491b8 | 15 | }PID_static; |
stoicancristi | 0:1f4d5c5491b8 | 16 | |
stoicancristi | 0:1f4d5c5491b8 | 17 | class PIDClass |
stoicancristi | 0:1f4d5c5491b8 | 18 | { |
stoicancristi | 0:1f4d5c5491b8 | 19 | public: |
stoicancristi | 1:d3e12393b71d | 20 | PIDClass(float _Kr, float _Ki, float _Kd, float _SetPoint); |
stoicancristi | 0:1f4d5c5491b8 | 21 | |
stoicancristi | 0:1f4d5c5491b8 | 22 | float ComputeCommand(float inputADC); |
stoicancristi | 1:d3e12393b71d | 23 | float getKr(){return Kr;} |
stoicancristi | 1:d3e12393b71d | 24 | float getKi(){return Ki;} |
stoicancristi | 1:d3e12393b71d | 25 | float getKd(){return Kd;} |
stoicancristi | 1:d3e12393b71d | 26 | void setKr(float new_Kr){Kr = new_Kr;} |
stoicancristi | 1:d3e12393b71d | 27 | void setKi(float new_Ki){Ki = new_Ki;} |
stoicancristi | 1:d3e12393b71d | 28 | void setKd(float new_Kd){Kd = new_Kd;} |
stoicancristi | 0:1f4d5c5491b8 | 29 | |
stoicancristi | 0:1f4d5c5491b8 | 30 | private: |
stoicancristi | 1:d3e12393b71d | 31 | float Kr; |
stoicancristi | 1:d3e12393b71d | 32 | float Ki; |
stoicancristi | 1:d3e12393b71d | 33 | float Kd; |
stoicancristi | 1:d3e12393b71d | 34 | float SetPoint; |
stoicancristi | 0:1f4d5c5491b8 | 35 | }; |
stoicancristi | 0:1f4d5c5491b8 | 36 | |
stoicancristi | 0:1f4d5c5491b8 | 37 | #endif |