Better driving method; calibration routine

Dependencies:   Stepper_Motor_X27168 mbed

Fork of ECE_4180_Lab_4 by Stepper Motor

Files at this revision

API Documentation at this revision

Comitter:
yhbyhb4433
Date:
Wed Mar 16 18:05:40 2016 +0000
Parent:
0:71dc3ae7e2eb
Commit message:
2-phase driving method; calibration routine

Changed in this revision

Stepper_Motor_X27168.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 71dc3ae7e2eb -r 5de876de6423 Stepper_Motor_X27168.lib
--- a/Stepper_Motor_X27168.lib	Tue Oct 20 00:41:08 2015 +0000
+++ b/Stepper_Motor_X27168.lib	Wed Mar 16 18:05:40 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/ECE-4180/code/Stepper_Motor_X27168/#c346170974bc
+https://developer.mbed.org/users/yhbyhb4433/code/Stepper_Motor_X27168/#406a6e6c4bd7
diff -r 71dc3ae7e2eb -r 5de876de6423 main.cpp
--- a/main.cpp	Tue Oct 20 00:41:08 2015 +0000
+++ b/main.cpp	Wed Mar 16 18:05:40 2016 +0000
@@ -2,18 +2,31 @@
 #include "StepperMotor_X27168.h"
 
 StepperMotor_X27168 smotor(p25, p26, p23, p22);
-
 int main() {
 
-    smotor.step_position(180);
-    wait(0.5);
+    smotor.init(); //initialize the motor
     
-    smotor.step_position(100);
-    wait(0.5);
+    smotor.set_speed(500); //set the speed to 500 steps per second
+    
+    smotor.angle_position(45);
+    wait(1);
     
     smotor.angle_position(270);
-    wait(0.5);
+    wait(1);
+    
+    smotor.angle_position(90);
+    wait(1);
+    
+    smotor.angle_position(180);
+    wait(1);
     
-    smotor.step_position(0);
-    wait(0.5);
+    smotor.angle_position(315);
+    wait(1);
+    
+    smotor.angle_position(45);
+    wait(1);
+    
+    smotor.angle_position(0);
+    wait(1);
+    
 }