9/10

Committer:
oshin1030
Date:
Fri Sep 10 08:55:09 2021 +0000
Revision:
5:b78f031b66f7
Parent:
4:1ee3f6183111
9/10;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yuki0108 0:f3d3f744dbd9 1 #ifndef _INCLUDED_AMT212_H_
yuki0108 0:f3d3f744dbd9 2 #define _INCLUDED_AMT212_H_
yuki0108 0:f3d3f744dbd9 3 #include "mbed.h"
yuki0108 0:f3d3f744dbd9 4
yuki0108 0:f3d3f744dbd9 5 #define SEND 1
yuki0108 0:f3d3f744dbd9 6 #define RECEIVE 0
yuki0108 0:f3d3f744dbd9 7 #define RECEIVE_COUNT 0
yuki0108 0:f3d3f744dbd9 8 #define RECEIVE_TURN 2
yuki0108 0:f3d3f744dbd9 9 #define GET_COUNT 84
yuki0108 0:f3d3f744dbd9 10 #define GET_TURN 85
yuki0108 0:f3d3f744dbd9 11 #define RESOLUTION_AMT21 16384
yuki0108 0:f3d3f744dbd9 12 #define DETECT_FLOW 5
yuki0108 0:f3d3f744dbd9 13 #define RESET 86
yuki0108 3:d7d9b1d7d01e 14 #define COUNT_OFFSET 6890
yuki0108 2:e0164b9fe93a 15 #define GEER_STEER 1
yuki0108 0:f3d3f744dbd9 16 #ifndef M_PI
yuki0108 0:f3d3f744dbd9 17 #define M_PI 3.14159265359f
yuki0108 0:f3d3f744dbd9 18 #endif
yuki0108 0:f3d3f744dbd9 19
yuki0108 0:f3d3f744dbd9 20
yuki0108 0:f3d3f744dbd9 21
yuki0108 0:f3d3f744dbd9 22 class Amt21
yuki0108 0:f3d3f744dbd9 23 {
yuki0108 0:f3d3f744dbd9 24 private:
yuki0108 2:e0164b9fe93a 25 //////////////////////////////////////////////
yuki0108 0:f3d3f744dbd9 26 int low_count,high_count;
yuki0108 0:f3d3f744dbd9 27 int low_turn,high_turn;
yuki0108 0:f3d3f744dbd9 28 int receive_mode;
yuki0108 0:f3d3f744dbd9 29 int instruction;
yuki0108 0:f3d3f744dbd9 30 void sendMessage();
yuki0108 0:f3d3f744dbd9 31 void receiveMessage();
yuki0108 2:e0164b9fe93a 32 /////////////////////////////////////////////
yuki0108 2:e0164b9fe93a 33 int count_;
yuki0108 0:f3d3f744dbd9 34 int receive_old;
yuki0108 0:f3d3f744dbd9 35 int flow_count;
yuki0108 0:f3d3f744dbd9 36 int th_min;
yuki0108 0:f3d3f744dbd9 37 int th_max;
yuki0108 0:f3d3f744dbd9 38 int pre_count;
yuki0108 0:f3d3f744dbd9 39 double omega_;
yuki0108 0:f3d3f744dbd9 40 double pre_time;
yuki0108 0:f3d3f744dbd9 41
yuki0108 4:1ee3f6183111 42 int getAbCount();//カウント数取得関数
yuki0108 4:1ee3f6183111 43 int getTurn();//回転回数取得関数
yuki0108 4:1ee3f6183111 44
yuki0108 0:f3d3f744dbd9 45 protected:
yuki0108 0:f3d3f744dbd9 46 Serial serial_;//RS485通信
yuki0108 0:f3d3f744dbd9 47 DigitalOut rs485_mode;//送受信の切り替え
yuki0108 0:f3d3f744dbd9 48 public:
yuki0108 0:f3d3f744dbd9 49 Amt21(PinName tx,PinName rx,PinName mode);//コンストラクタ
yuki0108 0:f3d3f744dbd9 50
yuki0108 0:f3d3f744dbd9 51 Timer timer_;
yuki0108 0:f3d3f744dbd9 52
oshin1030 5:b78f031b66f7 53 void rewriteCount_1();//1周期に1度呼び出す。
oshin1030 5:b78f031b66f7 54 void rewriteCount_2();//1周期に1度呼び出す。
yuki0108 0:f3d3f744dbd9 55 int getCount();//インクリメント型のカウントと同じように使えて、-のカウントや16383以上のカウントを返す。
yuki0108 4:1ee3f6183111 56 double getDeg();//角度[°]を返す
yuki0108 4:1ee3f6183111 57 double getRad();//角度[rad]を返す
yuki0108 4:1ee3f6183111 58 void calOmega();//getOmegaする前に呼び出す
yuki0108 4:1ee3f6183111 59 double getOmega();//角速度[rad/s]を返す
yuki0108 0:f3d3f744dbd9 60 void reset();//回転数のリセット関数。※0~360を示すカウント数はリセットされない。
yuki0108 0:f3d3f744dbd9 61
yuki0108 0:f3d3f744dbd9 62 };
yuki0108 0:f3d3f744dbd9 63 #endif