APS2 MEA Rodrigo Vianna

Dependencies:   mbed X_NUCLEO_IHM01A1

Revision:
9:dc704c11181d
Parent:
8:146aac014c84
Child:
10:8f031470ca9f
--- a/main.cpp	Thu Nov 26 16:18:24 2015 +0000
+++ b/main.cpp	Fri Nov 27 10:02:40 2015 +0000
@@ -52,7 +52,7 @@
 /* Definitions ---------------------------------------------------------------*/
 
 /* Number of steps corresponding to one round angle of the motor. */
-#define ROUND_ANGLE_STEPS 3200
+#define MOTOR_STEPS 400
 
 
 /* Variables -----------------------------------------------------------------*/
@@ -70,7 +70,7 @@
     /* Initializing SPI bus. */
     DevSPI dev_spi(D11, D12, D13);
 
-    /* Initializing Motor Control Component. */
+    /* Initializing Motor Control Component in FULL STEP mode. */
     motor = new L6474(D2, D8, D7, D9, D10, dev_spi);
     if (motor->Init(NULL) != COMPONENT_OK)
         return false;
@@ -82,10 +82,10 @@
     /*----- Moving. -----*/
 
     /* Printing to the console. */
-    printf("--> Moving forward %d steps.\r\n", ROUND_ANGLE_STEPS);
+    printf("--> Moving forward %d steps.\r\n", MOTOR_STEPS);
 
     /* Moving N steps in the forward direction. */
-    motor->Move(StepperMotor::FWD, ROUND_ANGLE_STEPS);
+    motor->Move(StepperMotor::FWD, MOTOR_STEPS);
 
     /* Waiting while the motor is active. */
     motor->WaitWhileActive();
@@ -103,10 +103,10 @@
     /*----- Moving. -----*/
     
     /* Printing to the console. */
-    printf("--> Moving backward %d steps.\r\n", ROUND_ANGLE_STEPS >> 1);
+    printf("--> Moving backward %d steps.\r\n", MOTOR_STEPS >> 1);
 
     /* Moving N steps in the backward direction. */
-    motor->Move(StepperMotor::BWD, ROUND_ANGLE_STEPS >> 1);
+    motor->Move(StepperMotor::BWD, MOTOR_STEPS >> 1);
     
     /* Waiting while the motor is active. */
     motor->WaitWhileActive();
@@ -128,10 +128,10 @@
     /*----- Going to a specified position. -----*/
 
     /* Printing to the console. */
-    printf("--> Going to position %d.\r\n", ROUND_ANGLE_STEPS >> 1);
+    printf("--> Going to position %d.\r\n", MOTOR_STEPS >> 1);
     
     /* Requesting to go to a specified position. */
-    motor->GoTo(ROUND_ANGLE_STEPS >> 1);
+    motor->GoTo(MOTOR_STEPS >> 1);
     
     /* Waiting while the motor is active. */
     motor->WaitWhileActive();
@@ -247,13 +247,13 @@
     while (1)
     {
         /* Requesting to go to a specified position. */
-        motor->GoTo(ROUND_ANGLE_STEPS >> 1);
+        motor->GoTo(MOTOR_STEPS >> 1);
 
         /* Waiting while the motor is active. */
         motor->WaitWhileActive();
 
         /* Requesting to go to a specified position. */
-        motor->GoTo(- (ROUND_ANGLE_STEPS >> 1));
+        motor->GoTo(- (MOTOR_STEPS >> 1));
 
         /* Waiting while the motor is active. */
         motor->WaitWhileActive();