Library used to control ST Nucleo Evaluation board IHM12A1, based on STSPIN240 low voltage dual brush DC motor control driver.
Dependencies: ST_INTERFACES
Dependents: motori prova_motore SchedamotoriIHM12A1 prova_motore_duck ... more
Fork of X-NUCLEO-IHM12A1 by
Brush DC Motor Control Library
Library to handle the X-NUCLEO-IHM12A1 Motor Control Expansion Board based on the STSPIN240 component.
It allows a complete management of the STSPIN240, a low voltage dual brush DC driver, by providing a complete APIs.
The key features of the library are :
- Configuration of the STSPIN240 (bridges input and enabling signals)
- Flag interrupt handling (overcurrent and thermal alarms reporting)
- Handling of up to two bidirectional Brush DC motors
- Nucleo and expansion board configuration (GPIOs, PWMs, IRQs…)
To use the STSPIN240 driver library, the user first has to call its initialization method which:
- Setups the required GPIOs to handle the bridges enable pins, the FLAG interrupt which reports overcurrent detection or thermal protection.
- Loads the driver parameters with initial values configured by the user or with their predefined values from “stspin240_250_target_config.h”, in order to program the PWMs frequency of the bridges inputs, the number of brush DC motors.
Once the initialization is done, the user can modify the driver parameters by calling specific functions to change the numbers of motors or the PWMs frequency.
The user can also write callback functions and attach them to:
- The flag interrupt handler depending on the actions he wants to perform when an overcurrent or a thermal alarm is reported.
- The Error handler which is called by the library when it reports an error.
Then, the user can drive the different brush DC motors by requesting to run in a specified direction and by changing the maximal speed. When a motor is requested to run, the corresponding bridge is automatically enabled.
A motion command can be stopped at any moment:
- Either by a hard stop which immediately stops the motor.
- Or by a hardHiz command which immediately stops the motor and disables the bridge which is used by the motor.
The library also provides functions to disable or enable the bridges independently from the run or stop commands.
Arduino Connector Compatibility Warning
Using the X-NUCLEO-IHM12A1 expansion board with the NUCLEO-F429ZI
requires adopting the following patch:
- to connect with a wire the
PB_3
Nucleo pin to thePWMB
expansion board pin.
Board configuration for HelloWorld_IHM12A1 example
Revision 7:6efcc9b4d810, committed 2018-08-09
- Comitter:
- Davidroid
- Date:
- Thu Aug 09 15:00:43 2018 +0000
- Parent:
- 6:123d44b9fb9d
- Commit message:
- Update comment of STSpin240_250's class constructor
Changed in this revision
Components/STSpin240_250/STSpin240_250.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 123d44b9fb9d -r 6efcc9b4d810 Components/STSpin240_250/STSpin240_250.h --- a/Components/STSpin240_250/STSpin240_250.h Thu Aug 03 16:47:02 2017 +0000 +++ b/Components/STSpin240_250/STSpin240_250.h Thu Aug 09 15:00:43 2018 +0000 @@ -85,12 +85,21 @@ * @brief Constructor. * @param flag_and_enable_pin pin name of the EN pin of the component. * @param standby_reset_pin pin name of the STBY\RST pin of the component. - * @param pwmA_pin pin name for the PWM input for bridge A - * @param pwmB_pin pin name for the PWM input for bridge B - * @param dirA_pin pin name for the direction pinfor bridge A - * @param dirB_pin pin name for the direction pinfor bridge B + * @param dirA_pin pin name for the direction pin for bridge A. + * @param dirB_pin pin name for the direction pin for bridge B. + * @param pwmA_pin pin name for the PWM input for bridge A. + * @param pwmB_pin pin name for the PWM input for bridge B. + * @param pwmRef_pin pin name for the REF pin of the component. */ - STSpin240_250(PinName flag_and_enable_pin, PinName standby_reset_pin, PinName dirA_pin, PinName dirB_pin, PinName pwmA_pin, PinName pwmB_pin, PinName pwmRef_pin) : BDCMotor(), flag_and_enable(flag_and_enable_pin), standby_reset(standby_reset_pin), dirA(dirA_pin), dirB(dirB_pin), pwmA(pwmA_pin), pwmB(pwmB_pin), pwmRef(pwmRef_pin) + STSpin240_250(PinName flag_and_enable_pin, PinName standby_reset_pin, PinName dirA_pin, PinName dirB_pin, PinName pwmA_pin, PinName pwmB_pin, PinName pwmRef_pin) : + BDCMotor(), + flag_and_enable(flag_and_enable_pin), + standby_reset(standby_reset_pin), + dirA(dirA_pin), + dirB(dirB_pin), + pwmA(pwmA_pin), + pwmB(pwmB_pin), + pwmRef(pwmRef_pin) { /* Checking stackability. */ if (!(numberOfDevices < MAX_NUMBER_OF_DEVICES))