Define Speed and Acceleration for a NEMA17

10,093 views
Skip to first unread message

Roberto Grosso

unread,
Jul 6, 2015, 4:49:15 AM7/6/15
to accels...@googlegroups.com
Dear All
Sorry for my english first.
I describe my project in order to be more clear.
I'm using NEMA17 drived by Postep25-32, connected to Arduino UNO 
Someone help me to calculate maximum speed and maximum acceleration for this motor.

Starting from the specification of the motor,
Maximum Speed = 600 RPM
200*600 = 120000 step. 120000/60 = 2000 step per second

Acceleration at Max Speed  = 1.4E+06 1/16 steps/sec² or 175000 1/2 steps/sec²
175000/2 = 87500 

Running at speed 2000 and acceleration 87500 everything work well.

The problem start when i try to reduce the acceleratin, because in my project i need a very soft acceleration and low speed
Reducing the acceleration the motor start to loose steps and vibrate.

for example using speed 200 and acceleration 40000 often it loose steps and sometime don't move and vibrate in the same position

Thanks in advance for the help.
Regards


Message has been deleted

Jon Magill

unread,
Jul 6, 2015, 2:30:29 PM7/6/15
to accels...@googlegroups.com
Often vibrations, or the motor jumping and sounding terrible, like it is missing steps, is due to a problem with the current setting on your driver. That said, your driver's maximum current is also the max current for your motor, and usually less current doesn't cause the erratic behavior you describe.

Did you set the jumper for your motor to the (correct) 2.5A position on the driver board? What voltage and current is the power supply you are using?

Try at a variety of speeds and acceleration settings. Many steppers have resonance issues at specific speeds. Try slightly faster and slightly slower.

The second most common problem with erratic motor behavior like you describe is a mis-wired motor, most common with 6-wire and 8-wire motors But with your 4-wire motor, that is unlikely. Just make sure you have Black-Green paired, and Blue-Red paired.

The next possible problem is the sequence of calls you are making in your code. There are many ways to get it wrong.

Does your motor behave correctly running a simple example program like the Bounce.pde example? Or is the behavior the same?

If you are using anything that communicates, e.g. Serial.print, or output devices like and LCD, those can also cause issues with constant speed. A typical Uno with just a single stepper connected will max out at around 4,000 steps/second.

If the example works, but your code doesn't, post your code.

--Jon

Roberto Grosso

unread,
Jul 6, 2015, 3:28:54 PM7/6/15
to accels...@googlegroups.com
Hi Jon
Thanks for the suggestions
Yes the current is OK.
i have checked the connection and they are proper.
The bounce.bde work, but now i have one information more.
The problem happen only in full step, for all the other settings 1/2 1/4 1/8 i can use all the range of speeds and accelerations
I will work in 1/4 because it work very well. 
Anyway i post the code that give problems and the code that work well
Thanks again


LOST STEPS CODE
#include <AccelStepper.h>

//Drive setup FULL step
float motorMaxSpeed = 2000.0;
float motorSpeed = 2000.0; //pulse per second
float motorAccel = 1000.0; //87500; //steps/second/second to accelerate
int motorDirPin = 6; //digital pin 6
int motorStepPin = 3; //digital pin 3

AccelStepper stepper(1, motorStepPin, motorDirPin); 

void setup(){
  
 stepper.setMaxSpeed(motorMaxSpeed);
 stepper.setSpeed(motorSpeed);
 stepper.setAcceleration(motorAccel);
 delay(5000);
}

void loop(){
for ( int sr = 0; sr < 2; sr++){
  delay(100);
  stepper.move(200);
  stepper.runToPosition();
  }  
  delay(100);
  stepper.move(8000);
  stepper.runToPosition();
  delay(1000);
}



WORKING CODE
#include <AccelStepper.h>

//Drive setup 1/4 step
float motorMaxSpeed = 8000.0;
float motorSpeed = 8000.0; //pulse per second
float motorAccel = 4000.0; //87500; //steps/second/second to accelerate
int motorDirPin = 6; //digital pin 6
int motorStepPin = 3; //digital pin 3

AccelStepper stepper(1, motorStepPin, motorDirPin); 

void setup(){
  
 stepper.setMaxSpeed(motorMaxSpeed);
 stepper.setSpeed(motorSpeed);
 stepper.setAcceleration(motorAccel);
 delay(5000);
}

void loop(){
for ( int sr = 0; sr < 2; sr++){
  delay(100);
  stepper.move(800);
  stepper.runToPosition();
  }  
  delay(100);
  stepper.move(32000);
  stepper.runToPosition();
  delay(1000);
}

Jon Magill

unread,
Jul 6, 2015, 6:23:22 PM7/6/15
to accels...@googlegroups.com
Roberto -- I'm glad to hear you got it working.

It sounds like there is just an issue with your board not working in full steps.

I am not sure what your goal is, but down the road you will want to avoid using "delay"s and probably runToPosition() too, which is a blocking function.

Although it doesn't make much sense with your current structure, most people would do something more like the attached version, using run()...

// RobertoGrosso.ino

#include <AccelStepper.h>

//Drive setup 1/4 step
float motorMaxSpeed = 8000.0;
float motorSpeed = 8000.0; //pulse per second
float motorAccel = 4000.0; //87500; //steps/second/second to accelerate
int motorDirPin = 6; //digital pin 6
int motorStepPin = 3; //digital pin 3

AccelStepper stepper(1, motorStepPin, motorDirPin); 

void setup(){
  
 stepper.setMaxSpeed(motorMaxSpeed);
 stepper.setSpeed(motorSpeed);
 stepper.setAcceleration(motorAccel);
 delay(5000);
}

void loop(){

for ( int sr = 0; sr < 2; sr++){
  delay(100);
  stepper.move(800);
  while (stepper.distanceToGo() != 0)
 stepper.run();
  }  
  delay(100);
  stepper.move(32000);
  while (stepper.distanceToGo() != 0)
 stepper.run();
  delay(1000);
}

Good luck,

--Jon


Roberto Grosso

unread,
Jul 7, 2015, 5:10:43 AM7/7/15
to accels...@googlegroups.com
Hi
Yes this code was just made in order to found the good speed and acceleration for my project.
I will contact the producer in order to understand why the full step work in this way
Thanks for everything
Regards

Richard Bogard

unread,
Sep 17, 2018, 4:01:08 PM9/17/18
to accelstepper
,
That's not a really good way test. You should be using a timer function on an interrupt to adjust a timer in fast  pwm mode. It is best if you will avoid performing calculations such as moving to the frequency domain. Instead simply increment the other timer by one and the closer you get to  zero on timer the higher the acceleration rate will be so you need to slow down  how many steps you increment in the frequency domain the closer you get to a high frequency.  Cannot overdo this as the tour will be significantly reduced at 4khz
 small counter valuesbecause the smaller the number is the more rapid the change will be you increase it by one but if you are dealing with 100 as a counter number limi
It is best to stay away from small  register values such as less than 50, which is easy to do with the 16-bit timer. for example if you increment from 100  to 101  your acceleration is relatively low.. But if you go from 1 to 0 you double the speed which is off limits and will cause a motor stall especially because you are operating at a frequency with the least amount of torque. With the right pre scale or value, your limit will be close to  2 kHz which according to this chart would give you approximately 63%  of the total power available

Stepper Motor Speed Torque Points

The difference in acceleration between 100 and 101, and the difference in acceleration between 99 and 100 is insignificant and you can discard that dynamic entirely as it will only confuse and create complicated and unnecessary equations..

none of that matters as the dynamic at that frequency or the microcontroller has more of an impact than anything else.  Grab a timer,  make sure you never use a  register  value less than 10  and then adjust your pre-scale or so that your maximum speed is within range.

using this technique I have achieved full with signals close to 7 kilohertz which is far better than  99% of the sketches out there. On top of that my interrupt function performs no math and never increments the register by any more than one. The consumption of processor time on my Arduino  is zero. The upper frequency limit  is four times greater than what you can do even if you try to switch it via registry or digital right. Most people confuse the results they see  past 2 kHz as exceeding the maximum speed of the stepper motor but they are wrong  simply because the  quantum nature  of trying to adjust a frequency programicly

Both dynamics are eliminated when using a timer within interrupt  the controlling timer with a compare register  and never allowing that pair register the fall below 10. Then you can apply maximum acceleration at every given moment by incrementing the counter as opposed to performing frequency calculations. yyour upper limit is what ever  frequency is achieved with a register setting up 10 for any given pre-scale value.. And here's a hint you only get like five choices for free scale. If you can't figure it out from this point then you should just kill yourself
Reply all
Reply to author
Forward
0 new messages