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:
17:35b9ca8c4bd6
Parent:
16:bec7dd79f328
Child:
18:2d6ab2b93685
diff -r bec7dd79f328 -r 35b9ca8c4bd6 Components/l6474/l6474_class.h
--- a/Components/l6474/l6474_class.h	Mon Dec 14 17:25:36 2015 +0000
+++ b/Components/l6474/l6474_class.h	Mon Jan 04 15:54:07 2016 +0000
@@ -97,6 +97,10 @@
      */
     L6474(PinName flag_irq, PinName standby_reset, PinName direction, PinName pwm, PinName ssel, DevSPI &spi) : StepperMotor(), flag_irq(flag_irq), standby_reset(standby_reset), direction(direction), pwm(pwm), ssel(ssel), dev_spi(spi)
     {
+        /* Checking stackability. */
+        if (!(numberOfDevices < MAX_NUMBER_OF_DEVICES))
+            error("Instantiation of the L6474 component failed: it can be stacked up to %d times.\r\n", MAX_NUMBER_OF_DEVICES);
+
         /* ACTION 4 ----------------------------------------------------------*
          * Initialize here the component's member variables, one variable per *
          * line.                                                              *
@@ -106,8 +110,7 @@
          *   instance_id = number_of_instances++;                             *
          *--------------------------------------------------------------------*/
         errorHandlerCallback = 0;
-        deviceInstance = numberOfDevices;
-        numberOfDevices++;
+        deviceInstance = numberOfDevices++;
         memset(spiTxBursts, 0, L6474_CMD_ARG_MAX_NB_BYTES * MAX_NUMBER_OF_DEVICES * sizeof(uint8_t));
         memset(spiRxBursts, 0, L6474_CMD_ARG_MAX_NB_BYTES * MAX_NUMBER_OF_DEVICES * sizeof(uint8_t));
     }
@@ -155,7 +158,7 @@
      * @param  id Pointer to an allocated variable to store the ID into.
      * @retval "0" in case of success, an error code otherwise.
      */
-    virtual int ReadID(uint8_t *id)
+    virtual int ReadID(uint8_t *id = NULL)
     {
         return (int) L6474_ReadID((uint8_t *) id);
     }