Friday, February 26, 2021

Enable hardware AccelStepper.h RAMPS 1.4 Arduino stepper bounce A4988 DRV8825 TMC


 The example from the AccelStepper source doesn't include that you have to enable the hardware before it can work. It took me a while before i figured that out...

#include <AccelStepper.h>
AccelStepper stepper1(AccelStepper::DRIVER, A0, A1);

void setup()
{   
    stepper1.setEnablePin(38);
    stepper1.setPinsInverted(false, false, true);
    stepper1.enableOutputs();
    stepper1.setMaxSpeed(30.0);
    stepper1.setAcceleration(30.0);
    stepper1.moveTo(420);
}
void loop()
{
    // Change direction at the limits
    if (stepper1.currentPosition()==420)
        stepper1.moveTo(0);
    if (stepper1.currentPosition()==0)
        stepper1.moveTo(420);

    stepper1.run();
}