Library that controls BD6211F of rohm.
Dependents: WallBot_Simple WallbotTypeN
BD6211F.cpp
00001 /** 00002 * Motor Driver BD6211F Control Library 00003 * 00004 * -- BD6211F is a device of the rohm. 00005 * 00006 * Copyright (C) 2011 Junichi Katsu (JKSOFT) 00007 */ 00008 00009 00010 #include "BD6211F.h" 00011 00012 // BD6211F Class Constructor 00013 BD6211F::BD6211F(PinName fwd, PinName rev): 00014 _fwd(fwd), _rev(rev) { 00015 00016 _fwd.period(0.00005); 00017 _rev.period(0.00005); 00018 _fwd = 0.0; 00019 _rev = 0.0; 00020 bspeed = 0.0; 00021 timer_flag = false; 00022 } 00023 00024 // Speed Control 00025 // arg 00026 // float speed�F-1.0 �` 0.0 �` 1.0 00027 void BD6211F::speed(float speed) { 00028 00029 if( timer_flag == true ) return; 00030 00031 bspeed = speed; 00032 00033 if( speed > 0.0 ) 00034 { 00035 _fwd = speed; 00036 _rev = 0.0; 00037 } 00038 else if( speed < 0.0 ) 00039 { 00040 _fwd = 0.0; 00041 _rev = -speed; 00042 } 00043 else 00044 { 00045 _fwd = 1.0; 00046 _rev = 1.0; 00047 } 00048 } 00049 00050 00051 // Speed Control with time-out 00052 // arg 00053 // float sspeed:-1.0 �` 0.0 �` 1.0 00054 // float time :0.0�` 00055 void BD6211F::move(float sspeed , float time) 00056 { 00057 speed(sspeed); 00058 timer_flag = true; 00059 timer.attach(this,&BD6211F::timeout,time); 00060 } 00061 00062 00063 void BD6211F::timeout() 00064 { 00065 timer_flag = false; 00066 speed(bspeed); 00067 } 00068
Generated on Wed Jul 13 2022 08:44:43 by 1.7.2