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!