I'm using the AccelStepper library with a Pololu style DRV8825 driver. I have seen weird behaviour when trying move negative values (i.e counter clockwise) that I think I've narrowed down to run() (because runSpeedToPosition() works )
If I run this minimal example, the motor spins continously, slowing in speed. It never stops. literally.
//Minimum Working Example for accelstepper problem
#define MOTHERBOARD 3 // AccelStepper Driver compatible (easydriver/pololu)
#include <Wire.h>
#include <MultiStepper.h>
#include <AccelStepper.h>
#include <Arduino.h>
AccelStepper m1(1,2,3); //initialise accelstepper for a two wire board, pin 5 step, pin 4 dir
void setup() {
Serial.begin(115200);
// put your setup code here, to run once:
m1.setEnablePin(4); //These give compilation errors that these don't exist !
m1.setPinsInverted(false, false, true); //For boards that enable=low
m1.setAcceleration(10000); //set acceleration, even though we only single step
m1.setMaxSpeed(10000);
m1.enableOutputs();
void loop() {
Serial.print("Loop ");
int i;
long pos = -50;
Serial.print("M1 cp"); Serial.println(m1.currentPosition());
m1.moveTo(m1.currentPosition()+pos);
m1.setSpeed(1000);
Serial.print("M1 dtg"); Serial.println(m1.distanceToGo());
while (m1.distanceToGo() != 0) {
m1.run();
Serial.print("M1 dtg"); Serial.println(m1.distanceToGo());
}
delay(500);
}
However, If I change it to this example, it works as expected (i.e it moves 50 steps anti clockwise, then pauses and repeats, just at a constant speed)
//Minimum Working Example for accelstepper problem
#define MOTHERBOARD 3 // AccelStepper Driver compatible (easydriver/pololu)
#include <Wire.h>
#include <MultiStepper.h>
#include <AccelStepper.h>
#include <Arduino.h>
AccelStepper m1(1,2,3); //initialise accelstepper for a two wire board, pin 5 step, pin 4 dir
void setup() {
Serial.begin(115200);
// put your setup code here, to run once:
m1.setEnablePin(4); //These give compilation errors that these don't exist !
m1.setPinsInverted(false, false, true); //For boards that enable=low
m1.setAcceleration(10000); //set acceleration, even though we only single step
m1.setMaxSpeed(10000);
m1.enableOutputs();
void loop() {
Serial.print("Loop ");
int i;
long pos = -50;
Serial.print("M1 cp"); Serial.println(m1.currentPosition());
m1.moveTo(m1.currentPosition()+pos);
m1.setSpeed(1000);
Serial.print("M1 dtg"); Serial.println(m1.distanceToGo());
while (m1.distanceToGo() != 0) {
m1.runSpeedToPosition();
Serial.print("M1 dtg"); Serial.println(m1.distanceToGo());
}
delay(500);
}
I don't see this problem with positive values of pos (i.e positive / clockwise movements)
Any ideas ?
Paul.