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_3Nucleo pin to thePWMBexpansion board pin.
Board configuration for HelloWorld_IHM12A1 example
Diff: Components/stspin240_250/stspin240_250_class.h
- Revision:
- 1:a68f20f0d233
- Parent:
- 0:13bc901c90aa
- Child:
- 2:232e0c730f59
--- a/Components/stspin240_250/stspin240_250_class.h Thu Apr 28 14:03:11 2016 +0000
+++ b/Components/stspin240_250/stspin240_250_class.h Tue Jun 14 12:24:23 2016 +0000
@@ -214,27 +214,7 @@
{
return (motorState_t) Stspin240_250_GetDeviceState(motorId);
}
-
- /**
- * @brief Getting the duty cycle of the PWM used for REF.
- * @param refId Id of the reference PWM signal.
- * @retval duty cycle in % (from 0 to 100)
- */
- virtual unsigned int GetRefPwmDc(unsigned int refId)
- {
- return (unsigned int) Stspin240_250_GetRefPwmDc(refId);
- }
-
- /**
- * @brief Getting the frequency of the PWM used for REF.
- * @param refId Id of the reference PWM signal.
- * @retval frequency in Hz.
- */
- virtual unsigned int GetRefPwmFreq(unsigned int refId)
- {
- return (unsigned int) Stspin240_250_GetRefPwmFreq(refId);
- }
-
+
/**
* @brief Getting the current speed in % of the specified motor.
* @param motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1).
@@ -292,34 +272,12 @@
* @param configuration. The bridge configuration.
* @retval None.
*/
- virtual void SetDualFullBridgeconfig(unsigned int configuration)
+ virtual void SetDualFullBridgeConfig(unsigned int configuration)
{
Stspin240_250_SetDualFullBridgeconfig(configuration);
}
/**
- * @brief Setting the duty cycle of the PWM used for REF.
- * @param refId Id of the reference PWM signal.
- * @param newDc new duty cycle from 0 to 100
- * @retval None.
- */
- virtual void SetRefPwmDc(unsigned int refId, unsigned int newDc)
- {
- Stspin240_250_SetRefPwmDc(refId, newDc);
- }
-
- /**
- * @brief Setting the frequency of the PWM used for REF.
- * @param refId Id of the reference PWM signal.
- * @param frequency in Hz.
- * @retval None.
- */
- virtual void SetRefPwmFreq(unsigned int refId, unsigned int frequency)
- {
- Stspin240_250_SetRefPwmFreq(refId, frequency);
- }
-
- /**
* @brief Setting the speed in %.
* @param motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1).
* @param speed The new speed in %.
@@ -365,6 +323,26 @@
}
/**
+ * @brief Getting the duty cycle of the PWM used for REF.
+ * @param refId Id of the reference PWM signal.
+ * @retval duty cycle in % (from 0 to 100)
+ */
+ virtual unsigned int GetRefPwmDc(unsigned int refId)
+ {
+ return (unsigned int) Stspin240_250_GetRefPwmDc(refId);
+ }
+
+ /**
+ * @brief Getting the frequency of the PWM used for REF.
+ * @param refId Id of the reference PWM signal.
+ * @retval frequency in Hz.
+ */
+ virtual unsigned int GetRefPwmFreq(unsigned int refId)
+ {
+ return (unsigned int) Stspin240_250_GetRefPwmFreq(refId);
+ }
+
+ /**
* @brief Releasing the reset (exiting standby mode).
* @param None.
* @retval None.
@@ -396,6 +374,28 @@
}
/**
+ * @brief Setting the duty cycle of the PWM used for REF.
+ * @param refId Id of the reference PWM signal.
+ * @param newDc new duty cycle from 0 to 100
+ * @retval None.
+ */
+ virtual void SetRefPwmDc(unsigned int refId, unsigned int newDc)
+ {
+ Stspin240_250_SetRefPwmDc(refId, newDc);
+ }
+
+ /**
+ * @brief Setting the frequency of the PWM used for REF.
+ * @param refId Id of the reference PWM signal.
+ * @param frequency in Hz.
+ * @retval None.
+ */
+ virtual void SetRefPwmFreq(unsigned int refId, unsigned int frequency)
+ {
+ Stspin240_250_SetRefPwmFreq(refId, frequency);
+ }
+
+ /**
* @brief Public static functions
*/
static uint8_t GetNbDevices(void)

X-NUCLEO-IHM12A1 Low Voltage Dual Brush DC Motor Driver