Library to handle the X-NUCLEO-IHM06A1 Motor Control Expansion Board based on the STSPIN220 component.

Dependencies:   ST_INTERFACES

Dependents:   HelloWorld_IHM06A1

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

Motor Control Library

Library to handle the X-NUCLEO-IHM06A1 Motor Control Expansion Board based on the STSPIN220 component.

It features the:

  • Read and write of the device parameters; GPIO, PWM and IRQ configuration; microstepping, direction position, speed, acceleration, deceleration and torque controls
  • Automatic full-step switch management; high impedance or hold stop mode selection; enable and standby management
  • Fault interrupts handling (over current, short-circuit and over temperature)
  • Command locking until the device completes movement

The API allows to easily:

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

Platform compatibility

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

Committer:
nucleosam
Date:
Thu May 26 15:44:53 2016 +0000
Revision:
0:0ccd34c56c66
Initial version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nucleosam 0:0ccd34c56c66 1 /**************************************************************************//**
nucleosam 0:0ccd34c56c66 2 * @file stspin220_target_config.h
nucleosam 0:0ccd34c56c66 3 * @author IPC Rennes
nucleosam 0:0ccd34c56c66 4 * @version V1.1.0
nucleosam 0:0ccd34c56c66 5 * @date May 26th, 2016
nucleosam 0:0ccd34c56c66 6 * @brief Predefines values for the STSPIN220 registers
nucleosam 0:0ccd34c56c66 7 * and for the devices parameters
nucleosam 0:0ccd34c56c66 8 * @note (C) COPYRIGHT 2016 STMicroelectronics
nucleosam 0:0ccd34c56c66 9 ******************************************************************************
nucleosam 0:0ccd34c56c66 10 * @attention
nucleosam 0:0ccd34c56c66 11 *
nucleosam 0:0ccd34c56c66 12 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
nucleosam 0:0ccd34c56c66 13 *
nucleosam 0:0ccd34c56c66 14 * Redistribution and use in source and binary forms, with or without modification,
nucleosam 0:0ccd34c56c66 15 * are permitted provided that the following conditions are met:
nucleosam 0:0ccd34c56c66 16 * 1. Redistributions of source code must retain the above copyright notice,
nucleosam 0:0ccd34c56c66 17 * this list of conditions and the following disclaimer.
nucleosam 0:0ccd34c56c66 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
nucleosam 0:0ccd34c56c66 19 * this list of conditions and the following disclaimer in the documentation
nucleosam 0:0ccd34c56c66 20 * and/or other materials provided with the distribution.
nucleosam 0:0ccd34c56c66 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
nucleosam 0:0ccd34c56c66 22 * may be used to endorse or promote products derived from this software
nucleosam 0:0ccd34c56c66 23 * without specific prior written permission.
nucleosam 0:0ccd34c56c66 24 *
nucleosam 0:0ccd34c56c66 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
nucleosam 0:0ccd34c56c66 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
nucleosam 0:0ccd34c56c66 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
nucleosam 0:0ccd34c56c66 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
nucleosam 0:0ccd34c56c66 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
nucleosam 0:0ccd34c56c66 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
nucleosam 0:0ccd34c56c66 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
nucleosam 0:0ccd34c56c66 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
nucleosam 0:0ccd34c56c66 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
nucleosam 0:0ccd34c56c66 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
nucleosam 0:0ccd34c56c66 35 *
nucleosam 0:0ccd34c56c66 36 ******************************************************************************
nucleosam 0:0ccd34c56c66 37 */
nucleosam 0:0ccd34c56c66 38
nucleosam 0:0ccd34c56c66 39 /* Define to prevent recursive inclusion -------------------------------------*/
nucleosam 0:0ccd34c56c66 40 #ifndef __STSPIN220_TARGET_CONFIG_H
nucleosam 0:0ccd34c56c66 41 #define __STSPIN220_TARGET_CONFIG_H
nucleosam 0:0ccd34c56c66 42
nucleosam 0:0ccd34c56c66 43 #ifdef __cplusplus
nucleosam 0:0ccd34c56c66 44 extern "C" {
nucleosam 0:0ccd34c56c66 45 #endif
nucleosam 0:0ccd34c56c66 46
nucleosam 0:0ccd34c56c66 47 /** @addtogroup STSPIN220
nucleosam 0:0ccd34c56c66 48 * @{
nucleosam 0:0ccd34c56c66 49 */
nucleosam 0:0ccd34c56c66 50
nucleosam 0:0ccd34c56c66 51 /** @addtogroup Stspin220_Exported_Constants
nucleosam 0:0ccd34c56c66 52 * @{
nucleosam 0:0ccd34c56c66 53 */
nucleosam 0:0ccd34c56c66 54
nucleosam 0:0ccd34c56c66 55 /** @defgroup Predefined_Stspin220_Registers_Values Predefined Stspin220 Registers Values
nucleosam 0:0ccd34c56c66 56 * @{
nucleosam 0:0ccd34c56c66 57 */
nucleosam 0:0ccd34c56c66 58
nucleosam 0:0ccd34c56c66 59 /************************ Speed Profile *******************************/
nucleosam 0:0ccd34c56c66 60
nucleosam 0:0ccd34c56c66 61 /// Acceleration rate in pulse/s2 (must be greater than 0)
nucleosam 0:0ccd34c56c66 62 #define STSPIN220_CONF_PARAM_ACC (480)
nucleosam 0:0ccd34c56c66 63
nucleosam 0:0ccd34c56c66 64 /// Deceleration rate in pulse/s2 (must be greater than 0)
nucleosam 0:0ccd34c56c66 65 #define STSPIN220_CONF_PARAM_DEC (480)
nucleosam 0:0ccd34c56c66 66
nucleosam 0:0ccd34c56c66 67 /// Running speed in pulse/s (8 pulse/s < Maximum speed <= 10 000 pulse/s )
nucleosam 0:0ccd34c56c66 68 #define STSPIN220_CONF_PARAM_RUNNING_SPEED (1600)
nucleosam 0:0ccd34c56c66 69
nucleosam 0:0ccd34c56c66 70 /// Minimum speed in pulse/s (8 pulse/s <= Minimum speed < 10 000 pulse/s)
nucleosam 0:0ccd34c56c66 71 #define STSPIN220_CONF_PARAM_MIN_SPEED (400)
nucleosam 0:0ccd34c56c66 72
nucleosam 0:0ccd34c56c66 73 /************************ Torque *******************************/
nucleosam 0:0ccd34c56c66 74
nucleosam 0:0ccd34c56c66 75 /// Acceleration torque in % (from 0 to 100)
nucleosam 0:0ccd34c56c66 76 #define STSPIN220_CONF_PARAM_ACC_TORQUE (20)
nucleosam 0:0ccd34c56c66 77
nucleosam 0:0ccd34c56c66 78 /// Deceleration torque in % (from 0 to 100)
nucleosam 0:0ccd34c56c66 79 #define STSPIN220_CONF_PARAM_DEC_TORQUE (15)
nucleosam 0:0ccd34c56c66 80
nucleosam 0:0ccd34c56c66 81 /// Running torque in % (from 0 to 100)
nucleosam 0:0ccd34c56c66 82 #define STSPIN220_CONF_PARAM_RUNNING_TORQUE (10)
nucleosam 0:0ccd34c56c66 83
nucleosam 0:0ccd34c56c66 84 /// Holding torque in % (from 0 to 100)
nucleosam 0:0ccd34c56c66 85 #define STSPIN220_CONF_PARAM_HOLDING_TORQUE (25)
nucleosam 0:0ccd34c56c66 86
nucleosam 0:0ccd34c56c66 87 /// Torque boost speed enable
nucleosam 0:0ccd34c56c66 88 #define STSPIN220_CONF_PARAM_TORQUE_BOOST_EN (TRUE)
nucleosam 0:0ccd34c56c66 89
nucleosam 0:0ccd34c56c66 90 /// Torque boost speed threshold in fullstep/s
nucleosam 0:0ccd34c56c66 91 #define STSPIN220_CONF_PARAM_TORQUE_BOOST_TH (200)
nucleosam 0:0ccd34c56c66 92
nucleosam 0:0ccd34c56c66 93 /******************************* Others ***************************************/
nucleosam 0:0ccd34c56c66 94
nucleosam 0:0ccd34c56c66 95 /// Step mode selection settings
nucleosam 0:0ccd34c56c66 96 #define STSPIN220_CONF_PARAM_STEP_MODE (STEP_MODE_1_32)
nucleosam 0:0ccd34c56c66 97
nucleosam 0:0ccd34c56c66 98 /// Automatic HIZ STOP
nucleosam 0:0ccd34c56c66 99 #define STSPIN220_CONF_PARAM_AUTO_HIZ_STOP (HOLD_MODE)
nucleosam 0:0ccd34c56c66 100
nucleosam 0:0ccd34c56c66 101 /// REF PWM frequency (Hz)
nucleosam 0:0ccd34c56c66 102 #define STSPIN220_CONF_PARAM_REF_PWM_FREQUENCY (100000)
nucleosam 0:0ccd34c56c66 103
nucleosam 0:0ccd34c56c66 104 /**
nucleosam 0:0ccd34c56c66 105 * @}
nucleosam 0:0ccd34c56c66 106 */
nucleosam 0:0ccd34c56c66 107
nucleosam 0:0ccd34c56c66 108 /**
nucleosam 0:0ccd34c56c66 109 * @}
nucleosam 0:0ccd34c56c66 110 */
nucleosam 0:0ccd34c56c66 111
nucleosam 0:0ccd34c56c66 112 /**
nucleosam 0:0ccd34c56c66 113 * @}
nucleosam 0:0ccd34c56c66 114 */
nucleosam 0:0ccd34c56c66 115
nucleosam 0:0ccd34c56c66 116 #ifdef __cplusplus
nucleosam 0:0ccd34c56c66 117 }
nucleosam 0:0ccd34c56c66 118 #endif
nucleosam 0:0ccd34c56c66 119
nucleosam 0:0ccd34c56c66 120 #endif /* __STSPIN220_TARGET_CONFIG_H */