Expansion SW library to control a bipolar stepper motor using X-NUCLEO-IHM05A1 expansion board based on L6208.

Dependencies:   ST_INTERFACES

Dependents:   HelloWorld_IHM05A1 TAU_ROTATING_PLATFORM_IHM05A1 Amaldi_13_Exercise_IHM05A1 Amaldi_13_Exercise_IHM05A1motore ... more

Fork of X-NUCLEO-IHM05A1 by ST Expansion SW Team

Motor Control Library

Library to handle the X-NUCLEO-IHM05A1 Motor Control Expansion Board based on the L6208 component.

It features the:

  • Read and write of device parameters
  • Configuration of GPIOs and IRQs (for enabling, direction, current decay and microstepping)
  • Control of position, speed, acceleration and deceleration
  • Command locking until the device completes movement
  • Handling of overcurrent and thermal alarms (flag interrupt handling)

The API allows to easily:

  • perform various positioning, moves and stops
  • get/set or monitor the motor positions
  • set home position and mark another position
  • get/set minimum and maximum speed
  • get current speed
  • get/set acceleration and deceleration
  • get/set the step mode (up to 1/16)

Board configuration

/media/uploads/nucleosam/mbed-x-nucleo-ihm05a1.png

Platform compatibility

Compatible platforms have been tested with the configurations provided by the HelloWorld_IHM05A1 example.

Committer:
Davidroid
Date:
Fri Jul 28 13:06:36 2017 +0000
Revision:
6:c73faac7197f
Parent:
4:0b52159554b5
Aligning to ARM mbed coding style.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
davide.aliprandi@st.com 3:63a8d672fe5e 1 /******************************************************//**
davide.aliprandi@st.com 3:63a8d672fe5e 2 * @file L6208_config.h
davide.aliprandi@st.com 3:63a8d672fe5e 3 * @author IPC Rennes
davide.aliprandi@st.com 3:63a8d672fe5e 4 * @version V1.1.0
davide.aliprandi@st.com 3:63a8d672fe5e 5 * @date February 11th, 2016
davide.aliprandi@st.com 3:63a8d672fe5e 6 * @brief Predefines values for the L6208 parameters
davide.aliprandi@st.com 3:63a8d672fe5e 7 * @note (C) COPYRIGHT 2016 STMicroelectronics
davide.aliprandi@st.com 3:63a8d672fe5e 8 ******************************************************************************
davide.aliprandi@st.com 3:63a8d672fe5e 9 * @attention
davide.aliprandi@st.com 3:63a8d672fe5e 10 *
davide.aliprandi@st.com 3:63a8d672fe5e 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
davide.aliprandi@st.com 3:63a8d672fe5e 12 *
davide.aliprandi@st.com 3:63a8d672fe5e 13 * Redistribution and use in source and binary forms, with or without modification,
davide.aliprandi@st.com 3:63a8d672fe5e 14 * are permitted provided that the following conditions are met:
davide.aliprandi@st.com 3:63a8d672fe5e 15 * 1. Redistributions of source code must retain the above copyright notice,
davide.aliprandi@st.com 3:63a8d672fe5e 16 * this list of conditions and the following disclaimer.
davide.aliprandi@st.com 3:63a8d672fe5e 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
davide.aliprandi@st.com 3:63a8d672fe5e 18 * this list of conditions and the following disclaimer in the documentation
davide.aliprandi@st.com 3:63a8d672fe5e 19 * and/or other materials provided with the distribution.
davide.aliprandi@st.com 3:63a8d672fe5e 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
davide.aliprandi@st.com 3:63a8d672fe5e 21 * may be used to endorse or promote products derived from this software
davide.aliprandi@st.com 3:63a8d672fe5e 22 * without specific prior written permission.
davide.aliprandi@st.com 3:63a8d672fe5e 23 *
davide.aliprandi@st.com 3:63a8d672fe5e 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
davide.aliprandi@st.com 3:63a8d672fe5e 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
davide.aliprandi@st.com 3:63a8d672fe5e 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
davide.aliprandi@st.com 3:63a8d672fe5e 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
davide.aliprandi@st.com 3:63a8d672fe5e 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
davide.aliprandi@st.com 3:63a8d672fe5e 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
davide.aliprandi@st.com 3:63a8d672fe5e 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
davide.aliprandi@st.com 3:63a8d672fe5e 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
davide.aliprandi@st.com 3:63a8d672fe5e 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
davide.aliprandi@st.com 3:63a8d672fe5e 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
davide.aliprandi@st.com 3:63a8d672fe5e 34 *
davide.aliprandi@st.com 3:63a8d672fe5e 35 ******************************************************************************
davide.aliprandi@st.com 3:63a8d672fe5e 36 */
davide.aliprandi@st.com 3:63a8d672fe5e 37
davide.aliprandi@st.com 3:63a8d672fe5e 38 /* Define to prevent recursive inclusion -------------------------------------*/
davide.aliprandi@st.com 3:63a8d672fe5e 39 #ifndef __L6208_CONFIG_H
davide.aliprandi@st.com 3:63a8d672fe5e 40 #define __L6208_CONFIG_H
davide.aliprandi@st.com 3:63a8d672fe5e 41
davide.aliprandi@st.com 3:63a8d672fe5e 42 #ifdef __cplusplus
davide.aliprandi@st.com 3:63a8d672fe5e 43 extern "C" {
davide.aliprandi@st.com 3:63a8d672fe5e 44 #endif
davide.aliprandi@st.com 3:63a8d672fe5e 45
davide.aliprandi@st.com 3:63a8d672fe5e 46 /** @addtogroup L6208
davide.aliprandi@st.com 3:63a8d672fe5e 47 * @{
davide.aliprandi@st.com 3:63a8d672fe5e 48 */
davide.aliprandi@st.com 3:63a8d672fe5e 49
davide.aliprandi@st.com 3:63a8d672fe5e 50 /** @addtogroup L6208_Exported_Constants
davide.aliprandi@st.com 3:63a8d672fe5e 51 * @{
davide.aliprandi@st.com 3:63a8d672fe5e 52 */
davide.aliprandi@st.com 3:63a8d672fe5e 53
davide.aliprandi@st.com 3:63a8d672fe5e 54 /** @defgroup Predefined_L6208_Parameters_Values Predefined L6208 Parameters Values
davide.aliprandi@st.com 3:63a8d672fe5e 55 * @{
davide.aliprandi@st.com 3:63a8d672fe5e 56 */
davide.aliprandi@st.com 3:63a8d672fe5e 57
davide.aliprandi@st.com 3:63a8d672fe5e 58 /// Acceleration rate in step/s^2 or (1/16)th step/s^2 for microstep modes
davide.aliprandi@st.com 3:63a8d672fe5e 59 #define L6208_CONF_PARAM_ACC_RATE (1000)
davide.aliprandi@st.com 3:63a8d672fe5e 60
davide.aliprandi@st.com 3:63a8d672fe5e 61 /// Acceleration current torque in % (from 0 to 100)
davide.aliprandi@st.com 3:63a8d672fe5e 62 #define L6208_CONF_PARAM_ACC_CURRENT (10)
davide.aliprandi@st.com 3:63a8d672fe5e 63
davide.aliprandi@st.com 3:63a8d672fe5e 64 /// Deceleration rate in step/s^2 or (1/16)th step/s^2 for microstep modes
davide.aliprandi@st.com 3:63a8d672fe5e 65 #define L6208_CONF_PARAM_DEC_RATE (1000)
davide.aliprandi@st.com 3:63a8d672fe5e 66
davide.aliprandi@st.com 3:63a8d672fe5e 67 /// Deceleration current torque in % (from 0 to 100)
davide.aliprandi@st.com 3:63a8d672fe5e 68 #define L6208_CONF_PARAM_DEC_CURRENT (10)
davide.aliprandi@st.com 3:63a8d672fe5e 69
davide.aliprandi@st.com 3:63a8d672fe5e 70 /// Running speed in step/s or (1/16)th step/s for microstep modes
davide.aliprandi@st.com 3:63a8d672fe5e 71 #define L6208_CONF_PARAM_RUNNING_SPEED (1000)
davide.aliprandi@st.com 3:63a8d672fe5e 72
davide.aliprandi@st.com 3:63a8d672fe5e 73 /// Running current torque in % (from 0 to 100)
davide.aliprandi@st.com 3:63a8d672fe5e 74 #define L6208_CONF_PARAM_RUNNING_CURRENT (10)
davide.aliprandi@st.com 3:63a8d672fe5e 75
davide.aliprandi@st.com 3:63a8d672fe5e 76 /// Holding current torque in % (from 0 to 100)
davide.aliprandi@st.com 3:63a8d672fe5e 77 #define L6208_CONF_PARAM_HOLDING_CURRENT (10)
davide.aliprandi@st.com 3:63a8d672fe5e 78
davide.aliprandi@st.com 3:63a8d672fe5e 79 /// Step mode via enum motorStepMode_t
davide.aliprandi@st.com 3:63a8d672fe5e 80 #define L6208_CONF_PARAM_STEP_MODE (STEP_MODE_1_16)
davide.aliprandi@st.com 3:63a8d672fe5e 81
davide.aliprandi@st.com 3:63a8d672fe5e 82 /// Decay mode via enum motorDecayMode_t
davide.aliprandi@st.com 3:63a8d672fe5e 83 #define L6208_CONF_PARAM_DECAY_MODE (FAST_DECAY)
davide.aliprandi@st.com 3:63a8d672fe5e 84
davide.aliprandi@st.com 3:63a8d672fe5e 85 /// Dwelling time in ms
davide.aliprandi@st.com 3:63a8d672fe5e 86 #define L6208_CONF_PARAM_DWELL_TIME (0)
davide.aliprandi@st.com 3:63a8d672fe5e 87
davide.aliprandi@st.com 3:63a8d672fe5e 88 /// Automatic HIZ STOP
davide.aliprandi@st.com 3:63a8d672fe5e 89 #define L6208_CONF_PARAM_AUTO_HIZ_STOP (FALSE)
davide.aliprandi@st.com 3:63a8d672fe5e 90
davide.aliprandi@st.com 3:63a8d672fe5e 91 /// VREFA and VREFB PWM frequency (Hz)
davide.aliprandi@st.com 3:63a8d672fe5e 92 #define L6208_CONF_VREF_PWM_FREQUENCY (100000)
davide.aliprandi@st.com 3:63a8d672fe5e 93
davide.aliprandi@st.com 3:63a8d672fe5e 94 /**
davide.aliprandi@st.com 3:63a8d672fe5e 95 * @}
davide.aliprandi@st.com 3:63a8d672fe5e 96 */
davide.aliprandi@st.com 3:63a8d672fe5e 97
davide.aliprandi@st.com 3:63a8d672fe5e 98 /**
davide.aliprandi@st.com 3:63a8d672fe5e 99 * @}
davide.aliprandi@st.com 3:63a8d672fe5e 100 */
davide.aliprandi@st.com 3:63a8d672fe5e 101
davide.aliprandi@st.com 3:63a8d672fe5e 102 /**
davide.aliprandi@st.com 3:63a8d672fe5e 103 * @}
davide.aliprandi@st.com 3:63a8d672fe5e 104 */
davide.aliprandi@st.com 3:63a8d672fe5e 105
davide.aliprandi@st.com 3:63a8d672fe5e 106 #ifdef __cplusplus
davide.aliprandi@st.com 3:63a8d672fe5e 107 }
davide.aliprandi@st.com 3:63a8d672fe5e 108 #endif
davide.aliprandi@st.com 3:63a8d672fe5e 109
davide.aliprandi@st.com 3:63a8d672fe5e 110 #endif /* __L6208_CONFIG_H */
davide.aliprandi@st.com 3:63a8d672fe5e 111
davide.aliprandi@st.com 3:63a8d672fe5e 112 /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/