Motion control example for 1 motor.
Dependencies: X_NUCLEO_IHM03A1 mbed
Fork of IHM03A1_ExampleFor1Motor by
This application provides an example of usage of the X-NUCLEO-IHM03A1 High Power Stepper Motor Control Expansion Board.
It shows how to use one stepper motor connected to the board by:
- moving the rotor a specific number of steps or to a specific position, with a given speed value, direction of rotation;
- monitoring the motor status;
- handling an interrupt triggered by the motor driver;
- getting and setting a motor driver parameter.
- etc.
For the hardware configuration of the expansion board, please refer to the X_NUCLEO_IHM03A1 home web page.
Revision 1:6b179be4937e, committed 2016-04-07
- Comitter:
- nucleosam
- Date:
- Thu Apr 07 16:32:55 2016 +0000
- Parent:
- 0:cd62cd5b2c77
- Child:
- 2:7e8485b5d57d
- Commit message:
- StepperMotor class modification and induced changes
Changed in this revision
| X_NUCLEO_IHM03A1.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_IHM03A1.lib Tue Apr 05 15:40:30 2016 +0000 +++ b/X_NUCLEO_IHM03A1.lib Thu Apr 07 16:32:55 2016 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/ST-Expansion-SW-Team/code/X_NUCLEO_IHM03A1/#00a3c3f5a8f0 +http://developer.mbed.org/teams/ST-Expansion-SW-Team/code/X_NUCLEO_IHM03A1/#8ce2a5d6fbf8
--- a/main.cpp Tue Apr 05 15:40:30 2016 +0000
+++ b/main.cpp Thu Apr 07 16:32:55 2016 +0000
@@ -426,7 +426,7 @@
printf(" Reached Speed: %d step/s.\r\n", unsignedIntegerValue);
/* Record the reached speed in step/tick */
- unsignedIntegerValue = motor->GetParameter(POWERSTEP01_SPEED);
+ unsignedIntegerValue = motor->GetRawParameter(POWERSTEP01_SPEED);
/* Print reached speed to the console in step/tick */
printf(" Reached Speed: %d step/tick.\r\n", unsignedIntegerValue);
@@ -490,7 +490,7 @@
/* Try to read an inexistent register */
/* the flag interrupt should be raised */
/* and the MyFlagInterruptHandler function called */
- motor->GetParameter(0x1F);
+ motor->GetRawParameter(0x1F);
//----- Put the bridges in high impedance
/* Printing to the console. */
@@ -531,7 +531,7 @@
printf(" This is corresponding to 45.75 full step/s.\r\n");
/* Change the maximum speed to 3*2^18 step/tick */
- motor->SetParameter(POWERSTEP01_MAX_SPEED, 3);
+ motor->SetRawParameter(POWERSTEP01_MAX_SPEED, 3);
/* Printing to the console. */
printf("--> Move the motor 3200 steps in forward direction.\r\n");
@@ -550,13 +550,13 @@
printf("--> Select full step mode.\r\n");
/* Select full step mode for device */
- motor->SetStepMode(STEP_MODE_FULL);
+ motor->SetStepMode(StepperMotor::STEP_MODE_FULL);
/* Printing to the console. */
printf("--> Set the device position to POWERSTEP01_MIN_POSITION + 199 (-2^21+199).\r\n");
/* Set the device position to POWERSTEP01_MIN_POSITION + 199 */
- motor->SetParameter(POWERSTEP01_ABS_POS,(uint32_t)(POWERSTEP01_MIN_POSITION+199));
+ motor->SetRawParameter(POWERSTEP01_ABS_POS,(uint32_t)(POWERSTEP01_MIN_POSITION+199));
/* Get current position of device and print to the console */
pos = motor->GetPosition();
@@ -582,7 +582,7 @@
printf("--> Set the device position to POWERSTEP01_MIN_POSITION + 199 (-2^21+199).\r\n");
/* Set the device position to POWERSTEP01_MIN_POSITION + 199 */
- motor->SetParameter(POWERSTEP01_ABS_POS,(uint32_t)(POWERSTEP01_MIN_POSITION+199));
+ motor->SetRawParameter(POWERSTEP01_ABS_POS,(uint32_t)(POWERSTEP01_MIN_POSITION+199));
/* Get current position of device and print to the console */
pos = motor->GetPosition();
@@ -618,7 +618,7 @@
printf("--> Restore device initial step mode.\r\n");
/* Reset device to its initial microstepping mode */
- motor->SetStepMode(POWERSTEP01_CONF_PARAM_STEP_MODE_DEVICE_0);
+ motor->SetStepMode((StepperMotor::step_mode_t)POWERSTEP01_CONF_PARAM_STEP_MODE_DEVICE_0);
/* Wait for 2 seconds */
wait_ms(2000);
