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:
- 9:1709d9b034f7
- Parent:
- 8:1458b4da7e56
- Child:
- 10:829d36e2de02
diff -r 1458b4da7e56 -r 1709d9b034f7 VNH5019.cpp --- a/VNH5019.cpp Sat May 06 13:12:18 2017 +0000 +++ b/VNH5019.cpp Thu Nov 30 17:05:25 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(); }