I wrote a program that makes one revolution on my stepper motor. It uses the Accelstepper library and a Hybrid Servo Driver (HSS57, if it's useful). I have the following code:
#include <AccelStepper.h>
int STEP = 4; // Pin pulse
int DIR = 5; // Pin direction
int ENA = 6; // Pin enable
int RPM = 200;
int SPR = 400; // Steps per revolution
int SPS; // Steps per second
AccelStepper stepper(1, STEP, DIR);
void setup()
{
stepper.setEnablePin(ENA);
stepper.setPinsInverted(0, 0, 1);
stepper.enableOutputs();
SPS = (RPM * SPR) / 60;
stepper.setSpeed(SPS);
stepper.setCurrentPosition(0);
stepper.moveTo(400);
stepper.setMaxSpeed(1000);
stepper.setAcceleration(1000);
}
void loop()
{
stepper.run();
}
However, this losses steps, as it makes just under one revolution. But when I delete the "stepper.setEnablePin(ENA);" line it works just fine.