Adelie Wagner / StepperMotorX2Y

Dependents:   Test_LCDTS_UI_StepperMove

Files at this revision

API Documentation at this revision

Comitter:
Abdel64
Date:
Wed Nov 11 11:10:28 2020 +0000
Parent:
0:52fb09e87581
Child:
2:97b1bc1f0b5f
Commit message:
Classe fille steppers OK

Changed in this revision

Stepper.cpp Show annotated file Show diff for this revision Revisions of this file
Stepper.h Show annotated file Show diff for this revision Revisions of this file
--- 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...
--- a/Stepper.h	Sun Feb 24 16:23:02 2013 +0000
+++ b/Stepper.h	Wed Nov 11 11:10:28 2020 +0000
@@ -7,13 +7,22 @@
 class stepper
 {
 public:
-    stepper(PinName _en, PinName ms1, PinName ms2, PinName ms3, PinName _stepPin, PinName dir);
-    void step(int microstep, int dir, float speed);
+    stepper(PinName _en, PinName _stepPin, PinName _dir);
+    //void move(float pos_current, float pos_togo, float speed);
     void enable();
     void disable();
-private:
+protected:
+    void step (int direction, float speed);
     DigitalOut en;
-    BusOut microstepping;
     DigitalOut stepPin;
-    DigitalOut direction;
+    DigitalOut dir;
+};
+
+class steppers: public stepper
+{
+public:
+    steppers(PinName _en, PinName _stepPin, PinName _dirG, PinName _dirD);
+    void step (int direction, float speed);
+protected:
+    DigitalOut dirD;
 };
\ No newline at end of file