Hi, in my final year project there is a turning table that it turn quart of circle after a moment with a high precision.
i decide to use the enable pin instead of sleep pin , but the motor jitter only one time is when i set the sleep pin to LOW for the first time ,after , the motor work perfectly .
video of the problem : Stepper motor jitter - YouTube
/*Example sketch to control a stepper motor with DRV8825 stepper motor driver AccelStepper library and Arduino. More info: https://www.makerguides.com */
#include <AccelStepper.h>
//Define stepper motor connections
#define dirPin 8
#define stepPin 7
const int sleepPin = 6;
const int enablePin = 4;
//Create stepper object
AccelStepper stepper(1,stepPin,dirPin); //motor interface type must be set to 1 when using a driver.
void setup()
{
Serial.begin(9600);
pinMode(enablePin,OUTPUT);
pinMode(sleepPin,OUTPUT);
digitalWrite(enablePin,HIGH);
Serial.println("En was set to HIGH");
delay(100);
digitalWrite(sleepPin,HIGH);
Serial.println("Slp was set to high");
delay(100);
digitalWrite(enablePin,LOW); // The motore jetter here !!!!!
Serial.println("EN was set to low");
delay(100);
stepper.setMaxSpeed(1000); //maximum steps per second
}
void loop(){
Serial.println("Turn");
digitalWrite(enablePin,LOW);
delay(5);
stepper.setCurrentPosition(0); //set the current position to 0
while(stepper.currentPosition() != 400)
{
stepper.setSpeed(100);
stepper.runSpeed();
}
delay(1000);
digitalWrite(enablePin,HIGH);
delay(1000);
}