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.
Dependencies: Encoder
Diff: SpeedController.h
- Revision:
- 4:ee0ac8415639
- Parent:
- 3:58a298386879
- Child:
- 5:fddbe92ca86f
--- a/SpeedController.h Fri Aug 09 06:28:06 2019 +0000
+++ b/SpeedController.h Fri Aug 09 07:15:35 2019 +0000
@@ -24,7 +24,7 @@
double initial_Db_;
double duty_limit_;
Ec *ec_;
-
+
public:
PwmOut pwm_F_;
PwmOut pwm_B_;
@@ -45,6 +45,31 @@
* 負の数を代入すれば逆回転することができる
*
* @param target_omega 目標角速度
+ * @section SAMPLE
+ * @code
+ * //プログラム例
+ * #include "mbed.h"
+ * #include "EC.h" //Encoderライブラリをインクルード
+ * #include "SpeedController.h" //SpeedControlライブラリをインクルード
+ * #define RESOLUTION 500
+ * Ec4multi EC(p11,p12,RESOLUTION);
+ * SpeedControl motor(p21,p22,50,EC);
+ * int main(){
+ * motor.setEquation(0.0062,0.0045,-0.0061,0.0091); //求めたC,Dの値を設定
+ * motor.setPDparam(0.1,0.0); //PIDの係数を設定
+ * int kai=0;
+ * for(int i=0;i<100000000;i++){
+ * motor.Sc(10); //10[rad/s]でモーターを回転
+ * kai++;
+ * if(kai>1000){
+ * printf("omega=%f\r\n",EC.getOmega());
+ * kai=0;
+ * }
+ * }
+ * motor.stop()
+ * while(1);
+ * }
+ * @endcode
*
* @section CAUTION(printfについて)
* printfはプログラム的に大きな負担がかかり、かなり時間がかかってしまうものである。
@@ -84,7 +109,7 @@
void setEquation(double cf,double df,double cb,double db);
/** 出力duty比の上限を決める関数
* 0 ~ 0.95の範囲内で設定する
- * @param duty_limit 出力duty比の上限
+ * @param duty_limit 出力duty比の上限
*/
void setDutyLimit(double duty_limit);
@@ -95,6 +120,27 @@
/** duty(-1 ~ 1)比でモーターを回転させる関数
* 負の値を入れたら逆回転する
* @param duty 出力duty比
+ * @section SAMPLE
+ * @code
+ * #include "mbed.h"
+ * #include "EC.h" //Encoderライブラリをインクルード
+ * #include "SpeedController.h" //SpeedControlライブラリをインクルード
+ * #define RESOLUTION 500
+ * Ec4multi EC(p11,p12,RESOLUTION);
+ * SpeedControl motor(p21,p22,50,EC);
+ * int main(){
+ * while(1){
+ * motor.turn(0.5);
+ * wait(1);
+ * motor.turn(0);
+ * wait(1);
+ * motor.turn(-0.5);
+ * wait(1);
+ * motor.turn(0);
+ * wait(1);
+ * }
+ * }
+ * @endcode
*/
void turn(double duty);
///Encoderや速度制御の値をresetする関数