A simple stepper motor driver library, supporting micro-stepping drivers.

Dependents:   Test_LCDTS_UI_StepperMove

Revision:
1:d453a05ce39e
Parent:
0:52fb09e87581
Child:
2:97b1bc1f0b5f
--- a/Stepper.cpp	Sun Feb 24 16:23:02 2013 +0000
+++ b/Stepper.cpp	Wed Nov 11 11:10:28 2020 +0000
@@ -1,26 +1,45 @@
 #include "Stepper.h"
 #include "mbed.h"
 
-stepper::stepper(PinName _en, PinName ms1, PinName ms2, PinName ms3, PinName _stepPin, PinName dir):en(_en),
-    microstepping(ms1, ms2, ms3),
+stepper::stepper(PinName _en, PinName _stepPin, PinName _dir):
+    en(_en),
     stepPin(_stepPin),
-    direction(dir)
+    dir(_dir)
 {
 }
 
-void stepper::step(int microstep, int dir, float speed)
+steppers::steppers(PinName _en, PinName _stepPin, PinName _dirG, PinName _dirD):
+    stepper(_en,_stepPin,_dirG),
+    dirD(_dirD)
+{}
+
+/*void stepper::move(float pos_current, float pos_togo, float speed)
+{
+    if ( */
+    
+void stepper::step(int direction, float speed)
 {
-    if (microstep == 1) {
-        microstepping = 0;
-    } else if (microstep <= 4) {
-        microstepping = microstep / 2;
-    } else if (microstep > 4) {
-        microstepping = (microstep / 2) - 1;
+    if (direction == 1) {
+        dir = 1;
+    } else if (direction == 0) {
+        dir = 0;
     }
-    if (dir == 1) {
-        direction = 0;
-    } else if (dir == 0) {
-        direction = 1;
+    
+    //  Step...
+    stepPin = 1;
+    wait(1/speed);
+    stepPin = 0;
+    wait(1/speed);
+}
+
+void steppers::step(int direction, float speed)
+{
+    if (direction == 1) {
+        dirD = 1;
+        dir = 0;
+    } else if (direction == 0) {
+        dirD = 0;
+        dir = 1;
     }
     
     //  Step...