Default mbed pwm doesn't have enough resolution at high frequencies, thats why I implemented VNH5019 Motor carrier with FastPWM.

Dependencies:   FastPWM

Fork of VNH5019 by IEEE RAS METU

Revision:
10:829d36e2de02
Parent:
9:1709d9b034f7
Child:
11:6902db5e7978
--- a/VNH5019.cpp	Thu Nov 30 17:05:25 2017 +0000
+++ b/VNH5019.cpp	Thu Nov 30 17:42:16 2017 +0000
@@ -3,6 +3,7 @@
 VNH5019::VNH5019(PinName INA_, PinName INB_, PinName ENDIAG_, PinName CS_, PinName PWM_)
  : INA(INA_),
    INB(INB_),
+   ENDIAG(ENDIAG_),
    CS(CS_),
    PWM(PWM_)
 {
@@ -11,8 +12,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;
@@ -50,8 +51,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;
@@ -65,10 +66,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();
 }