Is this a realistic accuracy???

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

As long as stepping motors are wired correctly and operated within their power, load and speed limits, they do not miss steps.

That means there is no cumulative error.

Pete123:
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).

Steppers can't start out at full speed. You need to accelerate them up to speed.

Hi,
As you only need 1 turn resolution, use a sensor at the stepper shaft, count the turns from it, rather than from the stepper software.

Tom...

DuaneDegn:
Steppers can't start out at full speed. You need to accelerate them up to speed.

Makes sense, however this problem does not present itself at 60RPM, or even 80RPM, just kind of odd that its 50RPM specifically.

A thing that I forgot to mention is that the steppers will only meed to run at an RPM range of 2RPM to 20RPM, so maybe I could get away without using the accel library? As that would complicate my code a bit..

TomGeorge:
Hi,
As you only need 1 turn resolution, use a sensor at the stepper shaft, count the turns from it, rather than from the stepper software.

Tom...

Definitely a good suggestion, I would think that would make my code a bit more complex, I am still learning how to code so the reason I did it the way it is is for the sake of simplicity. But I will look into that option. Another issue with using a sensor is that I would have to deal with any accuracy error of the sensor itself. What kind of sensor would you suggest? A reed switch? This project is actually a test fixture for testing the count of a reed switch at different temperatures...

Stepping motors show "resonance" effects and at certain speeds can behave badly.

Microstepping can help in such a case, but microstepping can also lead to missed steps.

DuaneDegn:
Steppers can't start out at full speed. You need to accelerate them up to speed.

Makes sense, however I am not having the same jolting problem at 60 RPM.

A thing that I forgot to mention is that the steppers will only meed to run at an RPM range of 2RPM to 20RPM, so maybe I could get away without using the accel library? As that would complicate my code a bit..

The code in your Original Post uses delay(). That is a complete NO NO if you want to control several motors. Also you are using a float value whereas delay() takes an unsigned long.

Have a look at how millis() and micros() are used to manage timing in the second example in this Simple Stepper Code.

You may find that running a 2 amp motor at 2 amps is a bit of struggle for a DRV 8825. It may need a heatsink and a fan.

An encoder on the motor shaft is a good way to check for missed steps but reading an encoder uses up a lot of Arduino CPU cycles. Reading 8 encoders and controlling 8 motors may be too much for a 16MHz Arduino.

...R
Stepper Motor Basics

however I am not having the same jolting problem at 60 RPM.

Your observations strongly suggest that the stepping motor is resonant at 55 RPM, but not 60.

Robin2:
The code in your Original Post uses delay(). That is a complete NO NO if you want to control several motors. Also you are using a float value whereas delay() takes an unsigned long.

Have a look at how millis() and micros() are used to manage timing in the second example in this Simple Stepper Code.

You may find that running a 2 amp motor at 2 amps is a bit of struggle for a DRV 8825. It may need a heatsink and a fan.

An encoder on the motor shaft is a good way to check for missed steps but reading an encoder uses up a lot of Arduino CPU cycles. Reading 8 encoders and controlling 8 motors may be too much for a 16MHz Arduino.

...R
Stepper Motor Basics

Hi Robin

I understand why you cannot use the Delay function when running several steppers at different speeds, but why would I not be able to run all the motors at the same time and in sync using the delay function? I have all the direction pins from all the drivers connected to pin 3 on the arduino and all step pins from all the drivers connected to pin 2, so far I have not had any issues driving 3 motors in sync. Will I experience other issues with this setup?

Pete123:
but why would I not be able to run all the motors at the same time and in sync using the delay function? I

I had assumed you wanted them all to work separately. From the point of view of the Arduino they will appear as a single motor if they all use the same step and direction output.

However doing it that way does not allow you to make an individual correction if one motor misses a step - assuming you have some means to detect missed steps.

...R

Robin2:
I had assumed you wanted them all to work separately. From the point of view of the Arduino they will appear as a single motor if they all use the same step and direction output.

However doing it that way does not allow you to make an individual correction if one motor misses a step - assuming you have some means to detect missed steps.

...R
[/quote

Robin2:
I had assumed you wanted them all to work separately. From the point of view of the Arduino they will appear as a single motor if they all use the same step and direction output.

However doing it that way does not allow you to make an individual correction if one motor misses a step - assuming you have some means to detect missed steps.

...R

Right on, I think I may have another arduino hooked up to log revolutions and a reed switch on every stepper shaft to verify that the motors turned the correct number of times.

Thanks!

Pete123:
Right on, I think I may have another arduino hooked up to log revolutions and a reed switch on every stepper shaft to verify that the motors turned the correct number of times.

You have not said what you plan to do if a motor does not turn the correct number of times.

If you just plan to stop everything if there is an error that will be simple.

But if you want to correct the error without stopping ....

...R

Robin2:
You have not said what you plan to do if a motor does not turn the correct number of times.

If you just plan to stop everything if there is an error that will be simple.

But if you want to correct the error without stopping ....

...R

Yup, I was thinking of using a sensor to count the revolutions strictly for the purpose of verifying that the motor has done the correct number of revolutions. This being a simple test fixture that only has to rotate a given number of times I would need a second method of verifying the revolutions count. As for correcting the error if there is one, I would not even know where to begin... I would adjust something in my code maybe? But in that case I would at least know that there is something wrong.

-Pete

Pete123:
As for correcting the error if there is one, I would not even know where to begin... I would adjust something in my code maybe? But in that case I would at least know that there is something wrong.

I think we are getting our time concepts confused.

If you want to change the code it means stopping the device, figuring out a change and then uploading and testing the new code. That may mean one hour or several hours with the device out of action. Maybe that is acceptable - but you have not said.

What I had in mind is that the program would make internal corrections without the device needing to stop - and for that each stepper must be controlled individually.

...R

Pete123:
Hi Robin

I understand why you cannot use the Delay function when running several steppers at different speeds, but why would I not be able to run all the motors at the same time and in sync using the delay function? I have all the direction pins from all the drivers connected to pin 3 on the arduino and all step pins from all the drivers connected to pin 2, so far I have not had any issues driving 3 motors in sync. Will I experience other issues with this setup?

if you are talking steppers, you have to ramp up to speed, run at speed, ramp to other speeds, ramp as needed, then ramp to stop.
delay is like you driving your car a 125 MPH them locking up the brakes. it almost the laboratory definition of how to make a stepper miss steps.
delay to a stepper is either part of a finely choreographed dance with a continual flow, or hitting a brick wall.
You have not mentioned load at any point, but if you operate your steppers will within their capability, you can run 1,000 revolutions right, then left, then right, then left, then right and right again, and right again, and left, and right and left and left again....... whatever you want, and not miss one step, that means 1,000 revolutions +/- 0 steps error. and that means withing 1/200th of a revolution.
the CNC guys use steppers for hours of operation and error check at the end, missed steps means something went wrong.

it would be easy enough to paint a stripe on each shaft and then use a second Arduino to count revolutions.
then run all your motors for the few minutes it would take to make 1,000 revolutions.

then see if all the stripes are in the exact same position and if each made the exact number of steps.

then increase ramp speeds until you have a missed step, then back off from that by a good margin and you would have a calibrated array.

it seems you are at the point of testing to get empirical data and not theoretical discussions of what might be.

Could you guys also recommend a capacitor to use for wiring these drivers in parallel? The DRV8825 webpage suggest using at least 47 µF across the power pins of the driver to protect against LC spikes. Since I am using 8 of these drivers can I put a larger capacitor across the main power leads coming out of the power supply? And if so what rating capacitor could I use? Or would I still need to wire in a capacitor for each board?

"This carrier board uses low-ESR ceramic capacitors, which makes it susceptible to destructive LC voltage spikes, especially when using power leads longer than a few inches. Under the right conditions, these spikes can exceed the 45 V maximum voltage rating for the DRV8825 and permanently damage the board, even when the motor supply voltage is as low as 12 V. One way to protect the driver from such spikes is to put a large (at least 47 µF) electrolytic capacitor across motor power (VMOT) and ground somewhere close to the board."

Thanks again for all the help
-Pete

Capacitors are not expensive. I would use one for each driver.

Note in the instructions "somewhere close to the board"

You don't want to be scratching your head for the reason it stops working on day 23

...R