I appreciate the template you provided. I adapted it for my purposes but even when I change your time between steps from 25 to 7.75 which should give me close to 1.55 RPS (93 RPM), I'm still not getting anywhere close to that speed.
Attached is my code,,
// testing a stepper motor with a Pololu A4988 driver board or equivalent
// this version uses millis() to manage timing rather than delay()
// and the movement is determined by a pair of momentary push switches
// press one and it turns CW, press the other and it turns CCW
byte directionPin = 3;
byte stepPin = 2;
byte ledPin = 13;
unsigned long curMillis;
unsigned long prevStepMillis = 0;
unsigned long millisBetweenSteps = 7.75; // milliseconds
void setup() {
Serial.begin(9600);
Serial.println("Starting Stepper Demo with millis()");
pinMode(directionPin, OUTPUT);
pinMode(stepPin, OUTPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(directionPin, HIGH);
curMillis = millis();
singleStep();
}
void singleStep() {
if (curMillis - prevStepMillis >= millisBetweenSteps) {
// next 2 lines changed 28 Nov 2018
//prevStepMillis += millisBetweenSteps;
prevStepMillis = curMillis;
digitalWrite(stepPin, HIGH);
Serial.print("HiGH");
digitalWrite(stepPin, LOW);
Serial.print("Low");
}
}
and I'll also attach pictures of my fixture and stepper, probably won't matter much but the reason I'm attaching them is I'm starting to think I may have a problem with the driver inside the fixture.
Wondering if anyone has a 200 step stepper and driver to test my code. I just ordered another one I can test on but hopefully if someone has something handy they can give me some insight.
justconmac:
I appreciate the template you provided. I adapted it for my purposes but even when I change your time between steps from 25 to 7.75 which should give me close to 1.55 RPS (93 RPM), I'm still not getting anywhere close to that speed.
What speed are you getting?
You can't use fractional millisecs because it works in whole numbers. It probably treats 7.75 as 7. If you need more precision you must use micros().
At 1 step every 7 millisecs you get 1000/7 = 142.9 steps per second. With 200 steps per rev that means 0.71 RPS if my maths is correct.