Thesis Rotating Platform, Uart Control

Dependencies:   BufferedSerial X_NUCLEO_IHM01A1_Disabled_Control mbed

Fork of Demo_IHM01A1_3-Motors by Arkadi Rafalovich

Files at this revision

API Documentation at this revision

Comitter:
Davidroid
Date:
Fri Nov 27 11:27:56 2015 +0000
Parent:
8:cec4c2c03a27
Child:
10:bf4541665bed
Commit message:
+ Updated with the new version of the library.

Changed in this revision

X_NUCLEO_IHM01A1.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
--- a/X_NUCLEO_IHM01A1.lib	Thu Nov 26 16:17:52 2015 +0000
+++ b/X_NUCLEO_IHM01A1.lib	Fri Nov 27 11:27:56 2015 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/ST-Expansion-SW-Team/code/X_NUCLEO_IHM01A1/#c3824af0caf4
+https://developer.mbed.org/teams/ST-Expansion-SW-Team/code/X_NUCLEO_IHM01A1/#9f4b9540ff3e
--- 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();