Default mbed pwm doesn't have enough resolution at high frequencies, thats why I implemented VNH5019 Motor carrier with FastPWM.
Fork of VNH5019 by
Diff: VNH5019.cpp
- Revision:
- 5:b5f360a16354
- Parent:
- 4:3802325cf6e1
- Child:
- 8:1458b4da7e56
--- a/VNH5019.cpp Tue Jul 29 14:25:40 2014 +0000 +++ b/VNH5019.cpp Thu Aug 07 12:23:30 2014 +0000 @@ -48,38 +48,6 @@ } } -void VNH5019::stop() -{ - INA = 0; - INB = 0; - PWM = 0.0; -} - -void VNH5019::brake(float Brake) -{ - // normalize Brake to 0..1 - if (Brake < 0) - Brake = -Brake; - if (Brake > 1.0) - Brake = 1.0; - - INA = 0; - INB = 0; - PWM = Brake; -} - -float VNH5019::get_current_mA() -{ - // Scale is 144mV per A - // Scale factor is 3.3 / 0.144 = 22.916667 - return CS.read() * 22.916667; -} - -bool VNH5019::is_fault() -{ - return !ENDIAG; -} - void VNH5019::clear_fault() { // if ENDIAG is high, then there is no fault @@ -105,33 +73,3 @@ // and finally re-enable the motor ENDIAG.input(); } - -void VNH5019::disable() -{ - ENDIAG.output(); - ENDIAG.write(0); -} - -void VNH5019::enable() -{ - ENDIAG.input(); -} - -DualVNH5019MotorShield::DualVNH5019MotorShield() -: m1(PTD4, PTA4, PTC8, PTB0, PTD5), - m2(PTC9, PTA13, PTD3, PTB1, PTD0) -{ -} - -DualVNH5019MotorShield::DualVNH5019MotorShield(PinName INA1_, PinName INB1_, PinName ENDIAG1_, PinName CS1_, PinName PWM1_, - PinName INA2_, PinName INB2_, PinName ENDIAG2_, PinName CS2_, PinName PWM2_) - : m1(INA1_, INB1_, ENDIAG1_, CS1_, PWM1_), - m2(INA2_, INB2_, ENDIAG2_, CS2_, PWM2_) -{ -} - -VNH5019& -DualVNH5019MotorShield::operator()(int m) -{ - return m == 1 ? m1 : m2; -}