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

Dependencies:   X_NUCLEO_IHM01A1 mbed

Fork of MotorControl_IHM01A1 by ST Expansion SW Team

Motor Control with the X-NUCLEO-IHM01A1 Expansion Board

This application provides a more complex 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, with an example of ISR and error handler, as well as an almost complete coverage of the available APIs, e.g.:

  • moving the rotor to a specific position;
  • moving the rotor for a certain amount of time;
  • setting the speed value;
  • setting the direction of rotation;
  • changing the stepper motor mode;
  • soft/hard stopping the rotor;
  • powering off the power bridge.
Revision:
2:d956260240b0
Parent:
1:5171df1bf684
Child:
3:82f4c46cccd0
--- a/main.cpp	Fri Oct 16 13:43:01 2015 +0000
+++ b/main.cpp	Fri Nov 13 13:00:23 2015 +0000
@@ -82,7 +82,7 @@
         printf("--> Moving forward 16000 steps.\r\n");
 
         /* Moving 16000 steps in the forward direction. */
-        motor->Move(FORWARD, 16000);
+        motor->Move(StepperMotor::CW, 16000);
         
         /* Waiting while the motor is active. */
         motor->WaitWhileActive();
@@ -97,7 +97,7 @@
         printf("--> Moving backward 16000 steps.\r\n");
         
         /* Moving 16000 steps in the backward direction. */
-        motor->Move(BACKWARD, 16000);
+        motor->Move(StepperMotor::CCW, 16000);
 
         /* Waiting while the motor is active. */
         motor->WaitWhileActive();
@@ -202,13 +202,13 @@
         printf("--> Moving backward.\r\n");
 
         /* Requesting to run backward. */
-        motor->Run(BACKWARD);
+        motor->Run(StepperMotor::CCW);
 
         /* Waiting until delay has expired. */
         wait_ms(5000);
 
         /* Getting current speed. */
-        int speed = motor->GetCurrentSpeed();
+        int speed = motor->GetSpeed();
 
         /* Printing to the console. */
         printf("    Speed: %d.\r\n", speed);
@@ -226,7 +226,7 @@
         wait_ms(5000);
 
         /* Getting current speed. */
-        speed = motor->GetCurrentSpeed();
+        speed = motor->GetSpeed();
 
         /* Printing to the console. */
         printf("    Speed: %d.\r\n", speed);
@@ -244,7 +244,7 @@
         wait_ms(5000);
 
         /* Getting current speed. */
-        speed = motor->GetCurrentSpeed();
+        speed = motor->GetSpeed();
 
         /* Printing to the console. */
         printf("    Speed: %d.\r\n", speed);
@@ -268,7 +268,7 @@
         wait_ms(5000);
 
         /* Getting current speed. */
-        speed = motor->GetCurrentSpeed();
+        speed = motor->GetSpeed();
 
         /* Printing to the console. */
         printf("    Speed: %d.\r\n", speed);
@@ -292,7 +292,7 @@
         wait_ms(5000);
 
         /* Getting current speed. */
-        speed = motor->GetCurrentSpeed();
+        speed = motor->GetSpeed();
 
         /* Printing to the console. */
         printf("    Speed: %d.\r\n", speed);
@@ -319,7 +319,7 @@
         printf("--> Requiring hard-stop while running.\r\n");
 
         /* Requesting to run in forward direction. */
-        motor->Run(FORWARD);
+        motor->Run(StepperMotor::CW);
 
         /* Waiting until delay has expired. */
         wait_ms(5000);
@@ -365,7 +365,7 @@
          * The flag interrupt should be raised and the "MyFlagInterruptHandler"
          * function called.
          */
-        motor->CmdGetParam(0x1F);
+        motor->GetParameter(0x1F);
 
         /* Waiting 0.5 seconds. */
         wait_ms(500);