Motion control example for 3 motors.

Dependencies:   X_NUCLEO_IHM03A1 mbed

Fork of IHM03A1_ExampleFor3Motors by ST Expansion SW Team

This application provides an example of usage of three X-NUCLEO-IHM03A1 High Power Stepper Motor Control Expansion Boards.

It shows how to use three stepper motors connected to the three expansion boards by:

  • moving each motor independently;
  • moving several motors synchronously;
  • monitoring the status of the three motors;
  • handling interrupts triggered by all motor drivers;
  • getting and setting a motor driver parameter;
  • etc.

For the hardware configuration of the expansion boards, please refer to the X_NUCLEO_IHM03A1 home web page.

Revision:
1:1d98c151c8eb
Parent:
0:36024a9bd220
Child:
2:c29a38e427f6
--- a/main.cpp	Tue Apr 05 15:33:37 2016 +0000
+++ b/main.cpp	Thu Apr 07 16:19:01 2016 +0000
@@ -585,36 +585,36 @@
   WaitForAllDevicesNotBusy();
 
   /* Get acceleration, deceleration, Maxspeed and MinSpeed of motor 1*/
-  myMaxSpeed= motor1->GetParameter(POWERSTEP01_MAX_SPEED);
-  myAcceleration = motor1->GetParameter(POWERSTEP01_ACC);
-  myDeceleration = motor1->GetParameter(POWERSTEP01_DEC);
-  myMinSpeed  = motor1->GetParameter(POWERSTEP01_MIN_SPEED); 
+  myMaxSpeed= motor1->GetRawParameter(POWERSTEP01_MAX_SPEED);
+  myAcceleration = motor1->GetRawParameter(POWERSTEP01_ACC);
+  myDeceleration = motor1->GetRawParameter(POWERSTEP01_DEC);
+  myMinSpeed  = motor1->GetRawParameter(POWERSTEP01_MIN_SPEED); 
   
   /* Select 1/16 microstepping mode for motor 1 */
   printf("    Set 1/16 microstepping mode for motor1.\r\n"); 
-  motor1->SetStepMode(STEP_MODE_1_16);
+  motor1->SetStepMode(StepperMotor::STEP_MODE_1_16);
   
   /* Select 1/8 microstepping mode for motor 2 */
   printf("    Set 1/8 microstepping mode for motor2.\r\n"); 
-  motor2->SetStepMode(STEP_MODE_1_8);
+  motor2->SetStepMode(StepperMotor::STEP_MODE_1_8);
   
   /* Set speed and acceleration of motor 2 */
   /* Do not scale with microstepping mode */
-  motor2->SetParameter(POWERSTEP01_ACC, myAcceleration);
-  motor2->SetParameter(POWERSTEP01_DEC, myDeceleration);
-  motor2->SetParameter(POWERSTEP01_MIN_SPEED, myMinSpeed);
-  motor2->SetParameter(POWERSTEP01_MAX_SPEED, myMaxSpeed);
+  motor2->SetRawParameter(POWERSTEP01_ACC, myAcceleration);
+  motor2->SetRawParameter(POWERSTEP01_DEC, myDeceleration);
+  motor2->SetRawParameter(POWERSTEP01_MIN_SPEED, myMinSpeed);
+  motor2->SetRawParameter(POWERSTEP01_MAX_SPEED, myMaxSpeed);
   
   /* Select ful step mode for motor 3 */
   printf("    Set ful step mode for motor3.\r\n"); 
-  motor3->SetStepMode(STEP_MODE_FULL);
+  motor3->SetStepMode(StepperMotor::STEP_MODE_FULL);
 
   /* Set speed and acceleration of motor 3 */
   /* Do not scale with microstepping mode */
-  motor3->SetParameter(POWERSTEP01_ACC, myAcceleration);
-  motor3->SetParameter(POWERSTEP01_DEC, myDeceleration);
-  motor3->SetParameter(POWERSTEP01_MIN_SPEED, myMinSpeed);
-  motor3->SetParameter(POWERSTEP01_MAX_SPEED, myMaxSpeed);
+  motor3->SetRawParameter(POWERSTEP01_ACC, myAcceleration);
+  motor3->SetRawParameter(POWERSTEP01_DEC, myDeceleration);
+  motor3->SetRawParameter(POWERSTEP01_MIN_SPEED, myMinSpeed);
+  motor3->SetRawParameter(POWERSTEP01_MAX_SPEED, myMaxSpeed);
 
   /* Printing to the console. */
   printf("--> Infinite Loop...\r\n");