kani

Dependencies:   2017NHKpin_config FEP omni_wheel PID R1307 ikarashiMDC

classDiagram

    \ ̄\                   / ̄/ 
/l     \  \             /  / lヽ  
| ヽ  ヽ   |           |  /  / | 
\ ` ‐ヽ  ヽ  ●        ●         /  / ‐  / 
  \ __ l  |  ||___|| /  l __ / 
     \  \ /      \/ 
      /\|   人__人  |/\    <ズワイガニ  
    //\|             |/\\     
    //\|   ケガニ            |/\\     
    /     . \_____/         \ 

                               ┏┓        ┏━┓┏┓              
     ┏┓         ┏┓┏┓   ┏┓    ┏┓┗┛     ┏┓ ┗┓┃┗┛              
┏┛┗━┓  ┃┃┃┃    ┃┃┏━┛┗┓┏┓┏┛┗━┓┃┃┏┓┏┓┏━━━┓ 
┗┓┏━┛  ┃┃┗┛    ┃┃┗━┓┏┛┗┛┗┓┏┓┃┗┛┗┛┃┃┗━━━┛    
┏┛┃┏━┓┃┗━━┓┃┃┏━┛┗┓      ┏┛┃┃┃        ┃┃              
┃┏┛┗━┛┗━━┓┃┃┃┃┏┓┏┛      ┗━┛┃┃        ┃┃┏┓          
┃┃┏━━┓┏━━┛┃┃┃┃┗┛┃         ┏┛┃        ┃┃┃┗━━┓    
┗┛┗━━┛┗━━━┛┗┛┗━━┛         ┗━┛        ┗┛┗━━━┛  
Committer:
uchitake
Date:
Tue Sep 26 16:55:48 2017 +0900
Branch:
develop1
Revision:
17:79fa65706f92
Parent:
7:c6acf63088b0
Child:
18:78df87e20590
tiny fix

Who changed what in which revision?

UserRevisionLine numberNew 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 6:fe9767a50891 38 const int SENSED_THRESHOLD = 1800;
uchitake 1:845af5425eec 39
uchitake 1:845af5425eec 40 /**
uchitake 1:845af5425eec 41 * @brief コンパスセンサを使ったPIDコントローラ
uchitake 1:845af5425eec 42 */
uchitake 1:845af5425eec 43 class PIDC : public PID, HMC6352, Ticker
uchitake 1:845af5425eec 44 {
uchitake 1:845af5425eec 45 public :
uchitake 1:845af5425eec 46 /**
uchitake 1:845af5425eec 47 * @brief defaultコンストラクタ,タイマ割り込みでの計算開始
uchitake 1:845af5425eec 48 */
uchitake 1:845af5425eec 49 PIDC();
uchitake 1:845af5425eec 50
uchitake 1:845af5425eec 51 /**
uchitake 1:845af5425eec 52 * @brief コンストラクタ
uchitake 1:845af5425eec 53 * @param sda sda HMC6352
uchitake 1:845af5425eec 54 * @param scl scl HMC6352
uchitake 1:845af5425eec 55 * @param kc KC
uchitake 1:845af5425eec 56 * @param ti TI
uchitake 1:845af5425eec 57 * @param td TD
uchitake 1:845af5425eec 58 * @param interval interval
uchitake 1:845af5425eec 59 */
uchitake 1:845af5425eec 60 PIDC(PinName sda, PinName scl, float kc, float ti, float td, float interval);
uchitake 1:845af5425eec 61
uchitake 7:c6acf63088b0 62 /**
uchitake 7:c6acf63088b0 63 * @brief センサの値とPIDの値をアップデート
uchitake 7:c6acf63088b0 64 */
uchitake 7:c6acf63088b0 65 void confirm();
uchitake 4:1073deb368df 66
uchitake 7:c6acf63088b0 67 /**
uchitake 7:c6acf63088b0 68 * @brief 回転用座標系リセット
uchitake 7:c6acf63088b0 69 */
uchitake 6:fe9767a50891 70 void resetAxisOffset();
uchitake 7:c6acf63088b0 71
uchitake 7:c6acf63088b0 72 /**
uchitake 7:c6acf63088b0 73 * 平行移動用座標系リセット
uchitake 7:c6acf63088b0 74 */
uchitake 6:fe9767a50891 75 void resetPlaneOffset();
uchitake 7:c6acf63088b0 76
uchitake 7:c6acf63088b0 77 /**
uchitake 7:c6acf63088b0 78 * @brief PIDの計算結果を取得
uchitake 7:c6acf63088b0 79 * @return PIDの計算結果
uchitake 7:c6acf63088b0 80 */
uchitake 6:fe9767a50891 81 float getCalculationResult() const;
uchitake 7:c6acf63088b0 82
uchitake 7:c6acf63088b0 83 /**
uchitake 7:c6acf63088b0 84 * 現在の角度を取得
uchitake 7:c6acf63088b0 85 * @return 現在の角度(degree)
uchitake 7:c6acf63088b0 86 */
uchitake 6:fe9767a50891 87 int getCurrentDegree() const;
uchitake 7:c6acf63088b0 88
uchitake 17:79fa65706f92 89 int getRawDegree();
uchitake 17:79fa65706f92 90
uchitake 7:c6acf63088b0 91 /**
uchitake 7:c6acf63088b0 92 * @brief キャリブレーションする
uchitake 7:c6acf63088b0 93 * @param mode ENTER OR EXIT
uchitake 7:c6acf63088b0 94 */
uchitake 1:845af5425eec 95 void calibration(int mode);
uchitake 1:845af5425eec 96 private :
uchitake 1:845af5425eec 97
uchitake 1:845af5425eec 98 void updateOutput();
uchitake 1:845af5425eec 99
uchitake 6:fe9767a50891 100 int axisOffSetDegree;
uchitake 6:fe9767a50891 101 int planeOffSetDegree;
uchitake 1:845af5425eec 102 int turnOverNumber;
uchitake 1:845af5425eec 103 int beforeDegree;
uchitake 1:845af5425eec 104
uchitake 1:845af5425eec 105 protected :
uchitake 17:79fa65706f92 106
uchitake 5:16ea97725085 107 int rawDegree;
uchitake 6:fe9767a50891 108 float calculationResult;
uchitake 6:fe9767a50891 109 int axisCurrentDegree;
uchitake 6:fe9767a50891 110 int planeCurrentDegree;
uchitake 1:845af5425eec 111 };
uchitake 1:845af5425eec 112
uchitake 1:845af5425eec 113 #endif//PID_CONTROLLER_H