Library for the VNH5019 Motor Driver, with a helper class for the Pololu Dual VNH5019 Dual Motor Driver Shield http://www.pololu.com/product/2502

Dependents:   VNH5019_second VNH5019_second1

Revision:
0:5d3ab0ea7f27
Child:
1:5e8d9ed18f0f
diff -r 000000000000 -r 5d3ab0ea7f27 VNH5019.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/VNH5019.h	Sat Feb 01 13:48:28 2014 +0000
@@ -0,0 +1,66 @@
+#ifndef DualVNH5019MotorShield_h
+#define DualVNH5019MotorShield_h
+
+#include <mbed.h>
+
+class DualVNH5019MotorShield
+{
+   public:
+      // default pin selection
+      DualVNH5019MotorShield(); // Default pin selection.
+
+                              // User-defined pin selection. 
+      DualVNH5019MotorShield(PinName INA1_, PinName INB1_, PinName ENDIAG1_, PinName CS1_, PinName PWM1_,
+                             PinName INA2_, PinName INB2_, PinName ENDIAG2_, PinName CS2_, PinName PWM2_);
+    
+      // Set motor speeds, from -1.0 to +1.0
+      void setM1Speed(float Speed);
+      void setM2Speed(float Speed);
+      void setSpeeds(float m1Speed, float m2Speed);
+
+      // stop (no current to the motors)
+      void setM1Stop();
+      void setM2Stop();
+
+      // brake, with strength 0..1
+      void setM1Brake(float Brake);
+      void setM2Brake(float Brake);
+      void setBrakes(float m1Brake, float m2Brake);
+      
+      // return the current supplied to the motors
+      float getM1CurrentMA();
+      float getM2CurrentMA();
+      
+      // fault
+      bool isM1Fault();
+      bool isM2Fault();
+
+      // If a fault occurs, then we follow the procedure from the data sheet to clear it
+      void clearM1Fault();
+      void clearM2Fault();
+      
+      // disable / enable (isFault() will return true if the motor is disabled).
+      // Disabling the motor also sets the speed to 0 and brakes to LOW.
+      void disableM1();
+      void disableM2();
+
+      void enableM1(bool Enable = true);
+      void enableM2(bool Enable = true);
+    
+   private:
+      void init(); // Initialize TIMER 1, set the PWM to 20kHZ. 
+
+      DigitalOut   INA1;
+      DigitalOut   INB1;
+      DigitalInOut ENDIAG1;
+      AnalogIn     CS1;
+      PwmOut       PWM1;
+
+      DigitalOut   INA2;
+      DigitalOut   INB2;
+      DigitalInOut ENDIAG2;
+      AnalogIn     CS2;
+      PwmOut       PWM2;
+};
+
+#endif