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:
- 11:6902db5e7978
- Parent:
- 10:829d36e2de02
--- a/VNH5019.cpp Thu Nov 30 17:42:16 2017 +0000 +++ b/VNH5019.cpp Thu Dec 07 15:32:22 2017 +0000 @@ -3,7 +3,6 @@ VNH5019::VNH5019(PinName INA_, PinName INB_, PinName ENDIAG_, PinName CS_, PinName PWM_) : INA(INA_), INB(INB_), - ENDIAG(ENDIAG_), CS(CS_), PWM(PWM_) { @@ -12,8 +11,8 @@ void VNH5019::init() { - ENDIAG.input(); - ENDIAG.mode(PullUp); + // ENDIAG.input(); + // ENDIAG.mode(PullUp); PWM.period_us(50); // 4 kHz (valid 0 - 20 kHz) PWM.write(0); INA = 0; @@ -51,8 +50,8 @@ void VNH5019::clear_fault() { // if ENDIAG is high, then there is no fault - if (ENDIAG.read()) - return; + /* if (ENDIAG.read()) + return; */ // toggle the inputs INA = 0; @@ -66,10 +65,10 @@ INA = 0; INB = 0; PWM = 0; - ENDIAG.output(); - ENDIAG = 0; + /* ENDIAG.output(); + ENDIAG = 0; */ wait_us(1600); // and finally re-enable the motor - ENDIAG.input(); + // ENDIAG.input(); }