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.

Revision:
0:0ccd34c56c66
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/stspin220/stspin220_target_config.h	Thu May 26 15:44:53 2016 +0000
@@ -0,0 +1,120 @@
+/**************************************************************************//**
+  * @file    stspin220_target_config.h
+  * @author  IPC Rennes
+  * @version V1.1.0
+  * @date    May 26th, 2016
+  * @brief   Predefines values for the STSPIN220 registers
+  * and for the devices parameters
+  * @note    (C) COPYRIGHT 2016 STMicroelectronics
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
+  *
+  * Redistribution and use in source and binary forms, with or without modification,
+  * are permitted provided that the following conditions are met:
+  *   1. Redistributions of source code must retain the above copyright notice,
+  *      this list of conditions and the following disclaimer.
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
+  *      this list of conditions and the following disclaimer in the documentation
+  *      and/or other materials provided with the distribution.
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
+  *      may be used to endorse or promote products derived from this software
+  *      without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  *
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STSPIN220_TARGET_CONFIG_H
+#define __STSPIN220_TARGET_CONFIG_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif  
+   
+/** @addtogroup STSPIN220
+  * @{
+  */
+
+/** @addtogroup Stspin220_Exported_Constants
+  * @{
+  */
+   
+/** @defgroup Predefined_Stspin220_Registers_Values Predefined Stspin220 Registers Values
+  * @{
+  */
+
+/************************ Speed Profile  *******************************/
+
+/// Acceleration rate in pulse/s2 (must be greater than 0)
+#define STSPIN220_CONF_PARAM_ACC                               (480)
+   
+/// Deceleration rate in pulse/s2 (must be greater than 0)
+#define STSPIN220_CONF_PARAM_DEC                               (480)
+   
+/// Running speed in pulse/s (8 pulse/s < Maximum speed <= 10 000 pulse/s )
+#define STSPIN220_CONF_PARAM_RUNNING_SPEED                     (1600)
+   
+/// Minimum speed in pulse/s (8 pulse/s <= Minimum speed < 10 000 pulse/s)
+#define STSPIN220_CONF_PARAM_MIN_SPEED                         (400)
+
+/************************ Torque  *******************************/
+
+/// Acceleration torque in % (from 0 to 100)
+#define STSPIN220_CONF_PARAM_ACC_TORQUE                        (20)
+
+/// Deceleration torque in % (from 0 to 100)
+#define STSPIN220_CONF_PARAM_DEC_TORQUE                        (15)
+
+/// Running torque in % (from 0 to 100)
+#define STSPIN220_CONF_PARAM_RUNNING_TORQUE                    (10)
+
+/// Holding torque in % (from 0 to 100)
+#define STSPIN220_CONF_PARAM_HOLDING_TORQUE                    (25)
+
+/// Torque boost speed enable
+#define STSPIN220_CONF_PARAM_TORQUE_BOOST_EN                   (TRUE)
+
+/// Torque boost speed threshold in fullstep/s
+#define STSPIN220_CONF_PARAM_TORQUE_BOOST_TH                   (200)
+    
+/******************************* Others ***************************************/
+
+/// Step mode selection settings
+#define STSPIN220_CONF_PARAM_STEP_MODE                         (STEP_MODE_1_32)
+   
+/// Automatic HIZ STOP
+#define STSPIN220_CONF_PARAM_AUTO_HIZ_STOP                     (HOLD_MODE)
+
+/// REF PWM frequency (Hz)
+#define STSPIN220_CONF_PARAM_REF_PWM_FREQUENCY                 (100000)
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif /* __STSPIN220_TARGET_CONFIG_H */
\ No newline at end of file