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

Files at this revision

API Documentation at this revision

Comitter:
mbedoguz
Date:
Thu Nov 30 17:42:16 2017 +0000
Parent:
9:1709d9b034f7
Child:
11:6902db5e7978
Commit message:
Compatibility changes are made.

Changed in this revision

VNH5019.cpp Show annotated file Show diff for this revision Revisions of this file
VNH5019.h Show annotated file Show diff for this revision Revisions of this file
--- 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();
 }
--- a/VNH5019.h	Thu Nov 30 17:05:25 2017 +0000
+++ b/VNH5019.h	Thu Nov 30 17:42:16 2017 +0000
@@ -40,6 +40,7 @@
 
         DigitalOut   INA;
         DigitalOut   INB;
+        DigitalInOut ENDIAG;
         AnalogIn     CS;
         FastPWM      PWM;
 };        
@@ -97,15 +98,18 @@
 inline
 bool VNH5019::is_fault()
 {
-  return false;
+  return !ENDIAG;
 }
 
 inline
 void VNH5019::disable()
 {
+    ENDIAG.output();
+    ENDIAG.write(0);
 }
 
 inline    
 void VNH5019::enable()
 {
+    ENDIAG.input();
 }