Skip to content

Wrong position when using moveTo on esp32? #60

@OT12345

Description

@OT12345

Hi, im having issues with the stepper moving to wrong position when i run the example code, seems like it only moves wrong when going in reverse, to little. This is a awesome library if the position is correct :)

im not using the enable pin, its is connected to ground (on).
the stepper im using is a nema23 closed loop with the driver directly on top of it.

#include "FastAccelStepper.h"

// As in StepperDemo for Motor 1 on AVR
//#define dirPinStepper    5
//#define enablePinStepper 6
//#define stepPinStepper   9  // OC1A in case of AVR

// As in StepperDemo for Motor 1 on ESP32
#define dirPinStepper 17
#define enablePinStepper -1
#define stepPinStepper 16

FastAccelStepperEngine engine = FastAccelStepperEngine();
FastAccelStepper *stepper = NULL;

void setup() {
  engine.init();
  stepper = engine.stepperConnectToPin(stepPinStepper);
  if (stepper) {
    stepper->setDirectionPin(dirPinStepper);
    stepper->setEnablePin(enablePinStepper);
    stepper->setAutoEnable(true);

    // If auto enable/disable need delays, just add (one or both):
    // stepper->setDelayToEnable(50);
    // stepper->setDelayToDisable(1000);

    stepper->setSpeedInUs(200);  // the parameter is us/step !!!
    stepper->setAcceleration(5000);
    
  }
}

void loop() {
  
  stepper->moveTo(10000);
  delay(2000);
  stepper->moveTo(5000);
  delay(2000);
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions