Modified phase table in stepper.cpp to enable stepping a bipolar motor using a twin H-bridge driver.
Fork of stepper by
Corrected single-stepping, now walking up or down just one phase table. Compile-time options for driving bipolar motor in any of single-phase, two-phase, or half-stepping. Coils remain engaged at end of specifed movement command - de-energize coils by issuing a motor.move(0) while already stopped.
Revision 3:96bfb8b476f8, committed 2014-12-18
- Comitter:
- gregeric
- Date:
- Thu Dec 18 19:49:42 2014 +0000
- Parent:
- 2:fd11d89b8ce0
- Child:
- 4:5b596b405573
- Commit message:
- Unipolar/bipolar motor configuration switchable by #define in stepper.cpp
Changed in this revision
| stepper.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/stepper.cpp Thu Dec 18 17:52:40 2014 +0000
+++ b/stepper.cpp Thu Dec 18 19:49:42 2014 +0000
@@ -17,15 +17,22 @@
#include "mbed.h"
#include "stepper.h"
+
+#define BIPOLAR_STEPPER
+
+#ifdef BIPOLAR_STEPPER
/*
-//Firing sequence for uni-polar (5+ wires) stepper (4x open-collector drivers required).
+ * Firing sequence A+, B+, A-, B- for bi-polar (4 wires) stepper (2x H-Bridge driver required eg L298)
+ */
+const uint8_t pase_cw[4][4] = {{1, 0, 0, 0}, {0, 0, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}};
+const uint8_t pase_ccw[4][4] = {{1, 0, 0, 0}, {0, 0, 0, 1}, {0, 1, 0, 0}, {0, 0, 1, 0}};
+#else
+/*
+ * Firing sequence for uni-polar (5+ wires) stepper (4x open-collector drivers required).
+ */
const uint8_t pase_cw[4][4] = {{1, 1, 0, 0}, {0, 1, 1, 0}, {0, 0, 1, 1}, {1, 0, 0, 1}};
const uint8_t pase_ccw[4][4] = {{1, 1, 0, 0}, {1, 0, 0, 1}, {0, 0, 1, 1}, {0, 1, 1, 0}};
-*/
-//Firing sequence for bi-polar (4 wires) stepper (2x H-Bridge driver required eg L298
-//A+, B+, A-, B-)
-const uint8_t pase_cw[4][4] = {{1, 0, 0, 0}, {0, 0, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}};
-const uint8_t pase_ccw[4][4] = {{1, 0, 0, 0}, {0, 0, 0, 1}, {0, 1, 0, 0}, {0, 0, 1, 0}};
+#endif
extern uint8_t pls_width[];
