dasf

Dependencies:   mbed a4988

Fork of Ex_Stepper by YX ZHANG

Revision:
0:19f886d481f3
Child:
1:6d4a62f98351
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Oct 11 03:38:41 2017 +0000
@@ -0,0 +1,30 @@
+#include "mbed.h"
+
+Ticker ticker_step;
+DigitalOut step(PB_0), dir(PB_1), en(PA_7);
+volatile int remain;
+
+void toggle_step() { //产生STEP脉冲信号
+    if(remain == 0)
+        return;
+    if(step){
+        step = 0; //STEP 1->0
+        remain--;
+    }else{
+        step = 1; //STEP 0->1
+    }
+}
+
+int main() {
+    ticker_step.attach(&toggle_step, 0.001);
+    en = 0; //Enable stepper driver
+    
+    while (true) {
+        dir = 0;
+        remain = 100;
+        wait(1);
+        dir = 1;
+        remain = 100;
+        wait(1);
+    }
+}