Theis Rotating Platform Demo code

Dependencies:   X_NUCLEO_IHM01A1_Demo_Code mbed

Fork of Demo_IHM01A1_3-Motors by Arkadi Rafalovich

Revision:
9:a9e51320aee4
Parent:
8:cec4c2c03a27
Child:
14:fcd452b03d1a
--- a/main.cpp	Thu Nov 26 16:17:52 2015 +0000
+++ b/main.cpp	Fri Nov 27 11:27:56 2015 +0000
@@ -51,8 +51,8 @@
 
 /* Definitions ---------------------------------------------------------------*/
 
-/* Number of steps corresponding to one round angle of the motor. */
-#define ROUND_ANGLE_STEPS 3200
+/* Number of steps to move. */
+#define STEPS 3200
 
 
 /* Variables -----------------------------------------------------------------*/
@@ -71,7 +71,7 @@
     /* Initializing SPI bus. */
     DevSPI dev_spi(D11, D12, D13);
 
-    /* Initializing Motor Control Component. */
+    /* Initializing Motor Control Components. */
     motor1 = new L6474(D2, D8, D7, D9, D10, dev_spi);
     if (motor1->Init(NULL) != COMPONENT_OK)
         return false;
@@ -86,11 +86,11 @@
     /*----- Moving. -----*/
 
     /* Printing to the console. */
-    printf("--> Moving forward: M1 %d steps, M2 %d steps.\r\n", ROUND_ANGLE_STEPS >> 1, ROUND_ANGLE_STEPS);
+    printf("--> Moving forward: M1 %d steps, M2 %d steps.\r\n", STEPS >> 1, STEPS);
 
     /* Moving N steps in the forward direction. */
-    motor1->Move(StepperMotor::FWD, ROUND_ANGLE_STEPS >> 1);
-    motor2->Move(StepperMotor::FWD, ROUND_ANGLE_STEPS);
+    motor1->Move(StepperMotor::FWD, STEPS >> 1);
+    motor2->Move(StepperMotor::FWD, STEPS);
 
     /* Waiting while the motor is active. */
     motor1->WaitWhileActive();
@@ -110,12 +110,12 @@
     /*----- Moving. -----*/
     
     /* Printing to the console. */
-    printf("--> Moving backward: M1 %d steps, M2 %d steps.\r\n", ROUND_ANGLE_STEPS >> 1, ROUND_ANGLE_STEPS);
+    printf("--> Moving backward: M1 %d steps, M2 %d steps.\r\n", STEPS >> 1, STEPS);
 
     
     /* Moving N steps in the backward direction. */
-    motor1->Move(StepperMotor::BWD, ROUND_ANGLE_STEPS >> 1);
-    motor2->Move(StepperMotor::BWD, ROUND_ANGLE_STEPS);
+    motor1->Move(StepperMotor::BWD, STEPS >> 1);
+    motor2->Move(StepperMotor::BWD, STEPS);
     
     /* Waiting while the motor is active. */
     motor1->WaitWhileActive();
@@ -140,11 +140,11 @@
     /*----- Going to a specified position. -----*/
 
     /* Printing to the console. */
-    printf("--> Going to position: M1 %d, M2 %d.\r\n", ROUND_ANGLE_STEPS, ROUND_ANGLE_STEPS >> 1);
+    printf("--> Going to position: M1 %d, M2 %d.\r\n", STEPS, STEPS >> 1);
     
     /* Requesting to go to a specified position. */
-    motor1->GoTo(ROUND_ANGLE_STEPS);
-    motor2->GoTo(ROUND_ANGLE_STEPS >> 1);
+    motor1->GoTo(STEPS);
+    motor2->GoTo(STEPS >> 1);
     
     /* Waiting while the motor is active. */
     motor1->WaitWhileActive();
@@ -274,16 +274,16 @@
     while(1)
     {
         /* Requesting to go to a specified position. */
-        motor1->GoTo(ROUND_ANGLE_STEPS >> 1);
-        motor2->GoTo(- (ROUND_ANGLE_STEPS >> 1));
+        motor1->GoTo(STEPS >> 1);
+        motor2->GoTo(- (STEPS >> 1));
 
         /* Waiting while the motor is active. */
         motor1->WaitWhileActive();
         motor2->WaitWhileActive();
 
         /* Requesting to go to a specified position. */
-        motor1->GoTo(- (ROUND_ANGLE_STEPS >> 1));
-        motor2->GoTo(ROUND_ANGLE_STEPS >> 1);
+        motor1->GoTo(- (STEPS >> 1));
+        motor2->GoTo(STEPS >> 1);
 
         /* Waiting while the motor is active. */
         motor1->WaitWhileActive();