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:
5:fd1315beea32
Parent:
4:265c30b9112a
--- a/Components/STSpin220/STSpin220.h	Fri Mar 24 13:54:23 2017 +0000
+++ b/Components/STSpin220/STSpin220.h	Fri Jul 28 13:28:00 2017 +0000
@@ -103,7 +103,9 @@
     {
         /* Checking stackability. */
         if (numberOfDevices!=0)
+        {
             error("Instantiation of the STSpin220 component failed: it can't be stacked on itself.\r\n");
+        }
 
         /* ACTION 4 ----------------------------------------------------------*
          * Initialize here the component's member variables, one variable per *
@@ -978,8 +980,14 @@
      */
     void STSpin220_Board_SetDirectionGpio(motorDir_t dir)
     {
-        if (dir==BACKWARD) direction_mode4 = 0;
-        else direction_mode4 = 1;
+        if (dir==BACKWARD)
+        {
+            direction_mode4 = 0;
+        }
+        else
+        {
+            direction_mode4 = 1;
+        }
     }
  
     /**
@@ -1040,9 +1048,21 @@
      */
     void STSpin220_Board_TimStckInit(bool check)
     {
-        if (monitor.is_connected()) monitor = 0;
-        if (check==false) stck_mode3 = 0;
-        else if (stck_mode3==1) STSpin220_ErrorHandler(STSPIN220_ERROR_STEP_CLOCK);
+        if (monitor.is_connected())
+        {
+            monitor = 0;
+        }
+        if (check==false)
+        {
+            stck_mode3 = 0;
+        }
+        else
+        {
+            if (stck_mode3==1)
+            {
+                STSpin220_ErrorHandler(STSPIN220_ERROR_STEP_CLOCK);
+            }
+        }
     }
 
     /**
@@ -1063,12 +1083,18 @@
 
     void STSpin220_Board_Monitor_Set(void)
     {
-        if (monitor.is_connected()) monitor = 1;
+        if (monitor.is_connected())
+        {
+            monitor = 1;
+        }
     }
     
     void STSpin220_Board_Monitor_Reset(void)
     {
-        if (monitor.is_connected()) monitor = 0;
+        if (monitor.is_connected())
+        {
+            monitor = 0;
+        }
     }
 
     /**