Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
rotaryinc.hpp
00001 #ifndef ROTARY_INC_ 00002 #define ROTARY_INC_ 00003 #include <mbed.h> 00004 #define M_PI 3.1415926535 00005 00006 #if 0 00007 ~example~ 00008 rotaryinc name(ピン名1,ピン名2,オムニの直径,パルスの分解能,一回のプログラムの時間(Δt))でこのクラスを使うことができる 00009 name.getpulse()でパルスの値を取得できる 00010 name.getspeed()でモータの速さを取得できる 00011 name.loop(一回のプログラムの時間(Δt))でΔt秒ごとのプログラムにできる 00012 #endif 00013 00014 class rotaryinc 00015 { 00016 public: 00017 rotaryinc(PinName pinA,PinName pinB,double,double,double); 00018 ~rotaryinc(); 00019 Timer timer; 00020 double getpulse(); 00021 double getspeed(); 00022 double gettheta(); 00023 double getomega(); 00024 double getrevolution(); 00025 void loop(); 00026 private: 00027 InterruptIn *pin_a_,*pin_b_; 00028 double time; 00029 double pulse[2]; 00030 double speed; 00031 void init(PinName,PinName); 00032 void riseA(void); 00033 void riseB(void); 00034 void fallA(void); 00035 void fallB(void); 00036 double theta[2]; 00037 double omega; 00038 double Resolution; 00039 double Diameter; 00040 double dt_; 00041 double revolution_num; 00042 }; 00043 00044 #endif
Generated on Sat Oct 8 2022 11:15:36 by
1.7.2