Precise stepper control

I’m trying to control a stepper (SparkFun ROB-10846) using the EasyDriver. This is for astrophotography, so the stepper motion needs to be very precise. The current code is below.

My issue is that the motor seems to run at discrete speeds. Speeds of 801-804 all turn at the exact same speed. 804-805 are the same as are 806-808.

Is there a way to get very precise speed control?

Thank you!

#include <AccelStepper.h>

AccelStepper stepper(4, 2, 3, 4, 5);

int spd = 805;

void setup()

{

Serial.begin(9600);

Serial.print(millis());

Serial.print(" ");

stepper.setMaxSpeed(spd);

stepper.setSpeed(spd);

Serial.println(stepper.currentPosition());

}

void loop()

{

stepper.runSpeed();

if (stepper.currentPosition() == 16000)

{

Serial.println(millis());

}

}

The best method for precise speed control is to take single, accurately timed steps. You don’t need a library for that; just a few lines of code. To take a step, pulse the STEP pin of the easydriver. That assumes, of course, that everything else is wired correctly.

On Arduino, delayMicroseconds() has granularity of 4 microseconds (if I recall correctly) and can be used to time steps. You will need to take program overhead into account, as well as the fact that the cpu clock is not very accurate.