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:
5:b5f360a16354
diff -r 3802325cf6e1 -r b5f360a16354 VNH5019Accel.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/VNH5019Accel.cpp	Thu Aug 07 12:23:30 2014 +0000
@@ -0,0 +1,36 @@
+#include "VNH5019Accel.h"
+
+void VNH5019Accel::Interrupt()
+{
+    float MyRequestedSpeed = RequestedSpeed;
+    if (CurrentSpeed != MyRequestedSpeed)
+    {
+        if (std::abs(CurrentSpeed-MyRequestedSpeed) < VNH5019ChangePerTick)
+            CurrentSpeed = MyRequestedSpeed;
+        else if (MyRequestedSpeed > CurrentSpeed)
+            CurrentSpeed += VNH5019ChangePerTick;
+        else
+            CurrentSpeed -= VNH5019ChangePerTick;
+        Driver.speed(CurrentSpeed);
+    }
+    else
+    {
+        float MyRequestedBrake = RequestedBrake;
+        if (CurrentBrake != MyRequestedBrake)
+        {
+            if (std::abs(CurrentBrake-MyRequestedBrake) < VNH5019BrakeChangePerTick)
+                CurrentBrake = MyRequestedBrake;
+            else if (MyRequestedBrake > CurrentBrake)
+                CurrentBrake += VNH5019BrakeChangePerTick;
+          else
+                CurrentBrake -= VNH5019BrakeChangePerTick;
+            Driver.brake(CurrentBrake);
+        }
+    }
+}
+
+DualVNH5019AccelMotorShield::DualVNH5019AccelMotorShield()
+: m1(PTD4, PTA4, PTC8, PTB0, PTD5),
+  m2(PTC9, PTA13, PTD3, PTB1, PTD0)
+{
+}