ST / X_NUCLEO_IHM01A1

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   Stepper_Matlab_Control SunTracker_BLE Stepper_Matlab_Control MemsMotorControl ... more

Fork of X_NUCLEO_IHM01A1 by ST Expansion SW Team

Motor Control Library

Introduction

Library to handle the X-NUCLEO-IHM01A1 Motor Control Expansion Board based on the the L6474 component.

Daisy-Chain Configuration

This board can be stacked up to three times so that the L6474 components will be connected in daisy-chain configuration. For this purpose, some resistors must be correctly connected on the boards as depicted here below:

/media/uploads/Davidroid/daisychaintable.png

Platform compatibility

  • NUCLEO boards have been tested with the default configuration provided by the HelloWorld_IHM01A1 example.
  • LPCXpresso11U68 board has been tested with the following patch:
    • to connect with a wire from the LPCX’s D4 pin to the IHM01A1’s D9 pin;
    • to initialize the pwm PinName variable with D4 rather than D9.
  • FRDM-K64F board has been tested with the following patch:
    • to connect with a wire from the FRDM’s D4 pin to the IHM01A1’s D8 pin;
    • to initialize the standby_reset PinName variable with D4 rather than D8.

Example Applications

Revision:
25:1c3146315f16
Parent:
23:58264db10a17
Child:
26:fd83fecf1ef5
--- a/Components/l6474/l6474_class.h	Fri Mar 11 15:46:34 2016 +0000
+++ b/Components/l6474/l6474_class.h	Thu Apr 07 16:31:49 2016 +0000
@@ -167,7 +167,8 @@
      * @brief  Getting the value of the Status Register.
      * @param  None.
      * @retval None.
-     * @note   The Status Register's flags are cleared, contrary to ReadStatusRegister().
+     * @note   The Status Register's flags are cleared, contrary to the
+     *         ReadStatusRegister() method.
      */
     virtual unsigned int GetStatus(void)
     {
@@ -176,10 +177,11 @@
 
    /**
      * @brief  Getting a parameter.
-     * @param  parameter A parameter's register adress.
+     * @param  parameter A parameter's register address.
      * @retval The parameter's value.
-     * @note   The Status Register's flags are cleared, contrary to ReadStatusRegister().
-     *         parameter can be one of the following:
+     * @note   The Status Register's flags are cleared, contrary to the
+     *         ReadStatusRegister() method.
+     *         The parameter can be one of the following:
      *           + L6474_ABS_POS
      *           + L6474_EL_POS
      *           + L6474_MARK
@@ -312,11 +314,11 @@
     }
 
    /**
-     * @brief  Setting a parameter.
-     * @param  parameter A parameter's register adress.
-     * @param  value The parameter's value.
-     * @retval None.
-     * @note   parameter can be one of the following:
+     * @brief   Setting a parameter.
+     * @param   parameter A parameter's register address.
+     * @param   value The parameter's value.
+     * @retval  None.
+     * @note    The parameter can be one of the following:
      *           + L6474_ABS_POS
      *           + L6474_EL_POS
      *           + L6474_MARK
@@ -345,6 +347,22 @@
      *           + L6474_RESERVED_REG13
      *           + L6474_RESERVED_REG14
      *           + L6474_INEXISTENT_REG
+     * @warning Some registers can only be written in particular conditions (see L6474's datasheet).
+     *          Any attempt to write one of those registers when the conditions are not satisfied
+     *          causes the command to be ignored and the NOTPERF_CMD flag to rise at the end of the
+     *          last argument byte. Any attempt to set an inexistent register (wrong address value)
+     *          causes the command to be ignored and the WRONG_CMD flag to rise.
+     *          For example, setting some parameters requires first to disable the power bridge;
+     *          this can be done through the SoftHiZ() method.
+     *          They are the following:
+     *           + L6474_EL_POS
+     *           + L6474_T_FAST
+     *           + L6474_TON_MIN        : value in us
+     *           + L6474_TOFF_MIN       : value in us
+     *           + L6474_ADC_OUT
+     *           + L6474_STEP_MODE
+     *           + L6474_CONFIG
+     *           + L6474_STATUS
      */
     virtual void SetParameter(unsigned int parameter, float value)
     {
@@ -390,41 +408,45 @@
     /**
      * @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)
+    virtual bool SetMaxSpeed(unsigned int speed)
     {
         L6474_SetMaxSpeed((unsigned int) speed);
+        return true;
     }
 
     /**
      * @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)
+    virtual bool SetMinSpeed(unsigned int speed)
     {
         L6474_SetMinSpeed((unsigned int) speed);
+        return true;
     }
 
     /**
      * @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)
+    virtual bool SetAcceleration(unsigned int acceleration)
     {
         L6474_SetAcceleration((unsigned int) acceleration);
+        return true;
     }
 
     /**
      * @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)
+    virtual bool SetDeceleration(unsigned int deceleration)
     {
         L6474_SetDeceleration((unsigned int) deceleration);
+        return true;
     }
 
     /**
@@ -549,7 +571,8 @@
      * @brief  Reading the Status Register.
      * @param  None.
      * @retval None.
-     * @note   The Status Register's flags are not cleared, contrary to GetStatus().
+     * @note   The Status Register's flags are not cleared, contrary to the
+     *         GetStatus() method.
      */
     virtual uint16_t ReadStatusRegister(void)
     {
@@ -557,22 +580,22 @@
     }
 
     /**
-     * @brief  Setting the Step Mode.
-     * @param  step_mode The Step Mode.
-     * @retval None.
-     * @note   step_mode can be one of the following:
-     *           + STEP_MODE_FULL
-     *           + STEP_MODE_HALF
-     *           + STEP_MODE_1_4
-     *           + STEP_MODE_1_8
-     *           + STEP_MODE_1_16
-     *           + STEP_MODE_1_32
-     *           + STEP_MODE_1_64
-     *           + STEP_MODE_1_128
+     * @brief   Setting the Step Mode.
+     * @param   step_mode The Step Mode.
+     * @retval "true" in case of success, "false" otherwise.
+     * @warning Setting the step mode implies first disabling the power bridge through
+     *          the SoftHiZ() method.
+     * @warning Every time step mode is changed, the values of the home
+     *          and mark positions lose meaning and are reset.
      */
-    virtual void SetStepMode(motorStepMode_t step_mode)
+    virtual bool SetStepMode(step_mode_t step_mode)
     {
+        if ((motorStepMode_t) step_mode > STEP_MODE_1_16)
+            return false;
+
+        SoftHiZ();
         L6474_SelectStepMode((motorStepMode_t) step_mode);
+        return true;
     }
 
     /**