Simple test application for the STMicroelectronics X-NUCLEO-IHM01A1 Stepper Motor Control Expansion Board.

Dependencies:   X_NUCLEO_IHM01A1 mbed

Fork of HelloWorld_IHM01A1 by ST Expansion SW Team

Motor Control with the X-NUCLEO-IHM01A1 Expansion Board

This application provides a simple example of usage of the X-NUCLEO-IHM01A1 Stepper Motor Control Expansion Board.
It shows how to use one stepper motor connected to the board, moving the rotor to a specific position, with a given speed value, direction of rotation, etc.

Revision:
27:e09aa231c16d
Parent:
26:b0203c2265e5
Child:
29:a80a213c3c94
--- a/main.cpp	Thu Apr 07 16:33:42 2016 +0000
+++ b/main.cpp	Fri Apr 08 12:48:30 2016 +0000
@@ -175,21 +175,36 @@
     /*----- Changing the motor setting. -----*/
 
     /* Printing to the console. */
+    printf("--> Setting Torque Regulation Current to 500[mA].\r\n");
+
+    /* Increasing the torque regulation current to 500[mA]. */
+    motor->SetParameter(L6474_TVAL, 500);
+
+    /* Printing to the console. */
     printf("--> Doubling the microsteps.\r\n");
 
     /* Doubling the microsteps. */
     if (!motor->SetStepMode((StepperMotor::step_mode_t) STEP_MODE_1_16))
         printf("    Step Mode not allowed.\r\n");
 
-    /* Printing to the console. */
-    printf("--> Setting Torque Regulation Current to 500[mA].\r\n");
-
-    /* Increasing the torque regulation current to 500[mA]. */
-    motor->SetParameter(L6474_TVAL, 500);
-
     /* Waiting. */
     wait_ms(DELAY_1);
 
+    /* Printing to the console. */
+    printf("--> Setting Home.\r\n");
+
+    /* Setting the current position to be the home position. */
+    motor->SetHome();
+
+    /* Getting current position. */
+    position = motor->GetPosition();
+    
+    /* Printing to the console. */
+    printf("    Position: %d.\r\n", position);
+    
+    /* Waiting. */
+    wait_ms(DELAY_2);
+
 
     /*----- Moving. -----*/
     
@@ -207,10 +222,6 @@
     
     /* Printing to the console. */
     printf("    Position: %d.\r\n", position);
-    printf("--> Setting Home.\r\n");
-
-    /* Setting the current position to be the home position. */
-    motor->SetHome();
 
     /* Waiting. */
     wait_ms(DELAY_1);