Control Stepper Motor Rotation by Time vs. Step Size?

Hi All,

I have wired up a high resolution stepper motor—0.9 degree. I have calculated that it takes about 3200 microsteps for a full rotation using the EasyStepper Driver and the following code from a Bildr tutorial:

#define DIR_PIN 2
#define STEP_PIN 3

void setup() { 
  pinMode(DIR_PIN, OUTPUT); 
  pinMode(STEP_PIN, OUTPUT); 
} 

void loop(){ 
  rotate(3200, .1); 
  delay(1000); 

}



void rotate(int steps, float speed){ 
  //rotate a specific number of microsteps (8 microsteps per step) - (negitive for reverse movement)
  //speed is any number from .01 -> 1 with 1 being fastest - Slower is stronger
  int dir = (steps > 0)? HIGH:LOW;
  steps = abs(steps);

  digitalWrite(DIR_PIN,dir); 

  float usDelay = (1/speed) * 70;
  Serial.println(usDelay);
  for(int i=0; i < steps; i++){ 
    digitalWrite(STEP_PIN, HIGH); 
    delayMicroseconds(usDelay); 

    digitalWrite(STEP_PIN, LOW); 
    delayMicroseconds(usDelay); 
  } 
}

I would like to control a degree rotation based on time. I'm working on a project that needs to rotate the stepper at very slow speeds—roughly 1 degree a minute. Any tips on how to go about this?

Thanks!

Can't you just work out how many steps there are per degree and thus how many steps per minute and then at regular intervals ask it to move one step? Isn't that what stepper are for?

If its 3200 microsteps per revolution then 1 deg/minute is one microstep every 6.75 seconds:

steps/sec = (steps/revs / deg/rev) * (deg/min * mins/sec) = (3200 / 360) * (1 * 1/60) = 3200 / 360 / 60

secs/step = 60 * 360 / 3200 = 6.75

I thought it would be a good exercise for the OP to work that out himself.

...R