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: mbed mbed-rtos X_NUCLEO_IHM02A1
Diff: main.cpp
- Revision:
- 22:e81ccf73bc5d
- Parent:
- 18:591a007effc2
- Child:
- 23:073b26366d03
--- a/main.cpp Tue Sep 27 13:58:51 2016 +0000
+++ b/main.cpp Wed Mar 01 17:53:04 2017 +0000
@@ -70,8 +70,7 @@
X_NUCLEO_IHM02A1 *x_nucleo_ihm02a1;
/* Initialization parameters of the motors connected to the expansion board. */
-L6470_Init_t init[L6470DAISYCHAINSIZE] =
-{
+L6470_Init_t init[L6470DAISYCHAINSIZE] = {
/* First Motor. */
{
9.0, /* Motor supply voltage in V. */
@@ -261,8 +260,9 @@
/* Halving the microsteps. */
init[0].step_sel = (init[0].step_sel > 0 ? init[0].step_sel - 1 : init[0].step_sel);
- if (!motors[0]->SetStepMode((StepperMotor::step_mode_t) init[0].step_sel))
+ if (!motors[0]->SetStepMode((StepperMotor::step_mode_t) init[0].step_sel)) {
printf(" Step Mode not allowed.\r\n");
+ }
/* Waiting. */
wait_ms(DELAY_1);
@@ -316,8 +316,9 @@
printf("--> Running together for %d seconds.\r\n", DELAY_3 / 1000);
/* Preparing each motor to perform a run at a specified speed. */
- for (int m = 0; m < L6470DAISYCHAINSIZE; m++)
+ for (int m = 0; m < L6470DAISYCHAINSIZE; m++) {
motors[m]->PrepareRun(StepperMotor::BWD, 400);
+ }
/* Performing the action on each motor at the same time. */
x_nucleo_ihm02a1->PerformPreparedActions();
@@ -329,8 +330,9 @@
/*----- Increasing the speed while running. -----*/
/* Preparing each motor to perform a run at a specified speed. */
- for (int m = 0; m < L6470DAISYCHAINSIZE; m++)
+ for (int m = 0; m < L6470DAISYCHAINSIZE; m++) {
motors[m]->PrepareGetSpeed();
+ }
/* Performing the action on each motor at the same time. */
uint32_t* results = x_nucleo_ihm02a1->PerformPreparedActions();
@@ -342,8 +344,9 @@
printf("--> Doublig the speed while running again for %d seconds.\r\n", DELAY_3 / 1000);
/* Preparing each motor to perform a run at a specified speed. */
- for (int m = 0; m < L6470DAISYCHAINSIZE; m++)
+ for (int m = 0; m < L6470DAISYCHAINSIZE; m++) {
motors[m]->PrepareRun(StepperMotor::BWD, results[m] << 1);
+ }
/* Performing the action on each motor at the same time. */
results = x_nucleo_ihm02a1->PerformPreparedActions();
@@ -352,8 +355,9 @@
wait_ms(DELAY_3);
/* Preparing each motor to perform a run at a specified speed. */
- for (int m = 0; m < L6470DAISYCHAINSIZE; m++)
+ for (int m = 0; m < L6470DAISYCHAINSIZE; m++) {
motors[m]->PrepareGetSpeed();
+ }
/* Performing the action on each motor at the same time. */
results = x_nucleo_ihm02a1->PerformPreparedActions();
@@ -371,8 +375,9 @@
printf("--> Hard Stop.\r\n");
/* Preparing each motor to perform a hard stop. */
- for (int m = 0; m < L6470DAISYCHAINSIZE; m++)
+ for (int m = 0; m < L6470DAISYCHAINSIZE; m++) {
motors[m]->PrepareHardStop();
+ }
/* Performing the action on each motor at the same time. */
x_nucleo_ihm02a1->PerformPreparedActions();
@@ -387,9 +392,8 @@
printf("--> Doing a full revolution on each motor, one after the other.\r\n");
/* Doing a full revolution on each motor, one after the other. */
- for (int m = 0; m < L6470DAISYCHAINSIZE; m++)
- for (int i = 0; i < MPR_1; i++)
- {
+ for (int m = 0; m < L6470DAISYCHAINSIZE; m++) {
+ for (int i = 0; i < MPR_1; i++) {
/* Computing the number of steps. */
int steps = (int) (((int) init[m].fullstepsperrevolution * pow(2.0f, init[m].step_sel)) / MPR_1);
@@ -402,6 +406,7 @@
/* Waiting. */
wait_ms(DELAY_1);
}
+ }
/* Waiting. */
wait_ms(DELAY_2);
@@ -413,12 +418,13 @@
printf("--> High Impedance State.\r\n");
/* Preparing each motor to set High Impedance State. */
- for (int m = 0; m < L6470DAISYCHAINSIZE; m++)
+ for (int m = 0; m < L6470DAISYCHAINSIZE; m++) {
motors[m]->PrepareHardHiZ();
+ }
/* Performing the action on each motor at the same time. */
x_nucleo_ihm02a1->PerformPreparedActions();
/* Waiting. */
wait_ms(DELAY_2);
-}
\ No newline at end of file
+}