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:
2:e12e4df7a486
Parent:
1:fbf28f3367aa
Child:
3:fffa53c7aed2
--- a/main.cpp	Fri Oct 16 13:51:31 2015 +0000
+++ b/main.cpp	Fri Nov 13 12:59:29 2015 +0000
@@ -87,7 +87,7 @@
         printf("--> Moving forward %d steps.\r\n", ROUND_ANGLE_STEPS);
 
         /* Moving N steps in the forward direction. */
-        motor->Move(FORWARD, ROUND_ANGLE_STEPS);
+        motor->Move(StepperMotor::CW, ROUND_ANGLE_STEPS);
         
         /* Waiting while the motor is active. */
         motor->WaitWhileActive();
@@ -108,7 +108,7 @@
         printf("--> Moving backward %d steps.\r\n", ROUND_ANGLE_STEPS);
         
         /* Moving N steps in the backward direction. */
-        motor->Move(BACKWARD, ROUND_ANGLE_STEPS);
+        motor->Move(StepperMotor::CCW, ROUND_ANGLE_STEPS);
         
         /* Waiting while the motor is active. */
         motor->WaitWhileActive();
@@ -174,13 +174,13 @@
         printf("--> Moving backward.\r\n");
 
         /* Requesting to run backward. */
-        motor->Run(BACKWARD);
+        motor->Run(StepperMotor::CCW);
 
         /* Waiting until delay has expired. */
         wait_ms(6000);
 
         /* Getting current speed. */
-        int speed = motor->GetCurrentSpeed();
+        int speed = motor->GetSpeed();
 
         /* Printing to the console. */
         printf("    Speed: %d.\r\n", speed);
@@ -198,7 +198,7 @@
         wait_ms(6000);
 
         /* Getting current speed. */
-        speed = motor->GetCurrentSpeed();
+        speed = motor->GetSpeed();
 
         /* Printing to the console. */
         printf("    Speed: %d.\r\n", speed);
@@ -216,7 +216,7 @@
         wait_ms(8000);
 
         /* Getting current speed. */
-        speed = motor->GetCurrentSpeed();
+        speed = motor->GetSpeed();
 
         /* Printing to the console. */
         printf("    Speed: %d.\r\n", speed);
@@ -228,7 +228,7 @@
         printf("--> Moving forward.\r\n");
 
         /* Requesting to run in forward direction. */
-        motor->Run(FORWARD);
+        motor->Run(StepperMotor::CW);
 
         /* Waiting until delay has expired. */
         wait_ms(4000);