cancel
Showing results for 
Search instead for 
Did you mean: 

IHM02A1 L6470 muliple Boards

Christian Meinert
Associate
Posted on December 01, 2017 at 17:25

Hello,

I currently try to use more than one Stepper Motor Controller Board (3 to be precise) stacked. Every single one is working perfect with individual CS jumpers set by using the standard library from st - using the mBed OS.

But using the together don't work: Only the first Board (2 Motors) works. If I swap the CS definitions again only x_nucleo_ihm02a1_A object is working (so the first one initialized). Using only one board the FLAG Led work as expected (off after initialization). Using more than one the Led is always on.

Here are some screenshots from my logic analyzer:

0690X000006096RQAQ.png

as you can see only the first Board communicate during initialization. The following 2: silence. If I change the SC order again, only the 1st one communicate.

0690X00000608xlQAA.png

could it be that the SDI/SDO lines are not in 

I'm using the Nucleo ST32-L476RG board.

Parts of the Hello Word example code

/* Motor Control Expansion Board. */

XNucleoIHM02A1 *x_nucleo_ihm02a1_A;

XNucleoIHM02A1 *x_nucleo_ihm02a1_B;

XNucleoIHM02A1 *x_nucleo_ihm02a1_C;

DevSPI dev_spi(D11, D12, D3);        

DigitalOut active(D6);

active=false;

/* Initializing Motor Control Expansion Board. */

active=true;   

x_nucleo_ihm02a1_A =

new

XNucleoIHM02A1(&init[

0

], &init[

1

], A4, A5, D4, D2, &dev_spi);    

active=false;

active=true;

x_nucleo_ihm02a1_B =

new

XNucleoIHM02A1(&init[

0

], &init[

1

], A4, A5, D4, A2, &dev_spi);    

active=false;

active=true;

x_nucleo_ihm02a1_C =

new

XNucleoIHM02A1(&init[

0

], &init[

1

], A4, A5, D4, D5, &dev_spi);      

active=false;

/* Building a list of motor control components. */

        

L6470 **motors[

3

];    

motors[

0

] = x_nucleo_ihm02a1_A->get_components();    

motors[

1

] = x_nucleo_ihm02a1_B->get_components();    

motors[

2

] = x_nucleo_ihm02a1_C->get_components();      

pcTerminal.

printf

(

''Motor Control Application Example for 6 Motors\r\n\n''

);      

int

b;    

int

m;         

while

(

true

) {        

   for

(b=

0

; b<

3

; ++b) {            

     

for

(m=

0

; m<

2

; ++m) {                

         pcTerminal.

printf

(

''Board %d Motor %d Steps %d\r\n''

,b,m,STEPS_1);                

         motors[b][m]->move(StepperMotor::FWD, STEPS_1);                

         wait(

1

);            

      }

    }

Any suggestions / help appreciated.

#stm32 #ihm02a1 #stm32l476rg #mbed #l6470
1 REPLY 1
SBrie
Associate

Hey Christian,

How did you solve the problem? I have no solution for the same problem: I can just control one motor shield: If use the user button motors 1 and 2 are moving. Without the user button motors 3 and 4 are moving :

/**
 ******************************************************************************
 * @file    main.cpp
 * @author  Davide Aliprandi, STMicroelectronics
 * @version V1.0.0
 * @date    November 4th, 2015
 * @brief   mbed test application for the STMicroelectronics X-NUCLEO-IHM02A1
 *          Motor Control Expansion Board: control of 2 motors.
 ******************************************************************************
 * @attention
 *
 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *   1. Redistributions of source code must retain the above copyright notice,
 *      this list of conditions and the following disclaimer.
 *   2. Redistributions in binary form must reproduce the above copyright notice,
 *      this list of conditions and the following disclaimer in the documentation
 *      and/or other materials provided with the distribution.
 *   3. Neither the name of STMicroelectronics nor the names of its contributors
 *      may be used to endorse or promote products derived from this software
 *      without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 ******************************************************************************
 */
 
/* Includes ------------------------------------------------------------------*/
 
/* mbed specific header files. */
#include "mbed.h"
 
/* Helper header files. */
#include "DevSPI.h"
 
/* Expansion Board specific header files. */
#include "XNucleoIHM02A1.h"
 
DigitalIn B1(USER_BUTTON);
 
/* Definitions ---------------------------------------------------------------*/
 
/* Number of movements per revolution. */
#define MPR_1 4
 
/* Number of steps. */
#define STEPS_1 (20 * 128)   /* 1 revolution given a 400 steps motor configured at 1/128 microstep mode. */
#define STEPS_2 (STEPS_1 * 2)
 
/* Delay in milliseconds. */
#define DELAY_1 100
#define DELAY_2 200
#define DELAY_3 500
 
 
/* Variables -----------------------------------------------------------------*/
 
/* Motor Control Expansion Board. */
XNucleoIHM02A1 *x_nucleo_ihm02a1_a;
XNucleoIHM02A1 *x_nucleo_ihm02a1_b;
 
 
/* Initialization parameters of the motors connected to the expansion board. */
L6470_init_t init[L6470DAISYCHAINSIZE] = {
    /* First Motor. */
    {
        45.0,                           /* Motor supply voltage in V. */
        400,                           /* Min number of steps per revolution for the motor. */
        1.7,                           /* Max motor phase voltage in A. */
        3.06,                          /* Max motor phase voltage in V. */
        300.0,                         /* Motor initial speed [step/s]. */
        500.0,                         /* Motor acceleration [step/s^2] (comment for infinite acceleration mode). */
        500.0,                         /* Motor deceleration [step/s^2] (comment for infinite deceleration mode). */
        992.0,                         /* Motor maximum speed [step/s]. */
        0.0,                           /* Motor minimum speed [step/s]. */
        602.7,                         /* Motor full-step speed threshold [step/s]. */
        3.06,                          /* Holding kval [V]. */
        3.06,                          /* Constant speed kval [V]. */
        3.06,                          /* Acceleration starting kval [V]. */
        3.06,                          /* Deceleration starting kval [V]. */
        61.52,                         /* Intersect speed for bemf compensation curve slope changing [step/s]. */
        392.1569e-6,                   /* Start slope [s/step]. */
        643.1372e-6,                   /* Acceleration final slope [s/step]. */
        643.1372e-6,                   /* Deceleration final slope [s/step]. */
        0,                             /* Thermal compensation factor (range [0, 15]). */
        3.06 * 1000 * 1.10,            /* Ocd threshold [ma] (range [375 ma, 6000 ma]). */
        3.06 * 1000 * 1.00,            /* Stall threshold [ma] (range [31.25 ma, 4000 ma]). */
        StepperMotor::STEP_MODE_1_128, /* Step mode selection. */
        0xFF,                          /* Alarm conditions enable. */
        0x2E88                         /* Ic configuration. */
    },
 
    /* Second Motor. */
    {
        45.0,                           /* Motor supply voltage in V. */
        400,                           /* Min number of steps per revolution for the motor. */
        1.7,                           /* Max motor phase voltage in A. */
        3.06,                          /* Max motor phase voltage in V. */
        300.0,                         /* Motor initial speed [step/s]. */
        500.0,                         /* Motor acceleration [step/s^2] (comment for infinite acceleration mode). */
        500.0,                         /* Motor deceleration [step/s^2] (comment for infinite deceleration mode). */
        992.0,                         /* Motor maximum speed [step/s]. */
        0.0,                           /* Motor minimum speed [step/s]. */
        602.7,                         /* Motor full-step speed threshold [step/s]. */
        3.06,                          /* Holding kval [V]. */
        3.06,                          /* Constant speed kval [V]. */
        3.06,                          /* Acceleration starting kval [V]. */
        3.06,                          /* Deceleration starting kval [V]. */
        61.52,                         /* Intersect speed for bemf compensation curve slope changing [step/s]. */
        392.1569e-6,                   /* Start slope [s/step]. */
        643.1372e-6,                   /* Acceleration final slope [s/step]. */
        643.1372e-6,                   /* Deceleration final slope [s/step]. */
        0,                             /* Thermal compensation factor (range [0, 15]). */
        3.06 * 1000 * 1.10,            /* Ocd threshold [ma] (range [375 ma, 6000 ma]). */
        3.06 * 1000 * 1.00,            /* Stall threshold [ma] (range [31.25 ma, 4000 ma]). */
        StepperMotor::STEP_MODE_1_128, /* Step mode selection. */
        0xFF,                          /* Alarm conditions enable. */
        0x2E88                         /* Ic configuration. */
    }
};
 
 
/* Main ----------------------------------------------------------------------*/
 
int main()
{
    /* Initializing Motor Control Expansion Board. */
    if(B1==0)
    {
        x_nucleo_ihm02a1_b = new XNucleoIHM02A1(&init[0], &init[1], A4, A5, D4, D10, D11, D12, D13);
        x_nucleo_ihm02a1_a = new XNucleoIHM02A1(&init[0], &init[1], A4, A5, D4, A2, D11, D12, D13);
    }
    else
    {
        x_nucleo_ihm02a1_a = new XNucleoIHM02A1(&init[0], &init[1], A4, A5, D4, A2, D11, D12, D13);
        x_nucleo_ihm02a1_b = new XNucleoIHM02A1(&init[0], &init[1], A4, A5, D4, D10, D11, D12, D13);
    }
 
    /* Building a list of motor control components. */
    L6470 **motors_a = x_nucleo_ihm02a1_a->get_components();
    L6470 **motors_b = x_nucleo_ihm02a1_b->get_components();
 
    /* Moving Motors */
    motors_a[0]->move(StepperMotor::FWD, STEPS_1);
    motors_a[1]->move(StepperMotor::FWD, STEPS_1);
    motors_b[0]->move(StepperMotor::FWD, STEPS_1);
    motors_b[1]->move(StepperMotor::FWD, STEPS_1);
    
    printf("Ende gut alles gut \r\n");
}