I'm not quite sure if this is a programming question or better suited for this forum.
I'm using an STM32F767 MCU along with two shields: IHM02A1 dual stepper motor driver.
Here are steps I did for the IHM02A1s:
4. Change:x_nucleo_ihm02a1 = new XNucleoIHM02A1(&init[2], &init[3], A4, A5, D4, D2, &dev_spi);
https://www.mouser.com/ds/2/389/x-nucleo-ihm02a1-954332.pdf#page=5
Mbed's online IDE does not have a debugger. I do not have one right now, but I will eventually...Keil uVision's 32 kB max project limit was :/
In short, the bottom shield works (moves motors). The top shield does not actually cause the motors to move.
The original program is here: os.mbed.com/components/X-NUCLEO-IHM02A1
(If you want, click "Import" on the Hello World example.)
I think this is the minimum reproducible form of it:
Here's the same version, just a bit easier to read:
https://github.com/adamaero/HelloWorld_IHM02A1mbed/blob/master/test.cpp
I could change the bottom two motors by changing motors[0] or motors[1], respectively.
So I would think getting the second motor on the second shield would be motors[3]...
I'm using an STM32F767 MCU along with two shields: IHM02A1 dual stepper motor driver.
Here are steps I did for the IHM02A1s:
1. On both shields, unsolder SB34 and solder SB12.
2. Change this in main.cpp:
dev_spi = new SPIClass(D11, D12, D13);2. Change this in main.cpp:
3. On the second (top) shield, unsolder SB23 and solder SB7. "So, when using more than one expansion board, the user must short a different solder bridge among SB7, SB8, SB9 and SB23, for each X-NUCLEO-IHM02A1."
st.com/content/ccc/resource/technical/document/user_manual/group0/9c/49/e6/da/a3/75/48/b9/DM00237629/files/DM00237629.pdf/jcr:content/translations/en.DM00237629.pdf#page=114. Change:
https://www.mouser.com/ds/2/389/x-nucleo-ihm02a1-954332.pdf#page=5
Mbed's online IDE does not have a debugger. I do not have one right now, but I will eventually...Keil uVision's 32 kB max project limit was :/
In short, the bottom shield works (moves motors). The top shield does not actually cause the motors to move.
The original program is here: os.mbed.com/components/X-NUCLEO-IHM02A1
(If you want, click "Import" on the Hello World example.)
I think this is the minimum reproducible form of it:
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_3 5000
/* Motor Control Expansion Board. */
XNucleoIHM02A1 *x_nucleo_ihm02a1;
/* 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[2], &init[3], A4, D2, D4, A2, &dev_spi);
//
/* Building a list of motor control components. */
L6470 **motors = x_nucleo_ihm02a1->get_components();
/* Setting the home position. */
motors[3]->set_home();
wait_ms(DELAY_1);
int position = motors[3]->get_position();
wait_ms(DELAY_1);
motors[3]->move(StepperMotor::BWD, STEPS_2);
motors[3]->wait_while_active();
wait_ms(DELAY_1);
position = motors[3]->get_position();
wait_ms(DELAY_1);
}
https://github.com/adamaero/HelloWorld_IHM02A1mbed/blob/master/test.cpp
I could change the bottom two motors by changing motors[0] or motors[1], respectively.
So I would think getting the second motor on the second shield would be motors[3]...
Attachments
-
314.8 KB Views: 1
Last edited: