![](/media/cache/profiles/P1030212_resized.JPG.50x50_q85.jpg)
明石高専ロボ研 mbedライブラリ
Dependents: MDD_L432KC USB2RS485 pathtracking odometry ... more
rotary_inc.hpp@0:ca84ed7518f5, 2020-01-02 (annotated)
- Committer:
- TanakaRobo
- Date:
- Thu Jan 02 09:30:06 2020 +0000
- Revision:
- 0:ca84ed7518f5
- Child:
- 3:28c77df7c0b6
buffered serial before test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
TanakaRobo | 0:ca84ed7518f5 | 1 | #ifndef ROTARY_INC_H |
TanakaRobo | 0:ca84ed7518f5 | 2 | #define ROTARY_INC_H |
TanakaRobo | 0:ca84ed7518f5 | 3 | #include "mbed.h" |
TanakaRobo | 0:ca84ed7518f5 | 4 | #ifndef M_PI |
TanakaRobo | 0:ca84ed7518f5 | 5 | #define M_PI 3.14159265358979 |
TanakaRobo | 0:ca84ed7518f5 | 6 | #endif |
TanakaRobo | 0:ca84ed7518f5 | 7 | |
TanakaRobo | 0:ca84ed7518f5 | 8 | /*ロータリーエンコーダーを使う。 |
TanakaRobo | 0:ca84ed7518f5 | 9 | *速度計測は、タイヤの円周とロリコンの分解能を指定した場合に有効になる。 |
TanakaRobo | 0:ca84ed7518f5 | 10 | *RotaryInc(PinName pinA, PinName pinB,double circumference,int Resolution,int mode = 0);//速度計測有効 |
TanakaRobo | 0:ca84ed7518f5 | 11 | *RotaryInc(PinName pinA, PinName pinB,int mode = 0);//速度計測無効 |
TanakaRobo | 0:ca84ed7518f5 | 12 | */ |
TanakaRobo | 0:ca84ed7518f5 | 13 | //RotaryInc rotary(PA_1,PA_3,2 * 50.8 * M_PI,200); |
TanakaRobo | 0:ca84ed7518f5 | 14 | |
TanakaRobo | 0:ca84ed7518f5 | 15 | class RotaryInc{ |
TanakaRobo | 0:ca84ed7518f5 | 16 | public: |
TanakaRobo | 0:ca84ed7518f5 | 17 | RotaryInc(PinName userA, PinName userB,double circumference,int resolution,int mode = 0);//速度計測有効 |
TanakaRobo | 0:ca84ed7518f5 | 18 | RotaryInc(PinName userA, PinName userB,int mode = 0);//速度計測無効 |
TanakaRobo | 0:ca84ed7518f5 | 19 | ~RotaryInc(); |
TanakaRobo | 0:ca84ed7518f5 | 20 | long long get(); |
TanakaRobo | 0:ca84ed7518f5 | 21 | double getSpeed(); |
TanakaRobo | 0:ca84ed7518f5 | 22 | void reset(); |
TanakaRobo | 0:ca84ed7518f5 | 23 | int diff(); |
TanakaRobo | 0:ca84ed7518f5 | 24 | private: |
TanakaRobo | 0:ca84ed7518f5 | 25 | InterruptIn *A_,*B_; |
TanakaRobo | 0:ca84ed7518f5 | 26 | Timer timer_; |
TanakaRobo | 0:ca84ed7518f5 | 27 | long long pulse_; |
TanakaRobo | 0:ca84ed7518f5 | 28 | long long last_[20]; |
TanakaRobo | 0:ca84ed7518f5 | 29 | long long prev_; |
TanakaRobo | 0:ca84ed7518f5 | 30 | int count_; |
TanakaRobo | 0:ca84ed7518f5 | 31 | int mode_; |
TanakaRobo | 0:ca84ed7518f5 | 32 | int resolution_; |
TanakaRobo | 0:ca84ed7518f5 | 33 | double now_; |
TanakaRobo | 0:ca84ed7518f5 | 34 | double sum_; |
TanakaRobo | 0:ca84ed7518f5 | 35 | double pre_t_[20]; |
TanakaRobo | 0:ca84ed7518f5 | 36 | double speed_; |
TanakaRobo | 0:ca84ed7518f5 | 37 | double circumference_; |
TanakaRobo | 0:ca84ed7518f5 | 38 | bool measur_; |
TanakaRobo | 0:ca84ed7518f5 | 39 | bool start_frag_; |
TanakaRobo | 0:ca84ed7518f5 | 40 | bool flag_; |
TanakaRobo | 0:ca84ed7518f5 | 41 | void init(PinName,PinName); |
TanakaRobo | 0:ca84ed7518f5 | 42 | void riseA(void); |
TanakaRobo | 0:ca84ed7518f5 | 43 | void riseB(void); |
TanakaRobo | 0:ca84ed7518f5 | 44 | void fallA(void); |
TanakaRobo | 0:ca84ed7518f5 | 45 | void fallB(void); |
TanakaRobo | 0:ca84ed7518f5 | 46 | void calcu(void); |
TanakaRobo | 0:ca84ed7518f5 | 47 | void zero(void); |
TanakaRobo | 0:ca84ed7518f5 | 48 | }; |
TanakaRobo | 0:ca84ed7518f5 | 49 | |
TanakaRobo | 0:ca84ed7518f5 | 50 | #endif /* ROTARY_INC_H */ |