update 1/27/16

Dependencies:   mbed

Fork of R5_StepperDrive by Jaime Martinez

Revision:
0:266a770a17e9
Child:
1:909572175aad
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/StepperDrive.h	Sun Nov 22 19:27:47 2015 +0000
@@ -0,0 +1,42 @@
+#ifndef _STEPPER_DRIVE_
+#define _STEPPER_DRIVE_
+
+#include "mbed.h"
+
+#define Ustep   16  //microstepping setup: 1, 2, 4, 8, or 16
+
+class StepperDrive{
+    public:
+    StepperDrive(PinName in1, PinName in2, bool in3, PinName in4, PinName in5, bool in6, float in7, float in8, float in9 = 1000);
+              //(stepPinLeft, dirPinLeft, invertLeft, stepPinRight, dirPinRight, invertRight, wheelCircum, wheelSepar, periodUs)
+    int move(float distance, float angle);
+    bool isMoveDone();
+    
+    private:
+    Ticker pit;           //periodic interrupt timer
+    
+    void pitCallback();
+    
+    void stepRight(bool dir);
+    void stepLeft(bool dir);
+    
+    DigitalOut leftStep;
+    DigitalOut leftDir;
+    DigitalOut rightStep;
+    DigitalOut rightDir;
+    
+    float wheelCircum;     //wheel circumference
+    float wheelSepar;      //distance between wheels
+    bool invertLeft;       //software wheel direction inversion
+    bool invertRight;      //software wheel direction inversion
+    bool moveComplete;
+    
+    int leftSteps;
+    int rightSteps;
+    float leftStepsPC;
+    float rightStepsPC;
+    float leftError;
+    float rightError;
+};
+
+#endif
\ No newline at end of file