Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Lab_6_WaG by
Diff: stepper.cpp
- Revision:
- 42:6cba679a4ee4
- Parent:
- 41:9b293b14b845
- Child:
- 43:3b7f326aa096
- Child:
- 44:4c2ba5bbba67
diff -r 9b293b14b845 -r 6cba679a4ee4 stepper.cpp
--- a/stepper.cpp Tue Mar 27 16:34:17 2018 +0000
+++ b/stepper.cpp Thu Mar 29 15:51:52 2018 +0000
@@ -1,14 +1,14 @@
/******************************************************************************
* EECS 397
*
-* Assignment Name: Lab 5: WaG
+* Assignment Name: Lab 6: WaG
*
* Authors: Sam Morrison and Phong Nguyen
* File name: stepper.cpp
* Purpose: Driver for stepper motor
*
* Created: 03/02/2018
-* Last Modified: 03/27/2018
+* Last Modified: 03/29/2018
*
******************************************************************************/
@@ -107,16 +107,23 @@
pc.printf("test begin\n");
while(1) {
if (jog_ccw == 0) {
- stp_step(STP_CCW);
- //pc.printf("Home sensor is currently %d\n", home_sensor.read());
+ if (stp_cur_pos != 0) {
+ stp_step(STP_CCW);
+ if (stp_cur_pos != STP_POS_UNKN)
+ stp_cur_pos--;
+ }
}
if (jog_cw == 0) {
- stp_step(STP_CW);
- //pc.printf("Home sensor is currently %d\n", home_sensor.read());
+ if (stp_cur_pos <= 400) {
+ stp_step(STP_CW);
+ if (stp_cur_pos != STP_POS_UNKN)
+ stp_cur_pos++;
+ }
+ else
+ while(1);
}
if (cal_button == 0) {
stp_find_home();
- //pc.printf("Home sensor is currently %d\n", home_sensor.read());
}
}
}
