Go Down

Topic: acceleration on stepper motor without using accelstepper.h (Read 2382 times) previous topic - next topic

bustercluster

title says it all. id like to know a method to add acceleration and deacceleration to my stepper motors.

TomGeorge

Hi,
title says it all. id like to know a method to add acceleration and deacceleration to my stepper motors.
What method to control accel, buttons, pot?
What do you want the control to do, set speed or acceleration.
What happens when stepper can go no faster and stalls.
What is the application that need acceleration control.

Tom..... :)
Everything runs on smoke, let the smoke out, it stops running....

RayLivingston

The most important question is:  Why on earth do you NOT want to use AccelStepper?  Doing proper acceleration and deceleration is non-trivial on a computationally limited CPU.  AccelStepper is very well done, and works very well.  You would spend a HUGE amount of time duplicating its performance and reliability, and for what gain?

The algorithm use by AccelStepper is very well documented, and the source code contains a link to the paper it is based on.

Regards,
Ray L.


lastchancename

I've done this in the past - by nominating a distance (# steps or, % of current-to-target position) to apply speed ramping,  then introduce skipped steps, from a single pulse... up to 'all' pulses skipped when you reached the target position.

You can vary the acceleration/deceleration speed by changing the skip number by +/1 (slow rate of change), through to +/-many (a function of the remaining distance).
Experienced responders have a nose for laziness, (they were beginners once)... expecting the poster to contribute to the learning experience.

RayLivingston

#4
May 08, 2016, 07:18 am Last Edit: May 08, 2016, 07:21 am by RayLivingston
I've done this in the past - by nominating a distance (# steps or, % of current-to-target position) to apply speed ramping,  then introduce skipped steps, from a single pulse... up to 'all' pulses skipped when you reached the target position.

You can vary the acceleration/deceleration speed by changing the skip number by +/1 (slow rate of change), through to +/-many (a function of the remaining distance).
Which will work fine only for relatively low step rates.  At higher rates, the skipped steps will setup oscillations in the motor rotation which can, by themselves, cause lost steps, and stalling.  For optimal performance, it is critical that the pulse train be smooth, with low jitter, and that the step-to-step timing varies smoothly throughout the entire motion.  Simply skipping steps will greatly reduce the maximum achievable speed, especially under load.

One of my stepper-driven CNC machines used bit-banging to drive the steppers.  It was limited to less than 100 inches/min., due entirely to the jitter in the step pulse timing.  And this was on a 2.8GHz PC.  I added a hardware motion controller, which generated the step pulses in hard-wired logic, and instantly increased the speed to over 350 inches/min.

Regards,
Ray L.

lastchancename

#5
May 08, 2016, 07:46 am Last Edit: May 08, 2016, 07:47 am by lastchancename
I agree with your sentiment, but the step rate in my method doesn't vary arbitrarily - it simply increases or decreases the 'frequency' of the steps by n depending on the distance from the target. (It sounds really cool on big motors!)

I've used this method on three concurrent steppers driven by an Arduino- stepping at 10KHz without any issues.  Perhaps I didn't explain it very well. (It wouldn't be the first time!)
:smiley-confuse:

P.S. I agree with using accell_stepper for simplicity, but if he wants to roll his own - this is one way to shoot at it.
Experienced responders have a nose for laziness, (they were beginners once)... expecting the poster to contribute to the learning experience.

Robin2

I suspect (but have not yet tested this) that smooth acceleration may not be essential to ensure that the motor does not miss steps and a series of 2 or 3 discrete intermediate speeds may be sufficient.

Of course this would be inappropriate if the load requires smooth acceleration.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

MarkT

1) Use microstepping - then you automatically reduce the impact of jitter and reduce the risk of resonant
pull-out.  Of course you have to step faster.

2) Jitter itself tends to be averaged out, but the components of the jitter that fall in the resonance peaks
of the mechanical system (rotor+load) will not be damped, so unless you can noise-shape the jitter
spectrum try to keep it to a minimum.

3) mechanical (viscous) damping is very useful to improve motor performance, it reduces resonance
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

ignaciovulliez

#8
Oct 12, 2018, 07:13 am Last Edit: Oct 12, 2018, 07:17 am by ignaciovulliez
Here is how i do it

digitalWrite(directionPin, HIGH);
 for(int n = 0; n < numberOfSteps; n++) {
   digitalWrite(stepPin, HIGH);
   digitalWrite(stepPin, LOW);
   
   //delayMicroseconds((abs(600-2*n)+micsbetweenSteps));   or

   delayMicroseconds(abs(150-n/2)+micsbetweenSteps);



//600 being double the total steps you are going to make     or

// 150 being half the total steps you are going to make

DKWatson

The definitive paper on linear acceleration was written by David Austin and detailed in an Atmel Application Note AVR446. I spent the better part of two years getting a commercial version of this working on the 328P. Good luck!
Live as if you were to die tomorrow. Learn as if you were to live forever. - Mahatma Gandhi

Go Up