I need to rotate 8 stepper motors for a total of 1000 revolutions and then stop. Ideally I would like to be able to rotate them for much longer (i.e. 250000 revolutions) EDIT: all motors need to rotate in sync.
But for 1000 revolutions I am required to have an accuracy of at LEAST +/- 1 revolution.
#define STEP_PIN 2
#define DIR_PIN 3
void setup() {
pinMode(DIR_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
long REV = 1000; // Input desired number of revolutions to be completed
int RPM = 2; // Input desired RPM
int steps = 200; // Adjust number of steps per revolution according to Microstepping
float Delay = 60000/(2*RPM*steps); // 60,000 milliseconds in minute
digitalWrite(DIR_PIN, HIGH);
for(int i=0; i<=REV*steps ; i++){
digitalWrite(STEP_PIN, HIGH);
delay(Delay);
digitalWrite(STEP_PIN, LOW);
delay(Delay);
}
}
void loop(){
}
I have been testing this code with other stepper motors that I have laying around, it seems to work fine, HOWEVER it does seem to have issues at oddly enough 50 RPM specifically (jolts back and forth a few steps before starting to rotate correctly). In fact I actually though I would have an issue with an RPM that would give me a delay with decimals such as 55 RPM, which comes out with 2.72727 milliseconds, HOWEVER for some reason that seems to work just fine... granted I still have to test the accuracy of that speed....
I will be using these steppers: http://www.amazon.com/Nema17-Stepper-Motor-4-lead-Connector/dp/B00QEXSCE8/ref=sr_1_2?ie=UTF8&qid=1452020576&sr=8-2&keywords=nema+17+stepper+motor (17HS16-2004S) 1.8 Degree, Bi-polar, 2A
I will be using these drivers: https://www.pololu.com/product/2133 (DRV8825)
I will be using this power supply: http://www.amazon.com/Universal-Regulated-Switching-Computer-Project/dp/B00D7CWSCG/ref=pd_bxgy_60_img_2?ie=UTF8&refRID=1DB9GDN7Y29CH7ZVDERJ (12v 30a Dc)
There are 8 drivers and 1 Arduino Uno. All the drivers are using the same step and direction pins from the arduino, so my understanding is that they are rotating in sync with each other...
With a percent error of +/-5% per step does that mean that upon completion of 1000 revolutions my revolution count could be off by 50?? I really think I am missing something...
Thanks, I appreciate any help
-Peter