kani
Dependencies: 2017NHKpin_config FEP omni_wheel PID R1307 ikarashiMDC
\ ̄\ / ̄/ /l \ \ / / lヽ | ヽ ヽ | | / / | \ ` ‐ヽ ヽ ● ● / / ‐ / \ __ l | ||___|| / l __ / \ \ / \/ /\| 人__人 |/\ <ズワイガニ //\| |/\\ //\| ケガニ |/\\ / . \_____/ \ ┏┓ ┏━┓┏┓ ┏┓ ┏┓┏┓ ┏┓ ┏┓┗┛ ┏┓ ┗┓┃┗┛ ┏┛┗━┓ ┃┃┃┃ ┃┃┏━┛┗┓┏┓┏┛┗━┓┃┃┏┓┏┓┏━━━┓ ┗┓┏━┛ ┃┃┗┛ ┃┃┗━┓┏┛┗┛┗┓┏┓┃┗┛┗┛┃┃┗━━━┛ ┏┛┃┏━┓┃┗━━┓┃┃┏━┛┗┓ ┏┛┃┃┃ ┃┃ ┃┏┛┗━┛┗━━┓┃┃┃┃┏┓┏┛ ┗━┛┃┃ ┃┃┏┓ ┃┃┏━━┓┏━━┛┃┃┃┃┗┛┃ ┏┛┃ ┃┃┃┗━━┓ ┗┛┗━━┛┗━━━┛┗┛┗━━┛ ┗━┛ ┗┛┗━━━┛
bot/PIDcontroller/PID_controller.h@4:1073deb368df, 2017-09-06 (annotated)
- Committer:
- uchitake
- Date:
- Wed Sep 06 00:01:47 2017 +0900
- Revision:
- 4:1073deb368df
- Parent:
- 3:369d9ee17e84
- Child:
- 5:16ea97725085
fix Drive Func
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 |
1:845af5425eec | 31 | const double KC = 5.0; |
uchitake |
1:845af5425eec | 32 | const double TI = 0.0; |
uchitake |
1:845af5425eec | 33 | const double TD = 0.0; |
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 |
1:845af5425eec | 63 | float getCo() const; |
uchitake |
3:369d9ee17e84 | 64 | float getDegree() const; |
uchitake |
1:845af5425eec | 65 | void calibration(int mode); |
uchitake |
1:845af5425eec | 66 | private : |
uchitake |
1:845af5425eec | 67 | |
uchitake |
1:845af5425eec | 68 | void updateOutput(); |
uchitake |
1:845af5425eec | 69 | |
uchitake |
1:845af5425eec | 70 | int rawDegree; |
uchitake |
1:845af5425eec | 71 | int offSetDegree; |
uchitake |
1:845af5425eec | 72 | int turnOverNumber; |
uchitake |
1:845af5425eec | 73 | int beforeDegree; |
uchitake |
1:845af5425eec | 74 | |
uchitake |
1:845af5425eec | 75 | protected : |
uchitake |
1:845af5425eec | 76 | float co; |
uchitake |
1:845af5425eec | 77 | float processValue; |
uchitake |
1:845af5425eec | 78 | int initDegree; |
uchitake |
1:845af5425eec | 79 | }; |
uchitake |
1:845af5425eec | 80 | |
uchitake |
1:845af5425eec | 81 | #endif//PID_CONTROLLER_H |