Test application for the STMicroelectronics X-NUCLEO-IHM01A1 Stepper Motor Control Expansion Board.
Dependencies: X_NUCLEO_IHM01A1
Fork of MotorControl_IHM01A1 by
Motor Control with the X-NUCLEO-IHM01A1 Expansion Board
This application provides a more complex example of usage of the X-NUCLEO-IHM01A1 Stepper Motor Control Expansion Board.
It shows how to use one stepper motor connected to the board, with an example of ISR and error handler, as well as an almost complete coverage of the available APIs, e.g.:
- moving the rotor to a specific position;
- moving the rotor for a certain amount of time;
- setting the speed value;
- setting the direction of rotation;
- changing the stepper motor mode;
- soft/hard stopping the rotor;
- powering off the power bridge.
Diff: main.cpp
- Revision:
- 22:ce8a202d67ac
- Parent:
- 20:bec1eba352a5
- Child:
- 25:205b3d09e64e
--- a/main.cpp Fri Apr 08 13:00:21 2016 +0000 +++ b/main.cpp Thu Sep 08 12:57:13 2016 +0000 @@ -55,10 +55,10 @@ /* Initialization parameters. */ L6474_Init_t init = { - 160, /* Acceleration rate in step/s2. Range: (0..+inf). */ - 160, /* Deceleration rate in step/s2. Range: (0..+inf). */ - 1600, /* Maximum speed in step/s. Range: (30..10000]. */ - 800, /* Minimum speed in step/s. Range: [30..10000). */ + 160, /* Acceleration rate in pps^2. Range: (0..+inf). */ + 160, /* Deceleration rate in pps^2. Range: (0..+inf). */ + 1600, /* Maximum speed in pps. Range: (30..10000]. */ + 800, /* Minimum speed in pps. Range: [30..10000). */ 250, /* Torque regulation current in mA. Range: 31.25mA to 4000mA. */ L6474_OCD_TH_750mA, /* Overcurrent threshold (OCD_TH register). */ L6474_CONFIG_OC_SD_ENABLE, /* Overcurrent shutwdown (OC_SD field of CONFIG register). */ @@ -327,7 +327,7 @@ /* Printing to the console. */ printf("--> Increasing the speed while running.\r\n"); - /* Increasing speed to 2400 step/s. */ + /* Increasing the speed. */ motor->SetMaxSpeed(2400); /* Waiting until delay has expired. */ @@ -345,7 +345,7 @@ /* Printing to the console. */ printf("--> Decreasing the speed while running.\r\n"); - /* Decreasing speed to 1200 step/s. */ + /* Decreasing the speed. */ motor->SetMaxSpeed(1200); /* Waiting until delay has expired. */ @@ -363,13 +363,13 @@ /* Printing to the console. */ printf("--> Increasing acceleration while running.\r\n"); - /* Increasing acceleration to 480 step/s^2. */ + /* Increasing the acceleration. */ motor->SetAcceleration(480); /* Waiting until delay has expired. */ wait_ms(5000); - /* Increasing speed to 2400 step/s. */ + /* Increasing the speed. */ motor->SetMaxSpeed(2400); /* Waiting until delay has expired. */ @@ -387,13 +387,13 @@ /* Printing to the console. */ printf("--> Increasing deceleration while running.\r\n"); - /* Increasing deceleration to 480 step/s^2. */ + /* Increasing the deceleration. */ motor->SetDeceleration(480); /* Waiting until delay has expired. */ wait_ms(5000); - /* Decreasing speed to 1200 step/s. */ + /* Decreasing the speed. */ motor->SetMaxSpeed(1200); /* Waiting until delay has expired. */