Simple test application for the STMicroelectronics X-NUCLEO-IHM01A1 Stepper Motor Control Expansion Board.
Dependencies: X_NUCLEO_IHM01A1 mbed
Fork of HelloWorld_IHM01A1 by
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, committed 2016-04-08
- Comitter:
- Davidroid
- Date:
- Fri Apr 08 12:48:30 2016 +0000
- Parent:
- 26:b0203c2265e5
- Child:
- 28:e15fc9311ca3
- Commit message:
- + Added a SetHome() after changing the step mode.; + 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 Apr 07 16:33:42 2016 +0000 +++ b/X_NUCLEO_IHM01A1.lib Fri Apr 08 12:48:30 2016 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/ST/code/X_NUCLEO_IHM01A1/#1c3146315f16 +http://developer.mbed.org/teams/ST/code/X_NUCLEO_IHM01A1/#fd83fecf1ef5
--- 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);