Library used to control ST Nucleo Evaluation board IHM04A1, based on L6206 motor control driver.

Dependencies:   ST_INTERFACES

Dependents:   HelloWorld_IHM04A1 RoboCane_Motore arm_dcmotor_can arm_linear_can_2 ... more

Fork of X_NUCLEO_IHM04A1 by ST Expansion SW Team

Motor Control Library

Library to handle the X-NUCLEO-IHM04A1 Motor Control Expansion Board based on the L6206 component.

It allows a complete management of the L6206 by providing a complete APIs.

The key features of the library are :

  • Configuration of the L6206 (bridges inputs and enabling signals, bridges paralleling)
  • FLAG interrupts handling (overcurrent and thermal alarms reporting)
  • Handling of up to two bidirectional Brush DC motors or up to 4 unidirectional Brush DC motors depending of the bridges paralleling configuration
  • Nucleo and expansion board configuration (GPIOs, PWMs, IRQs…)

To use the L6206 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 “l6206_target_config.h”, in order to program the PWMs frequency of the bridges inputs, the bridges paralleling configuration, the number and the type (bidirectional or unidirectional) of brush DC motors.

Once the initialization is done, the user can modify the driver parameters by calling specific functions to change the bridges paralleling configuration, types and 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-IHM04A1 expansion board with the NUCLEO-F429ZI requires adopting the following patch:

  • to connect with a wire the PB_4 Nucleo pin to the IN1A expansion board pin;
  • to connect with a wire the PC_7 Nucleo pin to the IN2A expansion board pin;
  • to connect with a wire the PA_15 Nucleo pin to the IN1B expansion board pin;
  • to connect with a wire the PB_3 Nucleo pin to the IN2B expansion board pin.


Board configuration for HelloWorld_IHM04A1 example

/media/uploads/brdirais/drive4brushdcmotor_ihm04a1.png

Committer:
brdirais
Date:
Tue May 03 11:16:57 2016 +0000
Revision:
0:2cb6ce8e07bd
Initial version of X-NUCLEO-IHM04A1 library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
brdirais 0:2cb6ce8e07bd 1 /**************************************************************************//**
brdirais 0:2cb6ce8e07bd 2 * @file L6206_target_config.h
brdirais 0:2cb6ce8e07bd 3 * @author IPC Rennes
brdirais 0:2cb6ce8e07bd 4 * @version V1.0.0
brdirais 0:2cb6ce8e07bd 5 * @date January 06, 2015
brdirais 0:2cb6ce8e07bd 6 * @brief Predefines values for the L6206 parameters
brdirais 0:2cb6ce8e07bd 7 * and for the devices parameters
brdirais 0:2cb6ce8e07bd 8 * @note (C) COPYRIGHT 2015 STMicroelectronics
brdirais 0:2cb6ce8e07bd 9 ******************************************************************************
brdirais 0:2cb6ce8e07bd 10 * @attention
brdirais 0:2cb6ce8e07bd 11 *
brdirais 0:2cb6ce8e07bd 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
brdirais 0:2cb6ce8e07bd 13 *
brdirais 0:2cb6ce8e07bd 14 * Redistribution and use in source and binary forms, with or without modification,
brdirais 0:2cb6ce8e07bd 15 * are permitted provided that the following conditions are met:
brdirais 0:2cb6ce8e07bd 16 * 1. Redistributions of source code must retain the above copyright notice,
brdirais 0:2cb6ce8e07bd 17 * this list of conditions and the following disclaimer.
brdirais 0:2cb6ce8e07bd 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
brdirais 0:2cb6ce8e07bd 19 * this list of conditions and the following disclaimer in the documentation
brdirais 0:2cb6ce8e07bd 20 * and/or other materials provided with the distribution.
brdirais 0:2cb6ce8e07bd 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
brdirais 0:2cb6ce8e07bd 22 * may be used to endorse or promote products derived from this software
brdirais 0:2cb6ce8e07bd 23 * without specific prior written permission.
brdirais 0:2cb6ce8e07bd 24 *
brdirais 0:2cb6ce8e07bd 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
brdirais 0:2cb6ce8e07bd 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
brdirais 0:2cb6ce8e07bd 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
brdirais 0:2cb6ce8e07bd 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
brdirais 0:2cb6ce8e07bd 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
brdirais 0:2cb6ce8e07bd 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
brdirais 0:2cb6ce8e07bd 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
brdirais 0:2cb6ce8e07bd 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
brdirais 0:2cb6ce8e07bd 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
brdirais 0:2cb6ce8e07bd 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
brdirais 0:2cb6ce8e07bd 35 *
brdirais 0:2cb6ce8e07bd 36 ******************************************************************************
brdirais 0:2cb6ce8e07bd 37 */
brdirais 0:2cb6ce8e07bd 38
brdirais 0:2cb6ce8e07bd 39 /* Define to prevent recursive inclusion -------------------------------------*/
brdirais 0:2cb6ce8e07bd 40 #ifndef __L6206_TARGET_CONFIG_H
brdirais 0:2cb6ce8e07bd 41 #define __L6206_TARGET_CONFIG_H
brdirais 0:2cb6ce8e07bd 42
brdirais 0:2cb6ce8e07bd 43 #ifdef __cplusplus
brdirais 0:2cb6ce8e07bd 44 extern "C" {
brdirais 0:2cb6ce8e07bd 45 #endif
brdirais 0:2cb6ce8e07bd 46
brdirais 0:2cb6ce8e07bd 47 /** @addtogroup BSP
brdirais 0:2cb6ce8e07bd 48 * @{
brdirais 0:2cb6ce8e07bd 49 */
brdirais 0:2cb6ce8e07bd 50
brdirais 0:2cb6ce8e07bd 51 /** @addtogroup L6474
brdirais 0:2cb6ce8e07bd 52 * @{
brdirais 0:2cb6ce8e07bd 53 */
brdirais 0:2cb6ce8e07bd 54
brdirais 0:2cb6ce8e07bd 55 /** @addtogroup L6206_Exported_Constants
brdirais 0:2cb6ce8e07bd 56 * @{
brdirais 0:2cb6ce8e07bd 57 */
brdirais 0:2cb6ce8e07bd 58
brdirais 0:2cb6ce8e07bd 59 /** @defgroup Predefined_L6206_Parameters_Values Predefined L6206 Parameters Values
brdirais 0:2cb6ce8e07bd 60 * @{
brdirais 0:2cb6ce8e07bd 61 */
brdirais 0:2cb6ce8e07bd 62
brdirais 0:2cb6ce8e07bd 63 /// The maximum number of L6206 devices
brdirais 0:2cb6ce8e07bd 64 #define MAX_NUMBER_OF_DEVICES (1)
brdirais 0:2cb6ce8e07bd 65
brdirais 0:2cb6ce8e07bd 66 /// The maximum number of BLDC motors connected to the L6206
brdirais 0:2cb6ce8e07bd 67 #define MAX_NUMBER_OF_BRUSH_DC_MOTORS (4)
brdirais 0:2cb6ce8e07bd 68
brdirais 0:2cb6ce8e07bd 69 /// Frequency of PWM of Input 1 Bridge A in Hz up to 100000Hz
brdirais 0:2cb6ce8e07bd 70 #define L6206_CONF_PARAM_FREQ_PWM1A (20000)
brdirais 0:2cb6ce8e07bd 71 /// Frequency of PWM of Input 2 Bridge A in Hz up to 100000Hz
brdirais 0:2cb6ce8e07bd 72 /// ON IHM04A1, must be identical to L6206_CONF_PARAM_FREQ_PWM1A as used timer is the same
brdirais 0:2cb6ce8e07bd 73 #define L6206_CONF_PARAM_FREQ_PWM2A (20000)
brdirais 0:2cb6ce8e07bd 74 /// Frequency of PWM of Input 1 Bridge B in Hz up to 100000Hz
brdirais 0:2cb6ce8e07bd 75 #define L6206_CONF_PARAM_FREQ_PWM1B (20000)
brdirais 0:2cb6ce8e07bd 76 /// Frequency of PWM of Input 2 Bridge B in Hz up to 100000Hz
brdirais 0:2cb6ce8e07bd 77 /// On IHM04A1, must be identical to L6206_CONF_PARAM_FREQ_PWM2B as used timer is the same
brdirais 0:2cb6ce8e07bd 78 #define L6206_CONF_PARAM_FREQ_PWM2B (20000)
brdirais 0:2cb6ce8e07bd 79
brdirais 0:2cb6ce8e07bd 80 /// Frequency of PWM of Input 2 Bridge B (in kHz)
brdirais 0:2cb6ce8e07bd 81 #define L6206_CONF_PARAM_PARALLE_BRIDGES (PARALLELING_NONE___1_BIDIR_MOTOR_BRIDGE_A__1_BIDIR_MOTOR_BRIDGE_B)
brdirais 0:2cb6ce8e07bd 82 /**
brdirais 0:2cb6ce8e07bd 83 * @}
brdirais 0:2cb6ce8e07bd 84 */
brdirais 0:2cb6ce8e07bd 85
brdirais 0:2cb6ce8e07bd 86 /**
brdirais 0:2cb6ce8e07bd 87 * @}
brdirais 0:2cb6ce8e07bd 88 */
brdirais 0:2cb6ce8e07bd 89
brdirais 0:2cb6ce8e07bd 90 /**
brdirais 0:2cb6ce8e07bd 91 * @}
brdirais 0:2cb6ce8e07bd 92 */
brdirais 0:2cb6ce8e07bd 93
brdirais 0:2cb6ce8e07bd 94 /**
brdirais 0:2cb6ce8e07bd 95 * @}
brdirais 0:2cb6ce8e07bd 96 */
brdirais 0:2cb6ce8e07bd 97
brdirais 0:2cb6ce8e07bd 98 #ifdef __cplusplus
brdirais 0:2cb6ce8e07bd 99 }
brdirais 0:2cb6ce8e07bd 100 #endif
brdirais 0:2cb6ce8e07bd 101
brdirais 0:2cb6ce8e07bd 102 #endif /* __L6206_TARGET_CONFIG_H */
brdirais 0:2cb6ce8e07bd 103
brdirais 0:2cb6ce8e07bd 104