Prova con controller motore

Dependencies:   X-NUCLEO-IHM05A1 mbed

Fork of HelloWorld_IHM05A1 by ST

Committer:
pinofal
Date:
Thu Nov 08 12:20:59 2018 +0000
Revision:
9:900e18a2310b
Prova con controller motore

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pinofal 9:900e18a2310b 1 /**
pinofal 9:900e18a2310b 2 ******************************************************************************
pinofal 9:900e18a2310b 3 * @file main.cpp
pinofal 9:900e18a2310b 4 * @author IPC Rennes
pinofal 9:900e18a2310b 5 * @version V1.0.0
pinofal 9:900e18a2310b 6 * @date April 13th, 2016
pinofal 9:900e18a2310b 7 * @brief mbed simple application for the STMicroelectronics X-NUCLEO-IHM05A1
pinofal 9:900e18a2310b 8 * Motor Control Expansion Board: control of 1 motor.
pinofal 9:900e18a2310b 9 ******************************************************************************
pinofal 9:900e18a2310b 10 * @attention
pinofal 9:900e18a2310b 11 *
pinofal 9:900e18a2310b 12 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
pinofal 9:900e18a2310b 13 *
pinofal 9:900e18a2310b 14 * Redistribution and use in source and binary forms, with or without modification,
pinofal 9:900e18a2310b 15 * are permitted provided that the following conditions are met:
pinofal 9:900e18a2310b 16 * 1. Redistributions of source code must retain the above copyright notice,
pinofal 9:900e18a2310b 17 * this list of conditions and the following disclaimer.
pinofal 9:900e18a2310b 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
pinofal 9:900e18a2310b 19 * this list of conditions and the following disclaimer in the documentation
pinofal 9:900e18a2310b 20 * and/or other materials provided with the distribution.
pinofal 9:900e18a2310b 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
pinofal 9:900e18a2310b 22 * may be used to endorse or promote products derived from this software
pinofal 9:900e18a2310b 23 * without specific prior written permission.
pinofal 9:900e18a2310b 24 *
pinofal 9:900e18a2310b 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
pinofal 9:900e18a2310b 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
pinofal 9:900e18a2310b 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
pinofal 9:900e18a2310b 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
pinofal 9:900e18a2310b 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
pinofal 9:900e18a2310b 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
pinofal 9:900e18a2310b 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
pinofal 9:900e18a2310b 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
pinofal 9:900e18a2310b 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
pinofal 9:900e18a2310b 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
pinofal 9:900e18a2310b 35 *
pinofal 9:900e18a2310b 36 ******************************************************************************
pinofal 9:900e18a2310b 37 */
pinofal 9:900e18a2310b 38
pinofal 9:900e18a2310b 39 /* Includes ------------------------------------------------------------------*/
pinofal 9:900e18a2310b 40
pinofal 9:900e18a2310b 41 /* mbed specific header files. */
pinofal 9:900e18a2310b 42 #include "mbed.h"
pinofal 9:900e18a2310b 43
pinofal 9:900e18a2310b 44 /* Component specific header files. */
pinofal 9:900e18a2310b 45 #include "L6208.h"
pinofal 9:900e18a2310b 46
pinofal 9:900e18a2310b 47
pinofal 9:900e18a2310b 48
pinofal 9:900e18a2310b 49
pinofal 9:900e18a2310b 50 /* Definitions ---------------------------------------------------------------*/
pinofal 9:900e18a2310b 51 #ifdef TARGET_NUCLEO_F334R8
pinofal 9:900e18a2310b 52 #define VREFA_PWM_PIN D11
pinofal 9:900e18a2310b 53 #define VREFB_PWM_PIN D9
pinofal 9:900e18a2310b 54 #elif TARGET_NUCLEO_F302R8
pinofal 9:900e18a2310b 55 #define VREFA_PWM_PIN D11
pinofal 9:900e18a2310b 56 #define VREFB_PWM_PIN D15 /* HW mandatory patch: bridge manually D9 with D15 */
pinofal 9:900e18a2310b 57 #else
pinofal 9:900e18a2310b 58 #define VREFA_PWM_PIN D3
pinofal 9:900e18a2310b 59 #define VREFB_PWM_PIN D9
pinofal 9:900e18a2310b 60 #endif
pinofal 9:900e18a2310b 61
pinofal 9:900e18a2310b 62 Serial pc(SERIAL_TX, SERIAL_RX);
pinofal 9:900e18a2310b 63
pinofal 9:900e18a2310b 64 /* Variables -----------------------------------------------------------------*/
pinofal 9:900e18a2310b 65
pinofal 9:900e18a2310b 66 /* Initialization parameters of the motor connected to the expansion board. */
pinofal 9:900e18a2310b 67 l6208_init_t init =
pinofal 9:900e18a2310b 68 {
pinofal 9:900e18a2310b 69 1500, //Acceleration rate in step/s^2 or (1/16)th step/s^2 for microstep modes
pinofal 9:900e18a2310b 70 40, //Acceleration current torque in % (from 0 to 100)
pinofal 9:900e18a2310b 71 1500, //Deceleration rate in step/s^2 or (1/16)th step/s^2 for microstep modes
pinofal 9:900e18a2310b 72 30, //Deceleration current torque in % (from 0 to 100)
pinofal 9:900e18a2310b 73 1500, //Running speed in step/s or (1/16)th step/s for microstep modes
pinofal 9:900e18a2310b 74 50, //Running current torque in % (from 0 to 100)
pinofal 9:900e18a2310b 75 20, //Holding current torque in % (from 0 to 100)
pinofal 9:900e18a2310b 76 STEP_MODE_1_16, //Step mode via enum motorStepMode_t
pinofal 9:900e18a2310b 77 FAST_DECAY, //Decay mode via enum motorDecayMode_t
pinofal 9:900e18a2310b 78 0, //Dwelling time in ms
pinofal 9:900e18a2310b 79 FALSE, //Automatic HIZ STOP
pinofal 9:900e18a2310b 80 100000 //VREFA and VREFB PWM frequency (Hz)
pinofal 9:900e18a2310b 81 };
pinofal 9:900e18a2310b 82
pinofal 9:900e18a2310b 83 /* Motor Control Component. */
pinofal 9:900e18a2310b 84 L6208 *motor;
pinofal 9:900e18a2310b 85
pinofal 9:900e18a2310b 86 /* Functions -----------------------------------------------------------------*/
pinofal 9:900e18a2310b 87
pinofal 9:900e18a2310b 88 /**
pinofal 9:900e18a2310b 89 * @brief This is an example of user handler for the flag interrupt.
pinofal 9:900e18a2310b 90 * @param None
pinofal 9:900e18a2310b 91 * @retval None
pinofal 9:900e18a2310b 92 * @note If needed, implement it, and then attach and enable it:
pinofal 9:900e18a2310b 93 * + motor->attach_flag_irq(&my_flag_irq_handler);
pinofal 9:900e18a2310b 94 * + motor->enable_flag_irq();
pinofal 9:900e18a2310b 95 * To disable it:
pinofal 9:900e18a2310b 96 * + motor->DisbleFlagIRQ();
pinofal 9:900e18a2310b 97 */
pinofal 9:900e18a2310b 98 void my_flag_irq_handler(void)
pinofal 9:900e18a2310b 99 {
pinofal 9:900e18a2310b 100 pc.printf(" WARNING: \"FLAG\" interrupt triggered:\r\n");
pinofal 9:900e18a2310b 101 motor->disable();
pinofal 9:900e18a2310b 102 pc.printf(" Motor disabled.\r\n\n");
pinofal 9:900e18a2310b 103 }
pinofal 9:900e18a2310b 104
pinofal 9:900e18a2310b 105 /**
pinofal 9:900e18a2310b 106 * @brief This is an example of error handler.
pinofal 9:900e18a2310b 107 * @param[in] error Number of the error
pinofal 9:900e18a2310b 108 * @retval None
pinofal 9:900e18a2310b 109 * @note If needed, implement it, and then attach it:
pinofal 9:900e18a2310b 110 * + motor->attach_error_handler(&my_error_handler);
pinofal 9:900e18a2310b 111 */
pinofal 9:900e18a2310b 112 void my_error_handler(uint16_t error)
pinofal 9:900e18a2310b 113 {
pinofal 9:900e18a2310b 114 /* Printing to the console. */
pinofal 9:900e18a2310b 115 pc.printf("Error %d detected\r\n\n", error);
pinofal 9:900e18a2310b 116
pinofal 9:900e18a2310b 117 /* Infinite loop */
pinofal 9:900e18a2310b 118 while (true) {
pinofal 9:900e18a2310b 119 }
pinofal 9:900e18a2310b 120 }
pinofal 9:900e18a2310b 121
pinofal 9:900e18a2310b 122 /* Main ----------------------------------------------------------------------*/
pinofal 9:900e18a2310b 123
pinofal 9:900e18a2310b 124 int main()
pinofal 9:900e18a2310b 125 {
pinofal 9:900e18a2310b 126 // configura velocità della comunicazione seriale su USB-VirtualCom e invia messaggio di benvenuto
pinofal 9:900e18a2310b 127 pc.baud(921600); //921600 bps
pinofal 9:900e18a2310b 128 //pc.baud(9600); //256000 bps
pinofal 9:900e18a2310b 129 pc.printf("*** Test Motor ***\n\r");
pinofal 9:900e18a2310b 130
pinofal 9:900e18a2310b 131 /* Printing to the console. */
pinofal 9:900e18a2310b 132 pc.printf("STARTING MAIN PROGRAM\r\n");
pinofal 9:900e18a2310b 133 pc.printf(" Reminder:\r\n");
pinofal 9:900e18a2310b 134 pc.printf(" The position unit is in agreement to the step mode.\r\n");
pinofal 9:900e18a2310b 135 pc.printf(" The speed, acceleration or deceleration unit depend on the step mode:\r\n");
pinofal 9:900e18a2310b 136 pc.printf(" - For normal mode and half step mode, the unit is steps/s or /s^2.\r\n");
pinofal 9:900e18a2310b 137 pc.printf(" - For microstep modes, the unit is (1/16)steps/s or /s^2.\r\n");
pinofal 9:900e18a2310b 138
pinofal 9:900e18a2310b 139 //----- Initialization
pinofal 9:900e18a2310b 140 /* Initializing Motor Control Component. */
pinofal 9:900e18a2310b 141 motor = new L6208(D2, D8, D7, D4, D5, D6, VREFA_PWM_PIN, VREFB_PWM_PIN);
pinofal 9:900e18a2310b 142 if (motor->init(&init) != COMPONENT_OK) {
pinofal 9:900e18a2310b 143 exit(EXIT_FAILURE);
pinofal 9:900e18a2310b 144 }
pinofal 9:900e18a2310b 145
pinofal 9:900e18a2310b 146 /* Attaching and enabling an interrupt handler. */
pinofal 9:900e18a2310b 147 motor->attach_flag_irq(&my_flag_irq_handler);
pinofal 9:900e18a2310b 148 motor->enable_flag_irq();
pinofal 9:900e18a2310b 149
pinofal 9:900e18a2310b 150 /* Attaching an error handler */
pinofal 9:900e18a2310b 151 motor->attach_error_handler(&my_error_handler);
pinofal 9:900e18a2310b 152
pinofal 9:900e18a2310b 153 /* Printing to the console. */
pinofal 9:900e18a2310b 154 pc.printf("Motor Control Application Example for 1 Motor\r\n");
pinofal 9:900e18a2310b 155
pinofal 9:900e18a2310b 156 //----- run the motor BACKWARD
pinofal 9:900e18a2310b 157 pc.printf("--> Running the motor backward.\r\n");
pinofal 9:900e18a2310b 158 motor->run(StepperMotor::BWD);
pinofal 9:900e18a2310b 159
pinofal 9:900e18a2310b 160 while (motor->get_status()!=STEADY) {
pinofal 9:900e18a2310b 161 /* Print reached speed to the console in step/s or microsteps/s */
pinofal 9:900e18a2310b 162 pc.printf(" Reached Speed: %d microstep/s.\r\n", motor->get_speed());
pinofal 9:900e18a2310b 163 wait_ms(50);
pinofal 9:900e18a2310b 164 }
pinofal 9:900e18a2310b 165 pc.printf(" Reached Speed: %d microstep/s.\r\n", motor->get_speed());
pinofal 9:900e18a2310b 166
pinofal 9:900e18a2310b 167 /* Wait for 1 second */
pinofal 9:900e18a2310b 168 wait_ms(1000);
pinofal 9:900e18a2310b 169
pinofal 9:900e18a2310b 170 //----- Decrease speed while running to one quarter of the previous speed
pinofal 9:900e18a2310b 171 motor->set_max_speed(motor->get_speed()>>2);
pinofal 9:900e18a2310b 172
pinofal 9:900e18a2310b 173 /* Wait until the motor starts decelerating */
pinofal 9:900e18a2310b 174 while (motor->get_status()==STEADY);
pinofal 9:900e18a2310b 175 /* Wait and print speed while the motor is not steady running */
pinofal 9:900e18a2310b 176 while (motor->get_status()!=STEADY) {
pinofal 9:900e18a2310b 177 /* Print reached speed to the console in step/s or microsteps/s */
pinofal 9:900e18a2310b 178 pc.printf(" Reached Speed: %d microstep/s.\r\n", motor->get_speed());
pinofal 9:900e18a2310b 179 wait_ms(50);
pinofal 9:900e18a2310b 180 }
pinofal 9:900e18a2310b 181 pc.printf(" Reached Speed: %d microstep/s.\r\n", motor->get_speed());
pinofal 9:900e18a2310b 182
pinofal 9:900e18a2310b 183 /* Wait for 5 seconds */
pinofal 9:900e18a2310b 184 wait_ms(5000);
pinofal 9:900e18a2310b 185
pinofal 9:900e18a2310b 186 //----- Soft stop required while running
pinofal 9:900e18a2310b 187 pc.printf("--> Soft stop requested.\r\n");
pinofal 9:900e18a2310b 188 motor->soft_stop();
pinofal 9:900e18a2310b 189
pinofal 9:900e18a2310b 190 /* Wait for the motor of device ends moving */
pinofal 9:900e18a2310b 191 motor->wait_while_active();
pinofal 9:900e18a2310b 192
pinofal 9:900e18a2310b 193 /* Wait for 2 seconds */
pinofal 9:900e18a2310b 194 wait_ms(2000);
pinofal 9:900e18a2310b 195
pinofal 9:900e18a2310b 196 //----- Change step mode to full step mode
pinofal 9:900e18a2310b 197 motor->set_step_mode(StepperMotor::STEP_MODE_FULL);
pinofal 9:900e18a2310b 198 pc.printf(" Motor step mode: %d (0:FS, 1:1/2, 2:1/4, 3:1/8, 4:1/16).\r\n", motor->get_step_mode());
pinofal 9:900e18a2310b 199
pinofal 9:900e18a2310b 200 /* Get current position of device and print to the console */
pinofal 9:900e18a2310b 201 pc.printf(" Position: %d.\r\n", motor->get_position());
pinofal 9:900e18a2310b 202
pinofal 9:900e18a2310b 203 /* Set speed, acceleration and deceleration to scale with normal mode */
pinofal 9:900e18a2310b 204 motor->set_max_speed(init.maxSpeedSps>>4);
pinofal 9:900e18a2310b 205 motor->set_acceleration(motor->get_acceleration()>>4);
pinofal 9:900e18a2310b 206 motor->set_deceleration(motor->get_deceleration()>>4);
pinofal 9:900e18a2310b 207 /* Print parameters to the console */
pinofal 9:900e18a2310b 208 pc.printf(" Motor Max Speed: %d step/s.\r\n", motor->get_max_speed());
pinofal 9:900e18a2310b 209 pc.printf(" Motor Min Speed: %d step/s.\r\n", motor->get_min_speed());
pinofal 9:900e18a2310b 210 pc.printf(" Motor Acceleration: %d step/s.\r\n", motor->get_acceleration());
pinofal 9:900e18a2310b 211 pc.printf(" Motor Deceleration: %d step/s.\r\n", motor->get_deceleration());
pinofal 9:900e18a2310b 212
pinofal 9:900e18a2310b 213 //----- move of 200 steps in the FW direction
pinofal 9:900e18a2310b 214 pc.printf("--> Moving forward 200 steps.\r\n");
pinofal 9:900e18a2310b 215 motor->move(StepperMotor::FWD, 200);
pinofal 9:900e18a2310b 216
pinofal 9:900e18a2310b 217 /* Waiting while the motor is active. */
pinofal 9:900e18a2310b 218 motor->wait_while_active();
pinofal 9:900e18a2310b 219
pinofal 9:900e18a2310b 220 /* Get current position of device and print to the console */
pinofal 9:900e18a2310b 221 pc.printf(" Position: %d.\r\n", motor->get_position());
pinofal 9:900e18a2310b 222
pinofal 9:900e18a2310b 223 /* Disable the power bridges */
pinofal 9:900e18a2310b 224 motor->disable();
pinofal 9:900e18a2310b 225
pinofal 9:900e18a2310b 226 /* Check that the power bridges are actually disabled */
pinofal 9:900e18a2310b 227 if (motor->check_status_hw()!=0) {
pinofal 9:900e18a2310b 228 pc.printf(" Motor driver disabled.\r\n");
pinofal 9:900e18a2310b 229 } else {
pinofal 9:900e18a2310b 230 pc.printf(" Failed to disable the motor driver.\r\n");
pinofal 9:900e18a2310b 231 }
pinofal 9:900e18a2310b 232
pinofal 9:900e18a2310b 233 /* Wait for 2 seconds */
pinofal 9:900e18a2310b 234 wait_ms(2000);
pinofal 9:900e18a2310b 235
pinofal 9:900e18a2310b 236 //----- Change step mode to 1/4 microstepping mode
pinofal 9:900e18a2310b 237 motor->set_step_mode(StepperMotor::STEP_MODE_1_4);
pinofal 9:900e18a2310b 238 pc.printf(" Motor step mode: %d (0:FS, 1:1/2, 2:1/4, 3:1/8, 4:1/16).\r\n", motor->get_step_mode());
pinofal 9:900e18a2310b 239
pinofal 9:900e18a2310b 240 /* Get current position of device and print to the console */
pinofal 9:900e18a2310b 241 pc.printf(" Position: %d.\r\n", motor->get_position());
pinofal 9:900e18a2310b 242
pinofal 9:900e18a2310b 243 /* Set speed, acceleration and deceleration to scale with microstep mode */
pinofal 9:900e18a2310b 244 motor->set_max_speed(motor->get_max_speed()<<4);
pinofal 9:900e18a2310b 245 motor->set_acceleration(motor->get_acceleration()<<4);
pinofal 9:900e18a2310b 246 motor->set_deceleration(motor->get_deceleration()<<4);
pinofal 9:900e18a2310b 247 /* Print parameters to the console */
pinofal 9:900e18a2310b 248 pc.printf(" Motor Max Speed: %d step/s.\r\n", motor->get_max_speed());
pinofal 9:900e18a2310b 249 pc.printf(" Motor Min Speed: %d step/s.\r\n", motor->get_min_speed());
pinofal 9:900e18a2310b 250 pc.printf(" Motor Acceleration: %d step/s.\r\n", motor->get_acceleration());
pinofal 9:900e18a2310b 251 pc.printf(" Motor Deceleration: %d step/s.\r\n", motor->get_deceleration());
pinofal 9:900e18a2310b 252
pinofal 9:900e18a2310b 253 /* Request to go position 800 (quarter steps) */
pinofal 9:900e18a2310b 254 motor->go_to(800);
pinofal 9:900e18a2310b 255
pinofal 9:900e18a2310b 256 /* Wait for the motor ends moving */
pinofal 9:900e18a2310b 257 motor->wait_while_active();
pinofal 9:900e18a2310b 258
pinofal 9:900e18a2310b 259 /* Get current position of device and print to the console */
pinofal 9:900e18a2310b 260 pc.printf(" Position: %d.\r\n", motor->get_position());
pinofal 9:900e18a2310b 261
pinofal 9:900e18a2310b 262 /* Wait for 2 seconds */
pinofal 9:900e18a2310b 263 wait_ms(2000);
pinofal 9:900e18a2310b 264
pinofal 9:900e18a2310b 265 //----- Restore step mode to its initialization value
pinofal 9:900e18a2310b 266 motor->set_step_mode((StepperMotor::step_mode_t)init.stepMode);
pinofal 9:900e18a2310b 267 pc.printf(" Motor step mode: %d (0:FS, 1:1/2, 2:1/4, 3:1/8, 4:1/16).\r\n", motor->get_step_mode());
pinofal 9:900e18a2310b 268
pinofal 9:900e18a2310b 269 /* Get current position of device and print to the console */
pinofal 9:900e18a2310b 270 pc.printf(" Position: %d.\r\n", motor->get_position());
pinofal 9:900e18a2310b 271
pinofal 9:900e18a2310b 272 //----- Change decay mode
pinofal 9:900e18a2310b 273 motor->set_decay_mode(SLOW_DECAY);
pinofal 9:900e18a2310b 274 pc.printf(" Motor decay mode: %d (0:slow decay, 1:fast decay).\r\n", motor->get_decay_mode());
pinofal 9:900e18a2310b 275
pinofal 9:900e18a2310b 276 //----- Go to position -6400
pinofal 9:900e18a2310b 277 pc.printf("--> Go to position -6400 steps.\r\n");
pinofal 9:900e18a2310b 278 motor->go_to(-6400);
pinofal 9:900e18a2310b 279
pinofal 9:900e18a2310b 280 /* Wait for the motor ends moving */
pinofal 9:900e18a2310b 281 motor->wait_while_active();
pinofal 9:900e18a2310b 282
pinofal 9:900e18a2310b 283 /* Get current position of device and print to the console */
pinofal 9:900e18a2310b 284 pc.printf(" Position: %d.\r\n", motor->get_position());
pinofal 9:900e18a2310b 285
pinofal 9:900e18a2310b 286 /* Wait for 2 seconds */
pinofal 9:900e18a2310b 287 wait_ms(2000);
pinofal 9:900e18a2310b 288
pinofal 9:900e18a2310b 289 //----- Restore decay mode to its initialization value
pinofal 9:900e18a2310b 290 motor->set_decay_mode(init.decayMode);
pinofal 9:900e18a2310b 291 pc.printf(" Motor decay mode: %d (0:slow decay, 1:fast decay).\r\n", motor->get_decay_mode());
pinofal 9:900e18a2310b 292
pinofal 9:900e18a2310b 293 //----- Go Home
pinofal 9:900e18a2310b 294 pc.printf("--> Go to home position.\r\n");
pinofal 9:900e18a2310b 295 motor->go_home();
pinofal 9:900e18a2310b 296
pinofal 9:900e18a2310b 297 /* Wait for the motor ends moving */
pinofal 9:900e18a2310b 298 motor->wait_while_active();
pinofal 9:900e18a2310b 299
pinofal 9:900e18a2310b 300 /* Wait for 1 second */
pinofal 9:900e18a2310b 301 wait_ms(1000);
pinofal 9:900e18a2310b 302
pinofal 9:900e18a2310b 303 /* Infinite Loop. */
pinofal 9:900e18a2310b 304 pc.printf("--> Infinite Loop...\r\n");
pinofal 9:900e18a2310b 305 //while (true) {
pinofal 9:900e18a2310b 306 int i;
pinofal 9:900e18a2310b 307 for (i = 0; i < 2; i++) {
pinofal 9:900e18a2310b 308 /* Request device to go position -3200 */
pinofal 9:900e18a2310b 309 motor->go_to(-3200);
pinofal 9:900e18a2310b 310
pinofal 9:900e18a2310b 311 /* Waiting while the motor is active. */
pinofal 9:900e18a2310b 312 motor->wait_while_active();
pinofal 9:900e18a2310b 313
pinofal 9:900e18a2310b 314 /* Request device to go position 3200 */
pinofal 9:900e18a2310b 315 motor->go_to(3200);
pinofal 9:900e18a2310b 316
pinofal 9:900e18a2310b 317 /* Waiting while the motor is active. */
pinofal 9:900e18a2310b 318 motor->wait_while_active();
pinofal 9:900e18a2310b 319 }
pinofal 9:900e18a2310b 320 }
pinofal 9:900e18a2310b 321
pinofal 9:900e18a2310b 322 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/