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.
TB6569.cpp
00001 // 00002 // TB6569.cpp 00003 // 00004 // ... Y.Kuroda 00005 // 00006 // 2012.02.01 ... Originally written by Y.Kuroda 00007 // 2013.06.23 ... Originally written by Y.Kuroda 00008 // 00009 // 00010 #include <mbed.h> 00011 #include "TB6569.h" 00012 00013 TB6569::TB6569( PinName pwm, PinName in1, PinName in2, PinName vref, PinName alert) 00014 : _pwm(pwm), 00015 _in1(in1), 00016 _in2(in2), 00017 _vref(vref), 00018 _alert(alert) 00019 { 00020 stop(); 00021 current_control(1.0); // default = not control current 00022 } 00023 00024 void 00025 TB6569::current_control(float vref) // Current Control [0 ... 1] 00026 { 00027 _vref = vref; 00028 } 00029 00030 void 00031 TB6569::output(int power) // Percent [-100 ... 100] 00032 { 00033 if(power == 0) { // stop 00034 stop(); 00035 } else { 00036 output((float)power/100); 00037 } 00038 } 00039 00040 void 00041 TB6569::output(float power) // PWM Duty [-1 ... 1] 00042 { 00043 if(power> 1) power= 1; 00044 else 00045 if(power<-1) power=-1; 00046 00047 if(power > 0) { 00048 _pwm = power; 00049 _in1 = 1; 00050 _in2 = 0; 00051 } else { 00052 _pwm = power; 00053 _in1 = 0; 00054 _in2 = 1; 00055 } 00056 } 00057 00058 void 00059 TB6569::short_break(void) 00060 { 00061 _pwm = 0; 00062 _in1 = 1; 00063 _in2 = 1; 00064 } 00065 00066 void 00067 TB6569::stop(void) 00068 { 00069 _pwm = 0; 00070 _in1 = 0; 00071 _in2 = 0; 00072 } 00073 00074 void 00075 TB6569::reset(void) 00076 { 00077 stop(); 00078 }
Generated on Thu Jul 28 2022 01:12:51 by
1.7.2