kani
Dependencies: 2017NHKpin_config FEP omni_wheel PID R1307 ikarashiMDC
\ ̄\ / ̄/ /l \ \ / / lヽ | ヽ ヽ | | / / | \ ` ‐ヽ ヽ ● ● / / ‐ / \ __ l | ||___|| / l __ / \ \ / \/ /\| 人__人 |/\ <ズワイガニ //\| |/\\ //\| ケガニ |/\\ / . \_____/ \ ┏┓ ┏━┓┏┓ ┏┓ ┏┓┏┓ ┏┓ ┏┓┗┛ ┏┓ ┗┓┃┗┛ ┏┛┗━┓ ┃┃┃┃ ┃┃┏━┛┗┓┏┓┏┛┗━┓┃┃┏┓┏┓┏━━━┓ ┗┓┏━┛ ┃┃┗┛ ┃┃┗━┓┏┛┗┛┗┓┏┓┃┗┛┗┛┃┃┗━━━┛ ┏┛┃┏━┓┃┗━━┓┃┃┏━┛┗┓ ┏┛┃┃┃ ┃┃ ┃┏┛┗━┛┗━━┓┃┃┃┃┏┓┏┛ ┗━┛┃┃ ┃┃┏┓ ┃┃┏━━┓┏━━┛┃┃┃┃┗┛┃ ┏┛┃ ┃┃┃┗━━┓ ┗┛┗━━┛┗━━━┛┗┛┗━━┛ ┗━┛ ┗┛┗━━━┛
bot/PIDcontroller/PID_controller.h@5:16ea97725085, 2017-09-06 (annotated)
- Committer:
- uchitake
- Date:
- Wed Sep 06 17:47:20 2017 +0900
- Revision:
- 5:16ea97725085
- Parent:
- 4:1073deb368df
- Child:
- 6:fe9767a50891
working MEGA STUPID CODE
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
uchitake |
1:845af5425eec | 1 | /** |
uchitake |
1:845af5425eec | 2 | * @file PID_controller.h |
uchitake |
1:845af5425eec | 3 | * @brief コンパスセンサを使ったPIDコントローラ |
uchitake |
1:845af5425eec | 4 | * |
uchitake |
1:845af5425eec | 5 | * Example : |
uchitake |
1:845af5425eec | 6 | * @code |
uchitake |
1:845af5425eec | 7 | * #include "mbed.h" |
uchitake |
1:845af5425eec | 8 | * #include "PID_controller.h" |
uchitake |
1:845af5425eec | 9 | * |
uchitake |
1:845af5425eec | 10 | * PIDC pidc; |
uchitake |
1:845af5425eec | 11 | * |
uchitake |
1:845af5425eec | 12 | * int main() |
uchitake |
1:845af5425eec | 13 | * { |
uchitake |
1:845af5425eec | 14 | * while(1) { |
uchitake |
1:845af5425eec | 15 | * pidc.confirm(); |
uchitake |
1:845af5425eec | 16 | * pc.printf("Hi, %f\r\n", pid.getCo()); |
uchitake |
1:845af5425eec | 17 | * } |
uchitake |
1:845af5425eec | 18 | * } |
uchitake |
1:845af5425eec | 19 | * @endcode |
uchitake |
1:845af5425eec | 20 | */ |
uchitake |
1:845af5425eec | 21 | #ifndef PID_CONTROLLER_H |
uchitake |
1:845af5425eec | 22 | #define PID_CONTROLLER_H |
uchitake |
1:845af5425eec | 23 | |
uchitake |
1:845af5425eec | 24 | #include "mbed.h" |
uchitake |
1:845af5425eec | 25 | #include "pin_config.h" |
uchitake |
1:845af5425eec | 26 | |
uchitake |
1:845af5425eec | 27 | #include "PID.h" |
uchitake |
1:845af5425eec | 28 | #include "HMC6352.h" |
uchitake |
1:845af5425eec | 29 | |
uchitake |
1:845af5425eec | 30 | // const double M_PI = 3.141592653589793; |
uchitake |
5:16ea97725085 | 31 | const double KC = 5.2; |
uchitake |
1:845af5425eec | 32 | const double TI = 0.0; |
uchitake |
5:16ea97725085 | 33 | const double TD = 0.00; |
uchitake |
3:369d9ee17e84 | 34 | const float INTERVAL = 0.01; |
uchitake |
1:845af5425eec | 35 | const float INPUT_LIMIT = 180.0; |
uchitake |
1:845af5425eec | 36 | const float OUTPUT_LIMIT = 0.4; |
uchitake |
1:845af5425eec | 37 | const float BIAS = 0.0; |
uchitake |
1:845af5425eec | 38 | |
uchitake |
1:845af5425eec | 39 | /** |
uchitake |
1:845af5425eec | 40 | * @brief コンパスセンサを使ったPIDコントローラ |
uchitake |
1:845af5425eec | 41 | */ |
uchitake |
1:845af5425eec | 42 | class PIDC : public PID, HMC6352, Ticker |
uchitake |
1:845af5425eec | 43 | { |
uchitake |
1:845af5425eec | 44 | public : |
uchitake |
1:845af5425eec | 45 | /** |
uchitake |
1:845af5425eec | 46 | * @brief defaultコンストラクタ,タイマ割り込みでの計算開始 |
uchitake |
1:845af5425eec | 47 | */ |
uchitake |
1:845af5425eec | 48 | PIDC(); |
uchitake |
1:845af5425eec | 49 | |
uchitake |
1:845af5425eec | 50 | /** |
uchitake |
1:845af5425eec | 51 | * @brief コンストラクタ |
uchitake |
1:845af5425eec | 52 | * @param sda sda HMC6352 |
uchitake |
1:845af5425eec | 53 | * @param scl scl HMC6352 |
uchitake |
1:845af5425eec | 54 | * @param kc KC |
uchitake |
1:845af5425eec | 55 | * @param ti TI |
uchitake |
1:845af5425eec | 56 | * @param td TD |
uchitake |
1:845af5425eec | 57 | * @param interval interval |
uchitake |
1:845af5425eec | 58 | */ |
uchitake |
1:845af5425eec | 59 | PIDC(PinName sda, PinName scl, float kc, float ti, float td, float interval); |
uchitake |
1:845af5425eec | 60 | |
uchitake |
4:1073deb368df | 61 | |
uchitake |
1:845af5425eec | 62 | void confirm(); |
uchitake |
5:16ea97725085 | 63 | void resetOffset(); |
uchitake |
5:16ea97725085 | 64 | void resetOffset2(); |
uchitake |
1:845af5425eec | 65 | float getCo() const; |
uchitake |
5:16ea97725085 | 66 | int getDegree() const; |
uchitake |
1:845af5425eec | 67 | void calibration(int mode); |
uchitake |
1:845af5425eec | 68 | private : |
uchitake |
1:845af5425eec | 69 | |
uchitake |
1:845af5425eec | 70 | void updateOutput(); |
uchitake |
1:845af5425eec | 71 | |
uchitake |
1:845af5425eec | 72 | int offSetDegree; |
uchitake |
5:16ea97725085 | 73 | int offSetDegree2; |
uchitake |
1:845af5425eec | 74 | int turnOverNumber; |
uchitake |
1:845af5425eec | 75 | int beforeDegree; |
uchitake |
1:845af5425eec | 76 | |
uchitake |
1:845af5425eec | 77 | protected : |
uchitake |
5:16ea97725085 | 78 | int rawDegree; |
uchitake |
1:845af5425eec | 79 | float co; |
uchitake |
1:845af5425eec | 80 | float processValue; |
uchitake |
1:845af5425eec | 81 | int initDegree; |
uchitake |
5:16ea97725085 | 82 | int initDegree2; |
uchitake |
5:16ea97725085 | 83 | int baseAngle; |
uchitake |
1:845af5425eec | 84 | }; |
uchitake |
1:845af5425eec | 85 | |
uchitake |
1:845af5425eec | 86 | #endif//PID_CONTROLLER_H |