New stepper motor library with accelerations etc

Hi,
I have just made available the AccelStepper library.

AccelStepper significantly improves on the standard Arduino Stepper library in several ways:

Supports acceleration and deceleration

Supports multiple simultaneous steppers, with independent concurrent stepping on each stepper

API functions never delay() or block

Supports 2 and 4 wire steppers

Very slow speeds are supported

Subclassable

Extensive API

Download from AccelStepper: AccelStepper library for Arduino

Very nice and very useful. Thank you for sharing your contribution.

I think the best attribute of the Arduino platform is all the software library and project examples that the community shares with the user base.

Lefty

Just what I needed! :smiley:

Is ther e a way to use this to control a large amount of tiny stepper motors...like almost 200?

200 steppers: in principle yes, but I cant think of any arduinos with 800 digital output pins :slight_smile:

Cheers.

It may be off-topic, but what does "Supports 2 and 4 wire steppers" mean? I thought the smallest number of stepper motor wires is 4?

A 2 wire motor is one that is attached to a controller and just uses step and direction pulses.
http://www.8051projects.net/stepper-motor-interfacing/stepper-motor-connections.php
Where as a 4 wire motor is one where the controller controls the individual ends of the two coils.

But still, it's not "2 wire stepper motor", it's "X-wire motor with controller" :slight_smile:
OK, thanks!

But still, it's not "2 wire stepper motor"

True but that's what it is called.

"200 steppers: in principle yes, but I cant think of any arduinos with 800 digital output pins "

how about multiplexing the steppers into a grid?

I guess as long as your multiplexor holds the value and you can change it quick enough to stop the motor stuttering then it should work.

I noticed most folk use a decoding chip to control the phasing of the steppers. Why can't the Arduino do the decoding and provide the correct phasing? Obviously the outputs would have to go through a driver of some sorts but I'm not sure why the decoder is the popular route?

I noticed the pulse rate is limited to 1000 steps/sec which is a bit slow for my application. Is this a limitation of the Arduino board or the software and is there any way to improve this?

Thanks,
Greg

Its a limitation due to the fact that I use millis() to compute the time of each step, so its limited to max 1000 per sec.

Hmmmm- I guess it wouldn't be as simple as just changing to micros()?

No, I would expect to have to deal with the micros() count wrapping etc.

mikem - thank you!
this is exactly what i need for my first bigger arduino project (a drawing robot) since i´m a total programming noob i was hopelessly lost trying to controll 2 steppers until i discovered this library. and you added the driver-option (pins==1) just at the right time :slight_smile:

one note on this: the 1 milisecond delay of the step pulse was too fast for my driver - i changed it to 20 & now it works ;D

thanx again!

thanks bub.
which driver are you using?
What is its claimed minimum step pulse width?

Cheers.

drivers are a3977´s
...actually it´s a half broken cnc controller board (z axsis never really worked)
http://www.cnc-plus.de/CNC-Electronics/Stepping-Motor-Drives/3-axis--2-5-Amp-Step-Motor-Driver-AMW-102.html

when i was setting up emc2 to use this controller for my cnc mill i used 20.000ns (found the number somewhere in a german cnc forum) thats why i changed it to 20ms...

just did a short test:

2ms nothing
3ms only one motor (x axis) moves
4ms both x and y are moving (can´t tell if the 3rd would move)

now i set it to 10 just to be save :slight_smile:

...is there a disadvantage in setting higher values?

---- edit ----
from the datasheet:
A. Minimum Command Active Time
Before Step Pulse (Data Set-Up Time)..... 200 ns
B. Minimum Command Active Time
After Step Pulse (Data Hold Time)............ 200 ns
C. Minimum STEP Pulse Width...................... 1.0 µs
D. Minimum STEP Low Time......................... 1.0 µs
E. Maximum Wake-Up Time......................... 1.0 ms

weird :-?

Hi Bub,

yes, curious.
I want to keep the pulse time short, because I want to minimise the delay times in the code. For the 2 and 4 wire there is no delay at all.

An alternative I considered would be to turn the Step on for a whole step interval then turn it off for a whole step interval, but this would half the step frequency, and make the step speed and accelerations out by a factor of 2.

thank you, just in time.
simultaneous stepper here we go.

note: i looked over the examples and couldn't find more information about overshooting (overshoot, over shoot) on Google.
any links ?