2021-05-24 09:18 AM
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:
Thank you