Library to handle the X_NUCLEO_IHM02A1 Motor Control Expansion Board based on the L6470 component.

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   HelloWorld_IHM02A1 ConcorsoFinal HelloWorld_IHM02A1_mbedOS HelloWorld_IHM02A1-Serialinterpreter ... more

Fork of X_NUCLEO_IHM02A1 by ST Expansion SW Team

Motor Control Library

Introduction

Library to handle the X-NUCLEO-IHM02A1 Motor Control Expansion Board based on the the L6470 component.

Daisy-Chain Configuration

The two L6470 components mounted on this board are connected in daisy-chain configuration. This board can be stacked up to four times so that the eight L6470 components will be connected two-by-two in daisy-chain configuration.

Concerning the SSEL pin of the SPI communication, each expansion board must be in one of the following configuration:

  • SB_23 resistor connected only: SSEL on pin A2;
  • SB_7 resistor connected only: SSEL on pin D2;
  • SB_8 resistor connected only: SSEL on pin D10;
  • SB_9 resistor connected only: SSEL on pin D5.

Arduino Connector Compatibility Warning

X-NUCLEO-IHM02A1 is Arduino compatible with one exception: instead of using D13 pin to drive the SPI clock, it uses D3 pin, hence the default configuration for this library is with the SPI clock on D3 pin.

To be fully Arduino compatible the following patch is required:

  • to remove the SB34 resistor;
  • to solder the SB12 resistor.

Alternatively, you can route the Nucleo board’s D13 pin directly to the expansion board’s D3 pin with a wire. In case you patch your expansion board or route the pin, the SPI clock will be driven on D13 pin rather than on D3 pin, and you have also to initialize the sclk PinName variable with D13 rather than D3. This patch is known to be required, for example, on the following boards: NUCLEO-F103RB, NUCLEO-F302RB, NUCLEO-F411RE, and NUCLEO-F429ZI.

If you use D13 pin for the SPI clock, please be aware that on STM32 Nucleo boards you may not drive the LED, otherwise you will get a conflict: the LED on STM32 Nucleo boards is connected to the D13 pin.

Example Applications

Revision:
17:4b3dc908724f
Parent:
12:a942d51c488b
Child:
18:ddf3d5dc8137
--- a/Components/Interfaces/StepperMotor_class.h	Fri Mar 11 15:49:04 2016 +0000
+++ b/Components/Interfaces/StepperMotor_class.h	Thu Apr 07 16:55:51 2016 +0000
@@ -2,8 +2,8 @@
  ******************************************************************************
  * @file    StepperMotor_class.h
  * @author  Davide Aliprandi, STMicroelectronics
- * @version V1.0.0
- * @date    November 12th, 2015
+ * @version V1.1.0
+ * @date    April 6th, 2016
  * @brief   This file contains the abstract class describing the interface of a
  *          stepper-motor component.
  ******************************************************************************
@@ -60,11 +60,29 @@
      */
     typedef enum
     {
-      BWD = 0, /* Backward. */
-      FWD = 1  /* Forward. */
+        BWD = 0, /* Backward. */
+        FWD = 1  /* Forward. */
     } direction_t;
 
     /**
+     * @brief Step modes.
+     */
+    typedef enum
+    {
+        STEP_MODE_FULL = 0, /* Full-step. */
+        STEP_MODE_HALF,     /* Half-step. */
+        STEP_MODE_1_4,      /* 1/4 microstep. */
+        STEP_MODE_1_8,      /* 1/8 microstep. */
+        STEP_MODE_1_16,     /* 1/16 microstep. */
+        STEP_MODE_1_32,     /* 1/32 microstep. */
+        STEP_MODE_1_64,     /* 1/64 microstep. */
+        STEP_MODE_1_128,    /* 1/128 microstep. */
+        STEP_MODE_1_256,    /* 1/256 microstep. */
+        STEP_MODE_UNKNOWN,  /* Unknown. */
+        STEP_MODE_WAVE      /* Full-step one-phase-on. */
+    } step_mode_t;
+
+    /**
      * @brief  Getting the status.
      * @param  None.
      * @retval The status.
@@ -72,13 +90,6 @@
     virtual unsigned int GetStatus(void) = 0;
 
     /**
-     * @brief  Getting a parameter.
-     * @param  parameter The parameter's identifier (or its register address).
-     * @retval The parameter's value.
-     */
-    virtual float GetParameter(unsigned int parameter) = 0;
-
-    /**
      * @brief  Getting the position.
      * @param  None.
      * @retval The position.
@@ -134,14 +145,6 @@
      */
     virtual direction_t GetDirection(void) = 0;
 
-   /**
-     * @brief  Setting a parameter.
-     * @param  parameter The parameter's identifier (or its register address).
-     * @param  value The parameter's value.
-     * @retval None.
-     */
-    virtual void SetParameter(unsigned int parameter, float value) = 0;
-
     /**
      * @brief  Setting the current position to be the home position.
      * @param  None.
@@ -159,30 +162,37 @@
     /**
      * @brief  Setting the maximum speed in pps.
      * @param  speed The maximum speed in pps.
-     * @retval None.
+     * @retval "true" in case of success, "false" otherwise.
      */
-    virtual void SetMaxSpeed(unsigned int speed) = 0;
+    virtual bool SetMaxSpeed(unsigned int speed) = 0;
 
     /**
      * @brief  Setting the minimum speed in pps.
      * @param  speed The minimum speed in pps.
-     * @retval None.
+     * @retval "true" in case of success, "false" otherwise.
      */
-    virtual void SetMinSpeed(unsigned int speed) = 0;
+    virtual bool SetMinSpeed(unsigned int speed) = 0;
 
     /**
      * @brief  Setting the acceleration in pps^2.
      * @param  acceleration The acceleration in pps^2.
-     * @retval None.
+     * @retval "true" in case of success, "false" otherwise.
      */
-    virtual void SetAcceleration(unsigned int acceleration) = 0;
+    virtual bool SetAcceleration(unsigned int acceleration) = 0;
 
     /**
      * @brief  Setting the deceleration in pps^2.
      * @param  deceleration The deceleration in pps^2.
-     * @retval None.
+     * @retval "true" in case of success, "false" otherwise.
      */
-    virtual void SetDeceleration(unsigned int deceleration) = 0;
+    virtual bool SetDeceleration(unsigned int deceleration) = 0;
+
+    /**
+     * @brief  Setting the Step Mode.
+     * @param  step_mode The Step Mode.
+     * @retval "true" in case of success, "false" otherwise.
+     */
+    virtual bool SetStepMode(step_mode_t step_mode) = 0;
 
     /**
      * @brief  Going to a specified position.