Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 10 months ago.
HelloWorld for two stacked IHM02A1 boards
Hello ST-Team, I really enjoy your work at the hole STM32 Nucleo project. I now woud like to use two IHM02A1 expansion board stacked on the NUCLEO-F302R8.
I modified your HelloWorld_IHM02A1 for the second expansion board. But I still can use one board at the same time. In the example I can change the order of the initializing of the expansion boards with the result that it chanche the working expansion board.
Can you please help my with a correction of my code or another HelloWorld example with multiple IHM02A1 boards?
Yours faithfully, Sven Brieden
minimal example: HelloWorld for two stacked IHM02A1
/* Includes ------------------------------------------------------------------*/
/* mbed specific header files. */
#include "mbed.h"
/* Helper header files. */
#include "DevSPI.h"
/* Expansion Board specific header files. */
#include "XNucleoIHM02A1.h"
DigitalIn User_Button(USER_BUTTON);
/* Definitions ---------------------------------------------------------------*/
/* 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(User_Button==1)
{ /* If I press the button only x_nucleo_ihm02a1_a is working */
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);
}
else
{ /* In this case only x_nucleo_ihm02a1_b works*/
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);
}
/* 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 */
printf("Moving motors from Board 1 \r\n");
motors_a[0]->move(StepperMotor::FWD, 20 * 128);
motors_a[1]->move(StepperMotor::FWD, 20 * 128);
wait_ms(2000);
printf("Moving motors from Board 2 \r\n");
motors_b[0]->move(StepperMotor::FWD, 20 * 128);
motors_b[1]->move(StepperMotor::FWD, 20 * 128);
}
Question relating to:
1 Answer
6 years, 8 months ago.
Hi Sven and ST-Team,
I have the same problem with the NUCLEOF401RE. x_nucleo_ihm02a1_2 = new XNucleoIHM02A1(&init[0], &init[1],A4, A5, D4, A2, D11, D12, D3 ); x_nucleo_ihm02a1_1 = new XNucleoIHM02A1(&init[0], &init[1], A4, A5, D4, D2, D11, D12, D3 ); The nCS pins are soldered correctly on SB23 and SB7
I'd appreciate it very much if you could help
Yours faithfully, Fabian Scherrer