NHK2017Ateamかにろぼ

Dependencies:   2017NHKpin_config mbed FEP HMC6352 MotorDriverController PID QEI omni

classDiagram

    \ ̄\                   / ̄/ 
/l     \  \             /  / lヽ  
| ヽ  ヽ   |           |  /  / | 
\ ` ‐ヽ  ヽ  ●        ●         /  / ‐  / 
  \ __ l  |  ||___|| /  l __ / 
     \  \ /      \/ 
      /\|   人__人  |/\       
    //\|             |/\\     
    //\|             |/\\     
    /     . \_____/         \ 

                               ┏┓        ┏━┓┏┓              
     ┏┓         ┏┓┏┓   ┏┓    ┏┓┗┛     ┏┓ ┗┓┃┗┛              
┏┛┗━┓  ┃┃┃┃    ┃┃┏━┛┗┓┏┓┏┛┗━┓┃┃┏┓┏┓┏━━━┓ 
┗┓┏━┛  ┃┃┗┛    ┃┃┗━┓┏┛┗┛┗┓┏┓┃┗┛┗┛┃┃┗━━━┛    
┏┛┃┏━┓┃┗━━┓┃┃┏━┛┗┓      ┏┛┃┃┃        ┃┃              
┃┏┛┗━┛┗━━┓┃┃┃┃┏┓┏┛      ┗━┛┃┃        ┃┃┏┓          
┃┃┏━━┓┏━━┛┃┃┃┃┗┛┃         ┏┛┃        ┃┃┃┗━━┓    
┗┛┗━━┛┗━━━┛┗┛┗━━┛         ┗━┛        ┗┛┗━━━┛  
Committer:
uchitake
Date:
Tue Sep 05 12:02:47 2017 +0900
Revision:
23:98746361f827
Parent:
22:bb6afe7332c3
remove WheelUnit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
UCHITAKE 6:590c9622ecf1 1 /**
UCHITAKE 6:590c9622ecf1 2 * @file PID_controller.h
UCHITAKE 6:590c9622ecf1 3 * @brief コンパスセンサを使ったPIDコントローラ
uchitake 21:b2c1d73b0ee9 4 *
uchitake 21:b2c1d73b0ee9 5 * Example :
uchitake 21:b2c1d73b0ee9 6 * @code
uchitake 21:b2c1d73b0ee9 7 * #include "mbed.h"
uchitake 21:b2c1d73b0ee9 8 * #include "PID_controller.h"
uchitake 21:b2c1d73b0ee9 9 *
uchitake 21:b2c1d73b0ee9 10 * PIDC pidc;
uchitake 21:b2c1d73b0ee9 11 *
uchitake 21:b2c1d73b0ee9 12 * int main()
uchitake 21:b2c1d73b0ee9 13 * {
uchitake 21:b2c1d73b0ee9 14 * while(1) {
uchitake 21:b2c1d73b0ee9 15 * pidc.confirm();
uchitake 21:b2c1d73b0ee9 16 * pc.printf("Hi, %f\r\n", pid.getCo());
uchitake 21:b2c1d73b0ee9 17 * }
uchitake 21:b2c1d73b0ee9 18 * }
uchitake 21:b2c1d73b0ee9 19 * @endcode
UCHITAKE 6:590c9622ecf1 20 */
UCHITAKE 6:590c9622ecf1 21 #ifndef PID_CONTROLLER_H
UCHITAKE 6:590c9622ecf1 22 #define PID_CONTROLLER_H
UCHITAKE 6:590c9622ecf1 23
UCHITAKE 6:590c9622ecf1 24 #include "mbed.h"
UCHITAKE 6:590c9622ecf1 25 #include "pin_config.h"
UCHITAKE 6:590c9622ecf1 26
UCHITAKE 6:590c9622ecf1 27 #include "PID.h"
UCHITAKE 6:590c9622ecf1 28 #include "HMC6352.h"
UCHITAKE 6:590c9622ecf1 29
uchitake 22:bb6afe7332c3 30 // const double M_PI = 3.141592653589793;
uchitake 22:bb6afe7332c3 31 const double KC = 5.0;
uchitake 22:bb6afe7332c3 32 const double TI = 0.0;
uchitake 22:bb6afe7332c3 33 const double TD = 0.0;
uchitake 22:bb6afe7332c3 34 const float INTERVAL = 0.05;
uchitake 22:bb6afe7332c3 35 const float INPUT_LIMIT = 180.0;
uchitake 22:bb6afe7332c3 36 const float OUTPUT_LIMIT = 0.4;
uchitake 22:bb6afe7332c3 37 const float BIAS = 0.0;
uchitake 18:41f7dd1a5ed1 38
UCHITAKE 6:590c9622ecf1 39 /**
UCHITAKE 6:590c9622ecf1 40 * @brief コンパスセンサを使ったPIDコントローラ
UCHITAKE 6:590c9622ecf1 41 */
UCHITAKE 6:590c9622ecf1 42 class PIDC : public PID, HMC6352, Ticker
UCHITAKE 6:590c9622ecf1 43 {
UCHITAKE 6:590c9622ecf1 44 public :
UCHITAKE 6:590c9622ecf1 45 /**
uchitake 18:41f7dd1a5ed1 46 * @brief defaultコンストラクタ,タイマ割り込みでの計算開始
UCHITAKE 6:590c9622ecf1 47 */
UCHITAKE 6:590c9622ecf1 48 PIDC();
uchitake 18:41f7dd1a5ed1 49
uchitake 18:41f7dd1a5ed1 50 /**
uchitake 18:41f7dd1a5ed1 51 * @brief コンストラクタ
uchitake 18:41f7dd1a5ed1 52 * @param sda sda HMC6352
uchitake 18:41f7dd1a5ed1 53 * @param scl scl HMC6352
uchitake 18:41f7dd1a5ed1 54 * @param kc KC
uchitake 18:41f7dd1a5ed1 55 * @param ti TI
uchitake 18:41f7dd1a5ed1 56 * @param td TD
uchitake 18:41f7dd1a5ed1 57 * @param interval interval
uchitake 18:41f7dd1a5ed1 58 */
uchitake 18:41f7dd1a5ed1 59 PIDC(PinName sda, PinName scl, float kc, float ti, float td, float interval);
uchitake 18:41f7dd1a5ed1 60
UCHITAKE 6:590c9622ecf1 61 void confirm();
uchitake 22:bb6afe7332c3 62 float getCo() const;
UCHITAKE 19:3a62cbc6fee9 63 void calibration(int mode);
UCHITAKE 6:590c9622ecf1 64 private :
uchitake 18:41f7dd1a5ed1 65
UCHITAKE 6:590c9622ecf1 66 void updateOutput();
uchitake 18:41f7dd1a5ed1 67
UCHITAKE 6:590c9622ecf1 68 int rawDegree;
UCHITAKE 6:590c9622ecf1 69 int offSetDegree;
UCHITAKE 6:590c9622ecf1 70 int turnOverNumber;
UCHITAKE 6:590c9622ecf1 71 int beforeDegree;
UCHITAKE 6:590c9622ecf1 72
UCHITAKE 6:590c9622ecf1 73 protected :
UCHITAKE 6:590c9622ecf1 74 float co;
UCHITAKE 6:590c9622ecf1 75 float processValue;
UCHITAKE 6:590c9622ecf1 76 int initDegree;
UCHITAKE 6:590c9622ecf1 77 };
UCHITAKE 6:590c9622ecf1 78
uchitake 18:41f7dd1a5ed1 79 #endif//PID_CONTROLLER_H