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 FYDP_Final2 by
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 scale(1), _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 float speed = scale*(float)speed_; 00028 00029 if( speed > 0 ) 00030 { 00031 _pwm = ((float)speed)/ 100.0; 00032 _fwd = 1; 00033 _rev = 0; 00034 } 00035 else if( speed < 0 ) 00036 { 00037 _pwm = -((float)speed)/ 100.0; 00038 _fwd = 0; 00039 _rev = 1; 00040 } 00041 else 00042 { 00043 _fwd = 1; 00044 _rev = 1; 00045 } 00046 }
Generated on Tue Jul 12 2022 16:56:36 by
