V1
Dependents: VITI_motor_angle_1 VITI_motor_angle_2 VITI_motor_angle_3
TB6549.cpp
00001 /* mbed simple H-bridge motor controller 00002 * Copyright (c) 2007-2010, 00003 * 00004 00005 */ 00006 00007 #include "TB6549.h" 00008 00009 #include "mbed.h" 00010 00011 Motor::Motor(PinName pwm, PinName in1, PinName in2,PinName sb): 00012 _pwm(pwm), _in1(in1), _in2(in2), _sb(sb) 00013 { 00014 00015 // Set initial condition of PWM 00016 _pwm.period(0.001); 00017 _pwm = 0; 00018 00019 // Initial condition stand by 00020 _in1 = 0; 00021 _in2 = 0; 00022 _sb = 0; 00023 } 00024 00025 void Motor::speed(float speed) 00026 { 00027 if(speed > 0) { 00028 _in1=0; 00029 _in2=1; 00030 _sb=1; 00031 } else { 00032 _in1=1; 00033 _in2=0; 00034 _sb=1; 00035 } 00036 _pwm = abs(speed); 00037 }
Generated on Sun Jul 24 2022 12:51:58 by 1.7.2