
kani
Dependencies: 2017NHKpin_config FEP omni_wheel PID R1307 ikarashiMDC
\ ̄\ / ̄/ /l \ \ / / lヽ | ヽ ヽ | | / / | \ ` ‐ヽ ヽ ● ● / / ‐ / \ __ l | ||___|| / l __ / \ \ / \/ /\| 人__人 |/\ <ズワイガニ //\| |/\\ //\| ケガニ |/\\ / . \_____/ \ ┏┓ ┏━┓┏┓ ┏┓ ┏┓┏┓ ┏┓ ┏┓┗┛ ┏┓ ┗┓┃┗┛ ┏┛┗━┓ ┃┃┃┃ ┃┃┏━┛┗┓┏┓┏┛┗━┓┃┃┏┓┏┓┏━━━┓ ┗┓┏━┛ ┃┃┗┛ ┃┃┗━┓┏┛┗┛┗┓┏┓┃┗┛┗┛┃┃┗━━━┛ ┏┛┃┏━┓┃┗━━┓┃┃┏━┛┗┓ ┏┛┃┃┃ ┃┃ ┃┏┛┗━┛┗━━┓┃┃┃┃┏┓┏┛ ┗━┛┃┃ ┃┃┏┓ ┃┃┏━━┓┏━━┛┃┃┃┃┗┛┃ ┏┛┃ ┃┃┃┗━━┓ ┗┛┗━━┛┗━━━┛┗┛┗━━┛ ┗━┛ ┗┛┗━━━┛
bot/PIDcontroller/PID_controller.h
- Committer:
- uchitake
- Date:
- 2017-09-26
- Branch:
- develop1
- Revision:
- 17:79fa65706f92
- Parent:
- 7:c6acf63088b0
- Child:
- 18:78df87e20590
File content as of revision 17:79fa65706f92:
/** * @file PID_controller.h * @brief コンパスセンサを使ったPIDコントローラ * * Example : * @code * #include "mbed.h" * #include "PID_controller.h" * * PIDC pidc; * * int main() * { * while(1) { * pidc.confirm(); * pc.printf("Hi, %f\r\n", pid.getCo()); * } * } * @endcode */ #ifndef PID_CONTROLLER_H #define PID_CONTROLLER_H #include "mbed.h" #include "pin_config.h" #include "PID.h" #include "HMC6352.h" // const double M_PI = 3.141592653589793; const double KC = 5.2; const double TI = 0.0; const double TD = 0.00; const float INTERVAL = 0.01; const float INPUT_LIMIT = 180.0; const float OUTPUT_LIMIT = 0.4; const float BIAS = 0.0; const int SENSED_THRESHOLD = 1800; /** * @brief コンパスセンサを使ったPIDコントローラ */ class PIDC : public PID, HMC6352, Ticker { public : /** * @brief defaultコンストラクタ,タイマ割り込みでの計算開始 */ PIDC(); /** * @brief コンストラクタ * @param sda sda HMC6352 * @param scl scl HMC6352 * @param kc KC * @param ti TI * @param td TD * @param interval interval */ PIDC(PinName sda, PinName scl, float kc, float ti, float td, float interval); /** * @brief センサの値とPIDの値をアップデート */ void confirm(); /** * @brief 回転用座標系リセット */ void resetAxisOffset(); /** * 平行移動用座標系リセット */ void resetPlaneOffset(); /** * @brief PIDの計算結果を取得 * @return PIDの計算結果 */ float getCalculationResult() const; /** * 現在の角度を取得 * @return 現在の角度(degree) */ int getCurrentDegree() const; int getRawDegree(); /** * @brief キャリブレーションする * @param mode ENTER OR EXIT */ void calibration(int mode); private : void updateOutput(); int axisOffSetDegree; int planeOffSetDegree; int turnOverNumber; int beforeDegree; protected : int rawDegree; float calculationResult; int axisCurrentDegree; int planeCurrentDegree; }; #endif//PID_CONTROLLER_H