Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EsmacatShield X_NUCLEO_IHM01A1
Revision 9:dc704c11181d, committed 2015-11-27
- Comitter:
- Davidroid
- Date:
- Fri Nov 27 10:02:40 2015 +0000
- Parent:
- 8:146aac014c84
- Child:
- 10:8f031470ca9f
- Commit message:
- + Updated to fit the initialization of the motor to FULL STEP mode done by 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 Nov 26 16:18:24 2015 +0000 +++ b/X_NUCLEO_IHM01A1.lib Fri Nov 27 10:02:40 2015 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/ST-Expansion-SW-Team/code/X_NUCLEO_IHM01A1/#c3824af0caf4 +https://developer.mbed.org/teams/ST-Expansion-SW-Team/code/X_NUCLEO_IHM01A1/#b4d365138c21
--- a/main.cpp Thu Nov 26 16:18:24 2015 +0000
+++ b/main.cpp Fri Nov 27 10:02:40 2015 +0000
@@ -52,7 +52,7 @@
/* Definitions ---------------------------------------------------------------*/
/* Number of steps corresponding to one round angle of the motor. */
-#define ROUND_ANGLE_STEPS 3200
+#define MOTOR_STEPS 400
/* Variables -----------------------------------------------------------------*/
@@ -70,7 +70,7 @@
/* Initializing SPI bus. */
DevSPI dev_spi(D11, D12, D13);
- /* Initializing Motor Control Component. */
+ /* Initializing Motor Control Component in FULL STEP mode. */
motor = new L6474(D2, D8, D7, D9, D10, dev_spi);
if (motor->Init(NULL) != COMPONENT_OK)
return false;
@@ -82,10 +82,10 @@
/*----- Moving. -----*/
/* Printing to the console. */
- printf("--> Moving forward %d steps.\r\n", ROUND_ANGLE_STEPS);
+ printf("--> Moving forward %d steps.\r\n", MOTOR_STEPS);
/* Moving N steps in the forward direction. */
- motor->Move(StepperMotor::FWD, ROUND_ANGLE_STEPS);
+ motor->Move(StepperMotor::FWD, MOTOR_STEPS);
/* Waiting while the motor is active. */
motor->WaitWhileActive();
@@ -103,10 +103,10 @@
/*----- Moving. -----*/
/* Printing to the console. */
- printf("--> Moving backward %d steps.\r\n", ROUND_ANGLE_STEPS >> 1);
+ printf("--> Moving backward %d steps.\r\n", MOTOR_STEPS >> 1);
/* Moving N steps in the backward direction. */
- motor->Move(StepperMotor::BWD, ROUND_ANGLE_STEPS >> 1);
+ motor->Move(StepperMotor::BWD, MOTOR_STEPS >> 1);
/* Waiting while the motor is active. */
motor->WaitWhileActive();
@@ -128,10 +128,10 @@
/*----- Going to a specified position. -----*/
/* Printing to the console. */
- printf("--> Going to position %d.\r\n", ROUND_ANGLE_STEPS >> 1);
+ printf("--> Going to position %d.\r\n", MOTOR_STEPS >> 1);
/* Requesting to go to a specified position. */
- motor->GoTo(ROUND_ANGLE_STEPS >> 1);
+ motor->GoTo(MOTOR_STEPS >> 1);
/* Waiting while the motor is active. */
motor->WaitWhileActive();
@@ -247,13 +247,13 @@
while (1)
{
/* Requesting to go to a specified position. */
- motor->GoTo(ROUND_ANGLE_STEPS >> 1);
+ motor->GoTo(MOTOR_STEPS >> 1);
/* Waiting while the motor is active. */
motor->WaitWhileActive();
/* Requesting to go to a specified position. */
- motor->GoTo(- (ROUND_ANGLE_STEPS >> 1));
+ motor->GoTo(- (MOTOR_STEPS >> 1));
/* Waiting while the motor is active. */
motor->WaitWhileActive();