Compiles, and motor driver shields work individually--but not together

AI Thread Summary
The discussion revolves around issues encountered while programming two motor control expansion boards using Mbed's Hello World program. The user is attempting to initialize two instances of the XNucleoIHM02A1 board but faces a problem where only one instance operates correctly when both are included in the code. The motors do not respond when both instances are uploaded to the board, despite the code compiling without warnings. The user seeks assistance in understanding why the simultaneous initialization fails and how to resolve the issue. Relevant hardware documentation links are provided for further reference.
adamaero
Messages
109
Reaction score
1
TL;DR Summary
I'm using an STM32F767 MCU along with two shields: IHM02A1 dual stepper motor driver.
I don't have a debugger yet, but my company is getting one...

In the mean time, I've been un/commenting out parts of Mbed's code. Their Hello World program is available from this website, and it can be used directly in their online IDE by clicking "Import Program": https://os.mbed.com/components/X-NUCLEO-IHM03A1/
Code:
#include "mbed.h"
#include "DevSPI.h"
#include "XNucleoIHM02A1.h"

#define MPR_1 4 /* Number of movements per revolution. */

#define STEPS_1 (200 * 128)   /* 1 revolution given a 200 steps motor configured at 1/128 microstep mode. */
#define STEPS_2 (STEPS_1 * 2)

/* Delay in milliseconds. */
#define DELAY_1 1000
#define DELAY_2 2000
#define DELAY_3 3000

/* Motor Control Expansion Board. */
XNucleoIHM02A1 *x_nucleo_ihm02a1;
XNucleoIHM02A1 *x_nucleo_ihm02a1two;

/* Initialization parameters of the motors connected to the expansion board. */
L6470_init_t init[L6470DAISYCHAINSIZE] = {
    /* First Motor. */
    {
        24.0,                          /* Motor supply voltage in V. */
        200,                           /* 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. */
    {
        24.0,                           /* Motor supply voltage in V. */
        200,                           /* 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. */
    }
};

int main()
{
    /* Initializing SPI bus. */
#ifdef TARGET_STM32F429
    DevSPI dev_spi(D11, D12, D13);

#else
    DevSPI dev_spi(D11, D12, D13);
#endif

    /* Initializing Motor Control Expansion Board. */
    x_nucleo_ihm02a1 =    new XNucleoIHM02A1(&init[0], &init[1], A4, A5, D4, D2, &dev_spi);
    x_nucleo_ihm02a1two = new XNucleoIHM02A1(&init[0], &init[1], A4, A5, D4, A2, &dev_spi);  

    /* Building a list of motor control components. */
    L6470 **motors = x_nucleo_ihm02a1->get_components();
    L6470 **motorstwo = x_nucleo_ihm02a1two->get_components();

    /* Setting the home position. */
    //motorstwo[1]->set_home();
//    wait_ms(DELAY_1);
    int position = motorstwo[1]->get_position();
    wait_ms(DELAY_1);
         
//      motors[1]->move(StepperMotor::FWD, STEPS_2);
//      motors[0]->move(StepperMotor::FWD, STEPS_2);    
//    wait_ms(DELAY_2);
      motorstwo[1]->move(StepperMotor::FWD, STEPS_2);
      motorstwo[0]->move(StepperMotor::FWD, STEPS_2);
    
    position = motorstwo[1]->get_position();
    wait_ms(DELAY_1); 
        
}

That's a minimum reproducible example of the full program. If you want to try it out yourself, simply copy/paste it into main.cpp (in the online IDE noted above).

Everything complies, no warnings. Either of the lines below (with their matching pointers and such) works by moving the motors. I.e., motorstwo[x] and motors[x] both work out on their own. But when both lines are loaded unto the board...nothing works, the motors do not move. The steppers don't even have a very soft sound coming from them.

Code:
    x_nucleo_ihm02a1 =    new XNucleoIHM02A1(&init[0], &init[1], A4, A5, D4, D2, &dev_spi);
    x_nucleo_ihm02a1two = new XNucleoIHM02A1(&init[0], &init[1], A4, A5, D4, A2, &dev_spi);

Why can't these two lines be uploaded together? How can this be fixed? Thanks.
 
Technology news on Phys.org
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...

Similar threads

Replies
1
Views
7K
Back
Top