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: QEI accelerator bit_test cyclic_io cyclic_var cylinder event_var limit mbed mecanum motor_drive pid pid_encoder rs422_put sbdbt servo
Fork of 17robo_fuzi by
motor_drive_.h
00001 /* 00002 MotorDrive Name(cw, ccw, pwm); 00003 00004 setup(Frequency, DutyLimit) 00005 MotorDrive関数のセットアップ 00006 pwm周波数,pwmの最高値を決める 00007 00008 output(duty) 00009 dutyを出力する 00010 */ 00011 00012 class MotorDrive 00013 { 00014 public : 00015 MotorDrive (PinName Cw, PinName Ccw, PinName Pwm) : cw(Cw), ccw(Ccw), pwm(Pwm) { 00016 cw = 0; 00017 ccw = 0; 00018 pwm = 0; 00019 } 00020 00021 void setup(float Frequency, float Dutylimit) { 00022 float Period = 1 / Frequency; 00023 pwm.period(Period); 00024 limit = Dutylimit; 00025 } 00026 00027 void output(float duty) { 00028 if (duty > 0) { 00029 ccw = 0; 00030 cw = 1; 00031 if (duty > limit) { 00032 duty = limit; 00033 } 00034 } else { 00035 cw = 0; 00036 ccw = 1; 00037 if (duty < -limit) { 00038 duty = -limit; 00039 } 00040 } 00041 00042 pwm = fabs(duty); 00043 } 00044 00045 private : 00046 DigitalOut cw; 00047 DigitalOut ccw; 00048 PwmOut pwm; 00049 00050 float limit; 00051 };
Generated on Mon Aug 8 2022 20:27:09 by
1.7.2
