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