9/10
Diff: AMT21.h
- Revision:
- 0:f3d3f744dbd9
- Child:
- 1:3838b5e3966c
diff -r 000000000000 -r f3d3f744dbd9 AMT21.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AMT21.h Thu Dec 10 06:41:13 2020 +0000 @@ -0,0 +1,57 @@ +#ifndef _INCLUDED_AMT212_H_ +#define _INCLUDED_AMT212_H_ +#include "mbed.h" + +#define SEND 1 +#define RECEIVE 0 +#define RECEIVE_COUNT 0 +#define RECEIVE_TURN 2 +#define GET_COUNT 84 +#define GET_TURN 85 +#define RESOLUTION_AMT21 16384 +#define DETECT_FLOW 5 +#define RESET 86 +#define COUNT_OFFSET 0 +#define GEER_STEER 280.0/50 +#ifndef M_PI +#define M_PI 3.14159265359f +#endif + + + +class Amt21 +{ +private: + int low_count,high_count; + int low_turn,high_turn; + int receive_mode; + int instruction; + void sendMessage(); + void receiveMessage(); + int receive_old; + int flow_count; + int th_min; + int th_max; + int count_; + int pre_count; + double omega_; + double pre_time; + +protected: + Serial serial_;//RS485通信 + DigitalOut rs485_mode;//送受信の切り替え +public: + Amt21(PinName tx,PinName rx,PinName mode);//コンストラクタ + + Timer timer_; + + int getAbCount();//カウント数取得関数 + int getTurn();//回転回数取得関数 + int getCount();//インクリメント型のカウントと同じように使えて、-のカウントや16383以上のカウントを返す。 + double getAngle(); + void calOmega(); + double getOmega(); + void reset();//回転数のリセット関数。※0~360を示すカウント数はリセットされない。 + +}; +#endif \ No newline at end of file