GroupA / Mbed 2 deprecated WaG_final

Dependencies:   mbed

Fork of Lab_6_WaG by GroupA

Revision:
43:3b7f326aa096
Parent:
42:6cba679a4ee4
Child:
45:54d18ab80fd1
--- a/stepper.cpp	Thu Mar 29 15:51:52 2018 +0000
+++ b/stepper.cpp	Thu Mar 29 16:28:06 2018 +0000
@@ -49,8 +49,12 @@
 */
 void stp_init() {
     stp_cur_pos = STP_POS_UNKN;
+    jog_cw.mode(PullUp);
+    jog_ccw.mode(PullUp);
+    cal_button.mode(PullUp);
+    home_sensor.mode(PullUp);
     for (int i = 1; i <= NUM_SENSORS; i++) {
-        stp_sensor_pos[i] = STP_POS_UNKN;
+        //stp_sensor_pos[i] = STP_POS_UNKN;
     }
 }
 
@@ -76,6 +80,7 @@
             //pc.printf("i = %d\n", i);
             spi_send(drv8806, turn[i]);
         }
+        wait(0.015);
     }
     else if (direction == STP_CCW) {
         for (int i = 3; i >= 0; i--) {
@@ -83,6 +88,7 @@
             //pc.printf("i = %d\n", i);
             spi_send(drv8806, turn[i]);
         }
+        wait(0.015);
     }
     wait(MOTOR_DELAY);
 }
@@ -99,10 +105,7 @@
  *      Returns: void
 */
 void step_test() {
-    jog_cw.mode(PullUp);
-    jog_ccw.mode(PullUp);
-    cal_button.mode(PullUp);
-    home_sensor.mode(PullUp);
+    stp_init();
     while (uti_chk_ubutton() == 0);
     pc.printf("test begin\n");
     while(1) {
@@ -112,6 +115,7 @@
                     if (stp_cur_pos != STP_POS_UNKN)
                         stp_cur_pos--;
                 }
+                
             }
             if (jog_cw == 0) {
                 if (stp_cur_pos <= 400) {