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.
TB6612.cpp
00001 /** 00002 * Motor Driver TB6612 Control Library 00003 * 00004 * -- TB6612 is a device of the TOSHIBA. 00005 * 00006 * Copyright (C) 2012 Junichi Katsu (JKSOFT) 00007 */ 00008 00009 00010 #include "TB6612.h" 00011 00012 // TB6612 Class Constructor 00013 TB6612::TB6612(PinName pwm, PinName fwd, PinName rev): 00014 _pwm(pwm), _fwd(fwd), _rev(rev) { 00015 00016 _fwd = 0; 00017 _rev = 0; 00018 _pwm = 0.0; 00019 _pwm.period(0.001); 00020 } 00021 00022 // Speed Control 00023 // arg 00024 // int speed -100 -- 0 -- 100 00025 void TB6612::speed(int speed) { 00026 00027 if( speed > 0 ) 00028 { 00029 _pwm = ((float)speed) / 100.0; 00030 _fwd = 1; 00031 _rev = 0; 00032 } 00033 else if( speed < 0 ) 00034 { 00035 _pwm = -((float)speed) / 100.0; 00036 _fwd = 0; 00037 _rev = 1; 00038 } 00039 else 00040 { 00041 _fwd = 1; 00042 _rev = 1; 00043 } 00044 } 00045 00046 00047 // Speed Control with time-out 00048 // arg 00049 // int speed -100 -- 0 -- 100 00050 // int time 0 00051 void TB6612::move(int sspeed , int time) 00052 { 00053 speed(sspeed); 00054 wait_ms(time); 00055 } 00056 00057
Generated on Mon Jul 18 2022 23:53:13 by
1.7.2