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.
Dependents: Programs LINE_TRACE_CAR
motor.h
00001 #ifndef _MOTOR_H_ 00002 #define _MOTOR_H_ 00003 00004 #include "mbed.h" 00005 00006 class Motor //モータクラス 00007 { 00008 public: 00009 const float PWM_FREQ; //PWM周波数 00010 const float MEASUREMENT_INTERVAL; //計測周期 00011 const int SLIT; //PGセンサスリット数 00012 const float KP; //フィードバックパラメータ(比例) 00013 const float KI; //フィードバックパラメータ(積分) 00014 const float KD; //フィードバックパラメータ(微分) 00015 00016 private: 00017 PwmOut pwm; //PWM出力 00018 DigitalOut phase; //モータ回転方向(正転=1) 00019 int counter; //RPMカウンタ 00020 float target; //目標回転数 00021 float target_pre; //ひとつ前の目標回転数 00022 float rpm; //現在の回転数 00023 float error_pre1; //ひとつ前の偏差 00024 float error_pre2; //ふたつ前の偏差 00025 float duty; //設定duty比 00026 float MV; //操作量 00027 void calc_rpm(); //回転数計測 00028 00029 public: 00030 Motor(PinName pwm_pin, PinName phase_pin); 00031 void Set_phase(const int _phase); 00032 void Set_target(const float _target); 00033 float Get_rpm(); 00034 float Get_estimated_duty(float target_rpm); 00035 void count(); 00036 void drive(); 00037 }; 00038 00039 #endif
Generated on Fri Jul 29 2022 11:27:02 by
1.7.2