Skip to content

setAutoEnable() funcitonality #5

Closed
@devrim-oguz

Description

@devrim-oguz

@gin66 Thank you very much for this library. This is the best stepper library I have used so far. I can drive stepper motors really fast using an ESP32 thanks to this. However, there is a slight issue on the auto enable function while using the setCurrentPosition().
For example, if I try this code:

homeAxis();

fastStepper.init();
axisStepper = fastStepper.stepperConnectToPin(AXIS_MOTOR_STEP_PIN);

if( axisStepper ) {
    axisStepper->setDirectionPin(AXIS_MOTOR_DIRECTION_PIN);
    axisStepper->setEnablePin(AXIS_MOTOR_ENABLE_PIN);
    axisStepper->setAutoEnable(true);
}
else {
    ESP.restart();
}

axisStepper->setCurrentPosition(0);

delay(1500);
axisStepper->setSpeed(30);
axisStepper->setAcceleration(5000);
axisStepper->moveTo(550400);

It homes the steppers using directly turning on and off the pins and then it sets the position to 0. After that, it moves to a given position which it can't reach correctly. It always misses it with some margin. I think this is due to starting driving the motors as soon as you enable them, because some drivers takes some time to adjust before actually pushing steps. If I change the code like this:

if( axisStepper ) {
    axisStepper->setDirectionPin(AXIS_MOTOR_DIRECTION_PIN);
    axisStepper->setEnablePin(AXIS_MOTOR_ENABLE_PIN);
    //axisStepper->setAutoEnable(true); <-Commented this line
}
else {
    ESP.restart();
}

axisStepper->enableOutputs(); //Manually enabling the outputs and waiting a little after that
delay(200);
axisStepper->setCurrentPosition(0);

delay(1500);
axisStepper->setSpeed(30);
axisStepper->setAcceleration(5000);
axisStepper->moveTo(550400);

it works without a problem. I think you need to give some time to the drivers before actually pushing steps to them. I don't know if you'd have the same issue with other drivers, but this is the case with my HPD-HBS57 closed loop stepper driver. It never misses any step due to its closed loop nature, however it misses steps with autoEnable turned on. I think you should wait a little before disabling the stepper motors between the commands and wait a little before starting them. This way they can have some time to adjust, and they wouldn't get turned on and off when there isn't any command in the queue immediately.

Thank you

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions