Test
Dependencies: X_NUCLEO_IHM02A1 mbed
Fork of HelloWorld_IHM02A1 by
main.cpp
00001 /** 00002 ****************************************************************************** 00003 * @file main.cpp 00004 * @author Davide Aliprandi, STMicroelectronics 00005 * @version V1.0.0 00006 * @date November 4th, 2015 00007 * @brief mbed test application for the STMicroelectronics X-NUCLEO-IHM02A1 00008 * Motor Control Expansion Board: control of 2 motors. 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00013 * 00014 * Redistribution and use in source and binary forms, with or without modification, 00015 * are permitted provided that the following conditions are met: 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 2. Redistributions in binary form must reproduce the above copyright notice, 00019 * this list of conditions and the following disclaimer in the documentation 00020 * and/or other materials provided with the distribution. 00021 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00022 * may be used to endorse or promote products derived from this software 00023 * without specific prior written permission. 00024 * 00025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00026 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00028 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00029 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00030 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00031 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00033 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00034 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 ****************************************************************************** 00037 */ 00038 00039 00040 /* Includes ------------------------------------------------------------------*/ 00041 00042 /* mbed specific header files. */ 00043 #include "mbed.h" 00044 00045 /* Helper header files. */ 00046 #include "DevSPI.h" 00047 00048 /* Expansion Board specific header files. */ 00049 #include "x_nucleo_ihm02a1_class.h" 00050 00051 /* String libraries for splitting commands*/ 00052 #include <string.h> 00053 00054 /* Definitions ---------------------------------------------------------------*/ 00055 00056 /* Number of movements per revolution. */ 00057 #define MPR_1 4 00058 00059 /* Number of steps. */ 00060 #define STEPS_1 (200 * 128) /* 1 revolution given a 400 steps motor configured at 1/128 microstep mode. */ 00061 #define STEPS_2 (STEPS_1 * 2) 00062 00063 /* Delay in milliseconds. */ 00064 #define DELAY_1 1000 00065 #define DELAY_2 2000 00066 #define DELAY_3 5000 00067 00068 00069 /* Variables -----------------------------------------------------------------*/ 00070 00071 /* Serial port to USB*/ 00072 Serial pc(USBTX,USBRX);//tx, rx 00073 00074 /* Motor Control Expansion Board. */ 00075 X_NUCLEO_IHM02A1 *x_nucleo_ihm02a1; 00076 00077 /* Initialization parameters of the motors connected to the expansion board. */ 00078 L6470_Init_t init[L6470DAISYCHAINSIZE] = 00079 { 00080 /* First Motor. */ 00081 { 00082 12.0, /* Motor supply voltage in V. */ 00083 200, /* Min number of steps per revolution for the motor. */ 00084 0.5, /* Max motor phase voltage in A. */ 00085 5.06, /* Max motor phase voltage in V. */ 00086 200.0, /* Motor initial speed [step/s]. */ 00087 300.0, /* Motor acceleration [step/s^2] (comment for infinite acceleration mode). */ 00088 300.0, /* Motor deceleration [step/s^2] (comment for infinite deceleration mode). */ 00089 400.0, /* Motor maximum speed [step/s]. */ 00090 0.0, /* Motor minimum speed [step/s]. */ 00091 800, /* Motor full-step speed threshold [step/s]. */ 00092 3.06, /* Holding kval [V]. */ 00093 3.06, /* Constant speed kval [V]. */ 00094 3.06, /* Acceleration starting kval [V]. */ 00095 3.06, /* Deceleration starting kval [V]. */ 00096 61.52, /* Intersect speed for bemf compensation curve slope changing [step/s]. */ 00097 392.1569e-6, /* Start slope [s/step]. */ 00098 643.1372e-6, /* Acceleration final slope [s/step]. */ 00099 643.1372e-6, /* Deceleration final slope [s/step]. */ 00100 0, /* Thermal compensation factor (range [0, 15]). */ 00101 3.06 * 1000 * 1.10, /* Ocd threshold [ma] (range [375 ma, 6000 ma]). */ 00102 3.06 * 1000 * 1.00, /* Stall threshold [ma] (range [31.25 ma, 4000 ma]). */ 00103 StepperMotor::STEP_MODE_1_128, /* Step mode selection. */ 00104 0xFF, /* Alarm conditions enable. */ 00105 0x2E88 /* Ic configuration. */ 00106 }, 00107 00108 /* Second Motor. */ 00109 { 00110 12.0, /* Motor supply voltage in V. */ 00111 200, /* Min number of steps per revolution for the motor. */ 00112 0.5, /* Max motor phase voltage in A. */ 00113 5.06, /* Max motor phase voltage in V. */ 00114 200.0, /* Motor initial speed [step/s]. */ 00115 300.0, /* Motor acceleration [step/s^2] (comment for infinite acceleration mode). */ 00116 300.0, /* Motor deceleration [step/s^2] (comment for infinite deceleration mode). */ 00117 400.0, /* Motor maximum speed [step/s]. */ 00118 0.0, /* Motor minimum speed [step/s]. */ 00119 800, /* Motor full-step speed threshold [step/s]. */ 00120 3.06, /* Holding kval [V]. */ 00121 3.06, /* Constant speed kval [V]. */ 00122 3.06, /* Acceleration starting kval [V]. */ 00123 3.06, /* Deceleration starting kval [V]. */ 00124 61.52, /* Intersect speed for bemf compensation curve slope changing [step/s]. */ 00125 392.1569e-6, /* Start slope [s/step]. */ 00126 643.1372e-6, /* Acceleration final slope [s/step]. */ 00127 643.1372e-6, /* Deceleration final slope [s/step]. */ 00128 0, /* Thermal compensation factor (range [0, 15]). */ 00129 3.06 * 1000 * 1.10, /* Ocd threshold [ma] (range [375 ma, 6000 ma]). */ 00130 3.06 * 1000 * 1.00, /* Stall threshold [ma] (range [31.25 ma, 4000 ma]). */ 00131 StepperMotor::STEP_MODE_1_128, /* Step mode selection. */ 00132 0xFF, /* Alarm conditions enable. */ 00133 0x2E88 /* Ic configuration. */ 00134 } 00135 }; 00136 00137 DigitalIn enable(PA_8); 00138 /* Building a list of motor control components. */ 00139 //L6470 **motors = x_nucleo_ihm02a1->GetComponents(); 00140 L6470 **motors; 00141 00142 void highZ(){ 00143 /* Preparing each motor to set High Impedance State. */ 00144 for (int m = 0; m < L6470DAISYCHAINSIZE; m++) 00145 motors[m]->PrepareHardHiZ(); 00146 00147 /* Performing the action on each motor at the same time. */ 00148 x_nucleo_ihm02a1->PerformPreparedActions(); 00149 } 00150 00151 void hardStop(int motor){ 00152 // /*----- Hard Stop. -----*/ 00153 // 00154 /* Printing to the console. */ 00155 // pc.printf("--> Hard Stop.\r\n"); 00156 00157 /* Preparing each motor to perform a hard stop. */ 00158 // for (int m = 0; m < L6470DAISYCHAINSIZE; m++) 00159 motors[motor]->PrepareHardStop(); 00160 00161 /* Performing the action on each motor at the same time. */ 00162 x_nucleo_ihm02a1->PerformPreparedActions(); 00163 00164 highZ(); 00165 /* Waiting. */ 00166 // wait_ms(DELAY_2); 00167 } 00168 00169 void stopAllMotors(){ 00170 /* Preparing each motor to perform a hard stop. */ 00171 for (int m = 0; m < L6470DAISYCHAINSIZE; m++) 00172 motors[m]->PrepareHardStop(); 00173 00174 /* Performing the action on each motor at the same time. */ 00175 x_nucleo_ihm02a1->PerformPreparedActions(); 00176 00177 highZ(); 00178 } 00179 00180 void setHome(int motor){ 00181 motors[motor]->SetHome(); 00182 } 00183 00184 int getPosition(int motor){ 00185 int position = motors[motor]->GetPosition(); 00186 return position; 00187 } 00188 00189 void moveSteps(int motor, int steps){ 00190 00191 if(steps < 0) 00192 motors[motor]->Move(StepperMotor::BWD, steps*-1); 00193 else 00194 motors[motor]->Move(StepperMotor::FWD, steps); 00195 motors[motor]->WaitWhileActive(); 00196 hardStop(motor); 00197 } 00198 00199 void runAtSpeed(int motor, int speed){ 00200 if(speed < 0) 00201 motors[motor]->PrepareRun(StepperMotor::BWD, speed*-1); 00202 else if(speed > 0) 00203 motors[motor]->PrepareRun(StepperMotor::FWD, speed); 00204 else{ 00205 hardStop(motor); 00206 return; 00207 } 00208 /* Performing the action on each motor at the same time. */ 00209 x_nucleo_ihm02a1->PerformPreparedActions(); 00210 } 00211 00212 void moveInSync(int steps){ 00213 if(steps < 0){ 00214 motors[0]->PrepareMove(StepperMotor::BWD, steps*-1); 00215 motors[1]->PrepareMove(StepperMotor::BWD, steps*-1); 00216 } 00217 else if(steps > 0){ 00218 motors[0]->PrepareMove(StepperMotor::FWD, steps); 00219 motors[1]->PrepareMove(StepperMotor::FWD, steps); 00220 } 00221 x_nucleo_ihm02a1->PerformPreparedActions(); 00222 motors[0]->WaitWhileActive(); 00223 motors[1]->WaitWhileActive(); 00224 } 00225 00226 void goXRHome(int speed){ 00227 //while not pushing button move motor to the left? 00228 motors[0]->PrepareRun(StepperMotor::BWD, speed); 00229 motors[1]->PrepareRun(StepperMotor::BWD, speed); 00230 00231 x_nucleo_ihm02a1->PerformPreparedActions(); 00232 00233 // while( 00234 wait_ms(5000); 00235 00236 stopAllMotors(); 00237 } 00238 00239 void goHome(int motor, int speed){ 00240 //while not pushing button move motor to the left? 00241 motors[motor]->PrepareRun(StepperMotor::BWD, speed); 00242 00243 x_nucleo_ihm02a1->PerformPreparedActions(); 00244 00245 // while( 00246 wait_ms(5000); 00247 00248 stopAllMotors(); 00249 } 00250 00251 void readSerial(){ 00252 char rx_line[10]; 00253 // while(pc.readable()){ 00254 pc.scanf("%s", rx_line); 00255 //pc.printf("Spoken %s \r\n", rx_line); 00256 00257 char cmd[10], cmdv[10], cmdv2[10]; 00258 int values = sscanf(rx_line, "%[^','],%[^','],%s",cmd, cmdv, cmdv2); 00259 //pc.printf("%d\r\n",values); 00260 int cmd_value = atoi(cmdv); 00261 int cmd_value2 = atoi(cmdv2); 00262 //pc.printf("%s\r\n%d\r\n%d\r\n", cmd, cmd_value, cmd_value2); 00263 00264 char c = cmd[0]; 00265 //pc.printf("%c", c); 00266 int pos; 00267 int pos2; 00268 switch(c){ 00269 case 'a': 00270 00271 return; 00272 case 'b': 00273 //set home 00274 setHome(cmd_value); 00275 pos = getPosition(cmd_value); 00276 pc.printf("%c,%d,%d\r\n",c,cmd_value,pos); 00277 return; 00278 case 'c': 00279 //get position 00280 pos = getPosition(cmd_value); 00281 pc.printf("%c,%d,%d\r\n",c,cmd_value,pos); 00282 return; 00283 case 'd': 00284 00285 break; 00286 case 'e': 00287 //move steps 00288 moveSteps(cmd_value, cmd_value2); 00289 pos = getPosition(cmd_value); 00290 pc.printf("%c,%d,%d\r\n",c,cmd_value,pos); 00291 return; 00292 case 'f': 00293 //run at a given speed or change to run until hit bump 00294 runAtSpeed(cmd_value, cmd_value2); 00295 break; 00296 case 'g': 00297 //Halt 00298 stopAllMotors(); 00299 break; 00300 case 'h': 00301 //move X to home (and R cause connected) 00302 goXRHome(cmd_value2); 00303 pos = getPosition(0); 00304 pos2 = getPosition(1); 00305 pc.printf("%c,%d,%d\r\n",c,pos,pos2); 00306 return; 00307 case 'i': 00308 //move X numebr of steps and R cause connected 00309 moveInSync(cmd_value); 00310 pos = getPosition(0); 00311 pos2 = getPosition(1); 00312 pc.printf("%c,%d,%d\r\n",c,pos,pos2); 00313 return; 00314 case 'j': 00315 //go home 00316 goHome(cmd_value, cmd_value2); 00317 pos = getPosition(cmd_value); 00318 pc.printf("%c,%d,%d\r\n",c,cmd_value,pos); 00319 return; 00320 default: 00321 //N/A command 00322 pc.printf("Do not understand commands: %s with value %d\r\n", cmd, cmd_value); 00323 return; 00324 } 00325 pc.printf("complete\r\n"); 00326 } 00327 00328 /* Main ----------------------------------------------------------------------*/ 00329 00330 int main () 00331 { 00332 /* Initializing SPI bus. */ 00333 DevSPI dev_spi(D11, D12, D13); 00334 00335 /* Initializing Motor Control Expansion Board. */ 00336 x_nucleo_ihm02a1 = new X_NUCLEO_IHM02A1(&init[0], &init[1], A4, A5, D4, A2, &dev_spi); 00337 00338 motors = x_nucleo_ihm02a1->GetComponents(); 00339 00340 pc.attach(readSerial); 00341 pc.printf("ready\r\n"); 00342 00343 while(1){ 00344 } 00345 00346 ///*----- Initialization. -----*/ 00347 // 00348 // /* Initializing SPI bus. */ 00349 // DevSPI dev_spi(D11, D12, D13); 00350 // 00351 // /* Initializing Motor Control Expansion Board. */ 00352 // x_nucleo_ihm02a1 = new X_NUCLEO_IHM02A1(&init[0], &init[1], A4, A5, D4, A2, &dev_spi); 00353 // 00354 // /* Building a list of motor control components. */ 00355 // L6470 **motors = x_nucleo_ihm02a1->GetComponents(); 00356 // 00357 // /* Printing to the console. */ 00358 // pc.printf("Motor Control Application Example for 2 Motors\r\n\n"); 00359 // 00360 // 00361 // /*----- Setting home and marke positions, getting positions, and going to positions. -----*/ 00362 // 00363 // /* Printing to the console. */ 00364 // pc.printf("--> Setting home position.\r\n"); 00365 // 00366 // /* Setting the home position. */ 00367 // motors[0]->SetHome(); 00368 // 00369 // /* Waiting. */ 00370 // wait_ms(DELAY_1); 00371 // 00372 // /* Getting the current position. */ 00373 // int position = motors[0]->GetPosition(); 00374 // 00375 // /* Printing to the console. */ 00376 // pc.printf("--> Getting the current position: %d\r\n", position); 00377 // 00378 // /* Waiting. */ 00379 // wait_ms(DELAY_1); 00380 // 00381 // /* Printing to the console. */ 00382 // pc.printf("--> Moving forward %d steps.\r\n", STEPS_1); 00383 // 00384 // /* Moving. */ 00385 // motors[0]->Move(StepperMotor::FWD, STEPS_1); 00386 // 00387 // /* Waiting while active. */ 00388 // motors[0]->WaitWhileActive(); 00389 // 00390 // /* Getting the current position. */ 00391 // position = motors[0]->GetPosition(); 00392 // 00393 // /* Printing to the console. */ 00394 // pc.printf("--> Getting the current position: %d\r\n", position); 00395 // 00396 // /* Printing to the console. */ 00397 // pc.printf("--> Marking the current position.\r\n"); 00398 // 00399 // /* Marking the current position. */ 00400 // motors[0]->SetMark(); 00401 // 00402 // /* Waiting. */ 00403 // wait_ms(DELAY_1); 00404 // 00405 // /* Printing to the console. */ 00406 // pc.printf("--> Moving backward %d steps.\r\n", STEPS_2); 00407 // 00408 // /* Moving. */ 00409 //motors[0]->Move(StepperMotor::BWD, STEPS_2); 00410 // 00411 // /* Waiting while active. */ 00412 // motors[0]->WaitWhileActive(); 00413 // 00414 // /* Waiting. */ 00415 // wait_ms(DELAY_1); 00416 // 00417 // /* Getting the current position. */ 00418 // position = motors[0]->GetPosition(); 00419 // 00420 // /* Printing to the console. */ 00421 // pc.printf("--> Getting the current position: %d\r\n", position); 00422 // 00423 // /* Waiting. */ 00424 // wait_ms(DELAY_1); 00425 // 00426 // /* Printing to the console. */ 00427 // pc.printf("--> Going to marked position.\r\n"); 00428 // 00429 // /* Going to marked position. */ 00430 // motors[0]->GoMark(); 00431 // 00432 // /* Waiting while active. */ 00433 // motors[0]->WaitWhileActive(); 00434 // 00435 // /* Waiting. */ 00436 // wait_ms(DELAY_1); 00437 // 00438 // /* Getting the current position. */ 00439 // position = motors[0]->GetPosition(); 00440 // 00441 // /* Printing to the console. */ 00442 // pc.printf("--> Getting the current position: %d\r\n", position); 00443 // 00444 // /* Waiting. */ 00445 // wait_ms(DELAY_1); 00446 // 00447 // /* Printing to the console. */ 00448 // pc.printf("--> Going to home position.\r\n"); 00449 // 00450 // /* Going to home position. */ 00451 // motors[0]->GoHome(); 00452 // 00453 // /* Waiting while active. */ 00454 // motors[0]->WaitWhileActive(); 00455 // 00456 // /* Waiting. */ 00457 // wait_ms(DELAY_1); 00458 // 00459 // /* Getting the current position. */ 00460 // position = motors[0]->GetPosition(); 00461 // 00462 // /* Printing to the console. */ 00463 // pc.printf("--> Getting the current position: %d\r\n", position); 00464 // 00465 // /* Waiting. */ 00466 // wait_ms(DELAY_1); 00467 // 00468 // /* Printing to the console. */ 00469 // pc.printf("--> Halving the microsteps.\r\n"); 00470 // 00471 // /* Halving the microsteps. */ 00472 // init[0].step_sel = (init[0].step_sel > 0 ? init[0].step_sel - 1 : init[0].step_sel); 00473 // if (!motors[0]->SetStepMode((StepperMotor::step_mode_t) init[0].step_sel)) 00474 // pc.printf(" Step Mode not allowed.\r\n"); 00475 // 00476 // /* Waiting. */ 00477 // wait_ms(DELAY_1); 00478 // 00479 // /* Printing to the console. */ 00480 // pc.printf("--> Setting home position.\r\n"); 00481 // 00482 // /* Setting the home position. */ 00483 // motors[0]->SetHome(); 00484 // 00485 // /* Waiting. */ 00486 // wait_ms(DELAY_1); 00487 // 00488 // /* Getting the current position. */ 00489 // position = motors[0]->GetPosition(); 00490 // 00491 // /* Printing to the console. */ 00492 // pc.printf("--> Getting the current position: %d\r\n", position); 00493 // 00494 // /* Waiting. */ 00495 // wait_ms(DELAY_1); 00496 // 00497 // /* Printing to the console. */ 00498 // pc.printf("--> Moving forward %d steps.\r\n", STEPS_1); 00499 // 00500 // /* Moving. */ 00501 // motors[0]->Move(StepperMotor::FWD, STEPS_1); 00502 // 00503 // /* Waiting while active. */ 00504 // motors[0]->WaitWhileActive(); 00505 // 00506 // /* Getting the current position. */ 00507 // position = motors[0]->GetPosition(); 00508 // 00509 // /* Printing to the console. */ 00510 // pc.printf("--> Getting the current position: %d\r\n", position); 00511 // 00512 // /* Printing to the console. */ 00513 // pc.printf("--> Marking the current position.\r\n"); 00514 // 00515 // /* Marking the current position. */ 00516 // motors[0]->SetMark(); 00517 // 00518 // /* Waiting. */ 00519 // wait_ms(DELAY_2); 00520 // 00521 // 00522 // /*----- Running together for a certain amount of time. -----*/ 00523 // 00524 // /* Printing to the console. */ 00525 // pc.printf("--> Running together for %d seconds.\r\n", DELAY_3 / 1000); 00526 // 00527 // /* Preparing each motor to perform a run at a specified speed. */ 00528 // for (int m = 0; m < L6470DAISYCHAINSIZE; m++) 00529 // motors[m]->PrepareRun(StepperMotor::BWD, 400); 00530 // 00531 // /* Performing the action on each motor at the same time. */ 00532 // x_nucleo_ihm02a1->PerformPreparedActions(); 00533 // 00534 // /* Waiting. */ 00535 // wait_ms(DELAY_3); 00536 // 00537 // 00538 // /*----- Increasing the speed while running. -----*/ 00539 // 00540 // /* Preparing each motor to perform a run at a specified speed. */ 00541 // for (int m = 0; m < L6470DAISYCHAINSIZE; m++) 00542 // motors[m]->PrepareGetSpeed(); 00543 // 00544 // /* Performing the action on each motor at the same time. */ 00545 // uint32_t* results = x_nucleo_ihm02a1->PerformPreparedActions(); 00546 // 00547 // /* Printing to the console. */ 00548 // pc.printf(" Speed: M1 %d, M2 %d.\r\n", results[0], results[1]); 00549 // 00550 // /* Printing to the console. */ 00551 // pc.printf("--> Doublig the speed while running again for %d seconds.\r\n", DELAY_3 / 1000); 00552 // 00553 // /* Preparing each motor to perform a run at a specified speed. */ 00554 // for (int m = 0; m < L6470DAISYCHAINSIZE; m++) 00555 // motors[m]->PrepareRun(StepperMotor::BWD, results[m] << 1); 00556 // 00557 // /* Performing the action on each motor at the same time. */ 00558 // results = x_nucleo_ihm02a1->PerformPreparedActions(); 00559 // 00560 // /* Waiting. */ 00561 // wait_ms(DELAY_3); 00562 // 00563 // /* Preparing each motor to perform a run at a specified speed. */ 00564 // for (int m = 0; m < L6470DAISYCHAINSIZE; m++) 00565 // motors[m]->PrepareGetSpeed(); 00566 // 00567 // /* Performing the action on each motor at the same time. */ 00568 // results = x_nucleo_ihm02a1->PerformPreparedActions(); 00569 // 00570 // /* Printing to the console. */ 00571 // pc.printf(" Speed: M1 %d, M2 %d.\r\n", results[0], results[1]); 00572 // 00573 // /* Waiting. */ 00574 // wait_ms(DELAY_1); 00575 // 00576 // 00577 // /*----- Hard Stop. -----*/ 00578 // 00579 // /* Printing to the console. */ 00580 // pc.printf("--> Hard Stop.\r\n"); 00581 // 00582 // /* Preparing each motor to perform a hard stop. */ 00583 // for (int m = 0; m < L6470DAISYCHAINSIZE; m++) 00584 // motors[m]->PrepareHardStop(); 00585 // 00586 // /* Performing the action on each motor at the same time. */ 00587 // x_nucleo_ihm02a1->PerformPreparedActions(); 00588 // 00589 // /* Waiting. */ 00590 // wait_ms(DELAY_2); 00591 // 00592 // 00593 // /*----- Doing a full revolution on each motor, one after the other. -----*/ 00594 // 00595 // /* Printing to the console. */ 00596 // pc.printf("--> Doing a full revolution on each motor, one after the other.\r\n"); 00597 // 00598 // /* Doing a full revolution on each motor, one after the other. */ 00599 // for (int m = 0; m < L6470DAISYCHAINSIZE; m++) 00600 // for (int i = 0; i < MPR_1; i++) 00601 // { 00602 // /* Computing the number of steps. */ 00603 // int steps = (int) (((int) init[m].fullstepsperrevolution * pow(2.0f, init[m].step_sel)) / MPR_1); 00604 // 00605 // /* Moving. */ 00606 // motors[m]->Move(StepperMotor::FWD, steps); 00607 // 00608 // /* Waiting while active. */ 00609 // motors[m]->WaitWhileActive(); 00610 // 00611 // /* Waiting. */ 00612 // wait_ms(DELAY_1); 00613 // } 00614 // 00615 // /* Waiting. */ 00616 // wait_ms(DELAY_2); 00617 // 00618 // 00619 // /*----- High Impedance State. -----*/ 00620 // 00621 // /* Printing to the console. */ 00622 // pc.printf("--> High Impedance State.\r\n"); 00623 // 00624 // /* Preparing each motor to set High Impedance State. */ 00625 // for (int m = 0; m < L6470DAISYCHAINSIZE; m++) 00626 // motors[m]->PrepareHardHiZ(); 00627 // 00628 // /* Performing the action on each motor at the same time. */ 00629 // x_nucleo_ihm02a1->PerformPreparedActions(); 00630 // 00631 // /* Waiting. */ 00632 // wait_ms(DELAY_2); 00633 }
Generated on Sun Jul 24 2022 03:55:19 by
1.7.2
