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:
9:d70452d7a1e1
Parent:
3:e3f6f4474d98
Child:
10:aa68441705b2
--- a/BSP/x_nucleo_ihm02a1_class.cpp	Thu Dec 10 15:42:20 2015 +0000
+++ b/BSP/x_nucleo_ihm02a1_class.cpp	Fri Dec 11 17:23:31 2015 +0000
@@ -57,74 +57,20 @@
 /* Number of instantiated expansion boards. */
 uint8_t X_NUCLEO_IHM02A1::number_of_boards = 0;
 
-/**
-  * @brief This array contains the initial parameters for the motors that are
-  *        linked with each L6470 mounted on each stacked X-NUCLEO-IHM02A1.
-  */
-const MICROSTEPPING_MOTOR_InitTypeDef X_NUCLEO_IHM02A1::MotorParameterInitData[EXPBRD_MOUNTED_NR_MAX][L6470DAISYCHAINSIZE] =
-{
-  {
-    {
-      9.0, 400, 1.7, 3.06, 300.0, 500.0, 500.0, 992.0, 0.0, 602.7, 3.06, 3.06,\
-      3.06, 3.06, 61.52, 392.1569e-6, 643.1372e-6, 643.1372e-6, 0,\
-      3.06*1000*1.10, 3.06*1000*1.00, MICROSTEP_1_128, 0xFF, 0x2E88
-    },
-    {
-      9.0, 400, 1.7, 3.06, 300.0, 500.0, 500.0, 992.0, 0.0, 602.7, 3.06, 3.06,\
-      3.06, 3.06, 61.52, 392.1569e-6, 643.1372e-6, 643.1372e-6, 0,\
-      3.06*1000*1.10, 3.06*1000*1.00, MICROSTEP_1_128, 0xFF, 0x2E88
-    },
-  },
-  {
-    {
-      9.0, 400, 1.7, 3.06, 300.0, 500.0, 500.0, 992.0, 0.0, 602.7, 3.06, 3.06,\
-      3.06, 3.06, 61.52, 392.1569e-6, 643.1372e-6, 643.1372e-6, 0,\
-      3.06*1000*1.10, 3.06*1000*1.00, MICROSTEP_1_128, 0xFF, 0x2E88
-    },
-    {
-      9.0, 400, 1.7, 3.06, 300.0, 500.0, 500.0, 992.0, 0.0, 602.7, 3.06, 3.06,\
-      3.06, 3.06, 61.52, 392.1569e-6, 643.1372e-6, 643.1372e-6, 0,\
-      3.06*1000*1.10, 3.06*1000*1.00, MICROSTEP_1_128, 0xFF, 0x2E88
-    },
-  },
-  {
-    {
-      9.0, 400, 1.7, 3.06, 300.0, 500.0, 500.0, 992.0, 0.0, 602.7, 3.06, 3.06,\
-      3.06, 3.06, 61.52, 392.1569e-6, 643.1372e-6, 643.1372e-6, 0,\
-      3.06*1000*1.10, 3.06*1000*1.00, MICROSTEP_1_128, 0xFF, 0x2E88
-    },
-    {
-      9.0, 400, 1.7, 3.06, 300.0, 500.0, 500.0, 992.0, 0.0, 602.7, 3.06, 3.06,\
-      3.06, 3.06, 61.52, 392.1569e-6, 643.1372e-6, 643.1372e-6, 0,\
-      3.06*1000*1.10, 3.06*1000*1.00, MICROSTEP_1_128, 0xFF, 0x2E88
-    },
-  },
-  {
-    {
-      9.0, 400, 1.7, 3.06, 300.0, 500.0, 500.0, 992.0, 0.0, 602.7, 3.06, 3.06,\
-      3.06, 3.06, 61.52, 392.1569e-6, 643.1372e-6, 643.1372e-6, 0,\
-      3.06*1000*1.10, 3.06*1000*1.00, MICROSTEP_1_128, 0xFF, 0x2E88
-    },
-    {
-      9.0, 400, 1.7, 3.06, 300.0, 500.0, 500.0, 992.0, 0.0, 602.7, 3.06, 3.06,\
-      3.06, 3.06, 61.52, 392.1569e-6, 643.1372e-6, 643.1372e-6, 0,\
-      3.06*1000*1.10, 3.06*1000*1.00, MICROSTEP_1_128, 0xFF, 0x2E88
-    },
-  },
-};
-
 
 /* Methods -------------------------------------------------------------------*/
 
 /**
  * @brief Constructor.
+ * @param init_0        pointer to the initialization structure of the first motor.
+ * @param init_1        pointer to the initialization structure of the second motor.
  * @param flag_irq      pin name of the FLAG pin of the component.
  * @param busy_irq      pin name of the BUSY pin of the component.
  * @param standby_reset pin name of the STBY\RST pin of the component.
  * @param ssel          pin name of the SSEL pin of the SPI device to be used for communication.
  * @param spi           SPI device to be used for communication.
  */
-X_NUCLEO_IHM02A1::X_NUCLEO_IHM02A1(PinName flag_irq, PinName busy_irq, PinName standby_reset, PinName ssel, DevSPI *spi) : dev_spi(spi)
+X_NUCLEO_IHM02A1::X_NUCLEO_IHM02A1(MICROSTEPPING_MOTOR_InitTypeDef *init_0, MICROSTEPPING_MOTOR_InitTypeDef *init_1, PinName flag_irq, PinName busy_irq, PinName standby_reset, PinName ssel, DevSPI *spi) : dev_spi(spi)
 {
     /* SPI communication. */
     if (dev_spi == NULL)
@@ -143,12 +89,16 @@
     components[1] = l6470_1 = new L6470(flag_irq, busy_irq, standby_reset, ssel, *dev_spi);
 
     /* Initializing the components. */
+    init_components[0] = init_0;
+    init_components[1] = init_1;
     if (!Init())
         error("Initialization of the X_NUCLEO_IHM02A1 expansion board failed.\n");
 }
 
 /**
  * @brief Constructor.
+ * @param init_0        pointer to the initialization structure of the first motor.
+ * @param init_1        pointer to the initialization structure of the second motor.
  * @param flag_irq      pin name of the FLAG pin of the component.
  * @param busy_irq      pin name of the BUSY pin of the component.
  * @param standby_reset pin name of the STBY\RST pin of the component.
@@ -157,7 +107,7 @@
  * @param miso          pin name of the MISO pin of the SPI device to be used for communication.
  * @param sclk          pin name of the SCLK pin of the SPI device to be used for communication.
  */
-X_NUCLEO_IHM02A1::X_NUCLEO_IHM02A1(PinName flag_irq, PinName busy_irq, PinName standby_reset, PinName ssel, PinName mosi, PinName miso, PinName sclk)
+X_NUCLEO_IHM02A1::X_NUCLEO_IHM02A1(MICROSTEPPING_MOTOR_InitTypeDef *init_0, MICROSTEPPING_MOTOR_InitTypeDef *init_1, PinName flag_irq, PinName busy_irq, PinName standby_reset, PinName ssel, PinName mosi, PinName miso, PinName sclk)
 {
     /* SPI communication. */
     dev_spi = new DevSPI(mosi, miso, sclk);
@@ -175,6 +125,8 @@
     components[1] = l6470_1 = new L6470(flag_irq, busy_irq, standby_reset, ssel, *dev_spi);
 
     /* Initializing the components. */
+    init_components[0] = init_0;
+    init_components[1] = init_1;
     if (!Init())
         error("Initialization of the X_NUCLEO_IHM02A1 expansion board failed.\n");
 }
@@ -231,7 +183,7 @@
 bool X_NUCLEO_IHM02A1::Init_L6470_0(void)
 {
     /* Initialization. */
-    if (l6470_0->Init((void *) &MotorParameterInitData[X_NUCLEO_IHM02A1_Id][0]) != COMPONENT_OK)
+    if (l6470_0->Init((void *) init_components[0]) != COMPONENT_OK)
         return false;
 
     return true;
@@ -244,7 +196,7 @@
 bool X_NUCLEO_IHM02A1::Init_L6470_1(void)
 {
     /* Initialization. */
-    if (l6470_1->Init((void *) &MotorParameterInitData[X_NUCLEO_IHM02A1_Id][1]) != COMPONENT_OK)
+    if (l6470_1->Init((void *) init_components[0]) != COMPONENT_OK)
         return false;
 
     return true;