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.
Fork of sagawa_lpc1114 by
TB6612.cpp
00001 #include "TB6612.h" 00002 00003 // TB6612 Class Constructor 00004 TB6612::TB6612(PinName pwm, PinName fwd, PinName rev): 00005 _pwm(pwm), _fwd(fwd), _rev(rev) { 00006 00007 _fwd = 0; 00008 _rev = 0; 00009 _pwm = 0.0; 00010 stat = 0; 00011 _pwm.period(0.001); 00012 00013 } 00014 00015 // Speed Control 00016 // arg 00017 // float speed -1.0 - 0.0 - 1.0 00018 float TB6612::speed(float speed) { 00019 00020 00021 00022 if( speed > 0.0 ) 00023 { 00024 if( speed > 0.7) speed = 0.7; 00025 _pwm = speed; 00026 _fwd = 1; 00027 _rev = 0; 00028 stat = 1; 00029 } 00030 else if( speed < 0.0 ) 00031 { 00032 if( speed < -0.7) speed = -0.7; 00033 _pwm = -speed; 00034 _fwd = 0; 00035 _rev = 1; 00036 stat = -1; 00037 } 00038 else 00039 { 00040 _fwd = 1; 00041 _rev = 1; 00042 stat = 0; 00043 } 00044 return speed==0 ? 0 : speed > 0 ? 1 : -1; 00045 }
Generated on Sat Aug 6 2022 18:01:58 by
1.7.2
