cancel
Showing results for 
Search instead for 
Did you mean: 

Beginners question: IHM01A1 + Stepper - What am I doing wrong

MDaub.1
Associate III

I am an owner of the STEVAL-EDUKIT, an inverted pendulum kit by ST with an NUCLEO-F401RE, IHM01A1, Nema17 motor and an rotary encoder + a 2A, 12V power supply. I have no prior experience with motor control whatsoever. See https://www.st.com/content/st_com/en/products/evaluation-tools/solution-evaluation-tools/motor-control-solution-eval-boards/stepper-motors/steval-edukit01.html for a picture how the whole apparatus looks like when assembled.

The provided demo firmware works well and I am studying the source code. I now want to achieve a swing-up of the pendulum from the down position and basically what I want to do is to have the motor do a 1/4 turn with high speed/torque/power. During experimentation I saw that turning the tower with my hand for 120 degrees in a quick flick, the pendulum gets enough energy to swing up. So I now want to try to mimic this with a one shot quick, forceful motor movement.

Basically I am trying to do this:

BSP_MotorControl_SetNbDevices(BSP_MOTOR_CONTROL_BOARD_ID_L6474, 1);
 
BSP_MotorControl_Init(BSP_MOTOR_CONTROL_BOARD_ID_L6474, &gL6474InitParams_SwingUp);
 
BSP_MotorControl_Move(0, FORWARD, 90);
BSP_MotorControl_WaitWhileActive(0);
 
// Hold it
while (true);
 
 

I noticed that no matter what I tried for BSP_MotorControl_SetMinSpeed, BSP_MotorControl_SetMaxSpeed, BSP_MotorControl_SetAcceleration, etc.. it had very little effect on the actual movement. Then I recognized that apparently it's the step size which was stopping me from fast turns. It was set to 1/16 in the init structure.

L6474_Init_t gL6474InitParams_SwingUp =
{
    80,                               /// Acceleration rate in step/s2. Range: (0..+inf).
    80,                               /// Deceleration rate in step/s2. Range: (0..+inf).
    160,                              /// Maximum speed in step/s. Range: (30..10000].
    160,                               ///Minimum speed in step/s. Range: [30..10000).
    1000,                               ///Torque regulation current in mA. (TVAL register) Range: 31.25mA to 4000mA.
	2000,                              ///Overcurrent threshold (OCD_TH register). Range: 375mA to 6000mA.
    L6474_CONFIG_OC_SD_ENABLE,         ///Overcurrent shutwdown (OC_SD field of CONFIG register).
    L6474_CONFIG_EN_TQREG_TVAL_USED,   /// Torque regulation method (EN_TQREG field of CONFIG register).
    L6474_STEP_SEL_1_16,               /// Step selection (STEP_SEL field of STEP_MODE register).
    L6474_SYNC_SEL_1_2,                /// Sync selection (SYNC_SEL field of STEP_MODE register).
    L6474_FAST_STEP_12us,              /// Fall time value (T_FAST field of T_FAST register). Range: 2us to 32us.
    L6474_TOFF_FAST_8us,               /// Maximum fast decay time (T_OFF field of T_FAST register). Range: 2us to 32us.
    3,                                 /// Minimum ON time in us (TON_MIN register). Range: 0.5us to 64us.
    21,                                /// Minimum OFF time in us (TOFF_MIN register). Range: 0.5us to 64us.
    L6474_CONFIG_TOFF_044us,           /// Target Swicthing Period (field TOFF of CONFIG register).
    L6474_CONFIG_SR_320V_us,           /// Slew rate (POW_SR field of CONFIG register).
    L6474_CONFIG_INT_16MHZ,            /// Clock setting (OSC_CLK_SEL field of CONFIG register).
    (L6474_ALARM_EN_OVERCURRENT      |
     L6474_ALARM_EN_THERMAL_SHUTDOWN |
     L6474_ALARM_EN_THERMAL_WARNING  |
     L6474_ALARM_EN_UNDERVOLTAGE     |
     L6474_ALARM_EN_SW_TURN_ON       |
     L6474_ALARM_EN_WRONG_NPERF_CMD)    /// Alarm (ALARM_EN register).
};

When I set L6474_STEP_SEL_1_16 to L6474_STEP_SEL_1_8 or L6474_STEP_SEL_1_4, the movement was immediately MUCH QUICKER and powerful which is somewhat easy to explain as the stepper now could do a more coarse movement. However it was still not quick enough so I wanted to try L6474_STEP_SEL_1_2 or L6474_STEP_SEL_1 but when I set it to L6474_STEP_SEL_1 the motor won't turn any more or very unprecise. It was merely rattling and it sounded as if the crank shaft moved inside but did not take the pendulum with it.

I was playing with the other settings in the struct like Acceleration, Min/Max Speed and the Torque Current but it was only the Torque Current that when set to 1000mA or even higher that had a noticeable effect. It was somewhat moving the pendulum but still it sounded/looked as if the motor would like to turn it for 90 degrees, but only took the whole thing for like 30 degrees or so with rattling. As if some some gears where slipping or so.

When I remove the whole rotary encoder/pendulum on top and just fixed a piece of paper to the motor shaft and let it turn, it did so without any problem or uncleanliness and the shaft is turning with like 3 full revolutions/sec if I tell it so in the code. So, without weight/burden the motor was indeed very quick.

So the following questions arise:

  • Why doesn't the motor take the pendulum with it in step size 1/1 mode? I'd say the total weight is just 100-200g and I read about stepper motors pulling weights of several kilos if need be?
  • What settings do I need to set in the Init structure? What is a good value for Torque Current for this setup? I am nervous to overheat/break/damage something when I go higher than I am allowed to. Is the upper bound the motor itself? What is the maximum current the motor would allow? The L6474 does not seem to be the limiting factor in this game? Do i need to change L6474_SYNC_SEL_1_2 as well, when I change L6474_STEP_SEL_*?
  • I didn't find a good explanation of what all those elements in the Init Structure mean. Is there a detailed description? For example I presume "Overcurrent threshold (OCD_TH register)" should be set to what my power supply can supply? Or is it limited to use the value of the motor? (That I don't know?)
  • Is my goal reachable at all with that setup or would I need a more powerful motor, power supply (higher voltage, higher current?)
  • Why is it no problem when using step size 1/16 to turn 1/4 circle (albeit slower then) with a setting of only 200mA of "Torque current setting" but 1/1 steps or 1/2 steps seem to need a much higher current for the motor to move? In the end it's the same weight, the same distance etc.?

Thank you

0 REPLIES 0