yaconsult
Posts: 33
Joined: Fri Mar 23, 2012 2:29 pm

Stepper speed control with Adafruit stepper board

Fri Sep 16, 2016 11:55 pm

I am trying to help a friend out with his Maker Faire project. I have programming, sys admin, and hardware experience but am new to stepper motors.

The basic functionality of the stepper that he needs is that at some point, it gets turned on and the speed of rotation increases over time at some rate depending on other conditions. Think of it like a dropped ping pong ball attached to a belt driven by the stepper. So it accelerates to a speed and then remains at that speed. Now, imagine that you turn on a fan under the ball that blew air up under it. The ball would decelerate, stop, and then accelerate in the opposite direction.

Now, while I'm a ham and have some electronics experience, I have never worked with stepper motors before. It seems like all you have to work with is steps (!) and you can choose the stepping mode. The controller being used is the Adafruit stepper controller and a NEMA 17 motor. So if I just sit in a loop and send step commands to the controller, that is as fast as it can rotate, right? And to get different speeds, you delay between sending the step commands, right? I will be doing this in python and have experience with python.

I did some google searching and it seems that a method of getting a stepper motor to step faster is by increasing the i2c speed from the default, right? Is that commonly used in programs to vary stepper speed? Or only if the max speed needs to be increased?

I would love to see examples of code doing this kind of acceleration and deceleration using stepper motors. Is it just a combination of step and wait commands? Any tips about controlling stepper speed would be appreciated! The Adafruit library does have a setSpeed function - how would this be used to get the desired acceleration and deceleration? It is mentioned here: https://learn.adafruit.com/adafruit-dc- ... per-motors But they don't have any examples of varying the speed.

I am using the parts that my friend speced and bought for his project, but wouldn't DC motors probably have been a better choice when you want to control the speed of motion of an object by a motor? Still, I have seem projects where people have made car and other mobile objects using steppers so they must have needed to deal with the same speed issues.

Thanks for any help!

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: Stepper speed control with Adafruit stepper board

Sat Sep 17, 2016 2:19 am

yaconsult wrote: So if I just sit in a loop and send step commands to the controller, that is as fast as it can rotate, right? And to get different speeds, you delay between sending the step commands, right?
Are you driving it directly with the voltage on for the entire time as you go through the sequence? Measure the resistance of the windings to see what you are dealing with at various voltages. I was using a stepper from a printer and I could run it directly at 5 volts but clearly 12 volts was trouble. If you need more performance, you'll want to look into a constant current chopper type circuit. The idea is that it lets you run at the higher voltage but limits the on time to limit the total current to a safe level.

User avatar
Jednorozec
Posts: 809
Joined: Sun Nov 24, 2013 2:17 pm
Location: Deposit, NY

Re: Stepper speed control with Adafruit stepper board

Sat Sep 17, 2016 4:47 am

Adafruit indirectly talks about speed control.
OK lets say you want a lot of control over your steppers, you can use the one oneStep(direction, stepstyle) which will make a single step in the style you request, with no delay. This will let you step exactly when you like, for the most control
The most important leg of a three legged stool is the one that's missing.
It's called thinking. Why don't you try it sometime?

yaconsult
Posts: 33
Joined: Fri Mar 23, 2012 2:29 pm

Re: Stepper speed control with Adafruit stepper board

Sat Sep 17, 2016 5:45 am

stderr wrote:
yaconsult wrote: So if I just sit in a loop and send step commands to the controller, that is as fast as it can rotate, right? And to get different speeds, you delay between sending the step commands, right?
Are you driving it directly with the voltage on for the entire time as you go through the sequence? Measure the resistance of the windings to see what you are dealing with at various voltages. I was using a stepper from a printer and I could run it directly at 5 volts but clearly 12 volts was trouble. If you need more performance, you'll want to look into a constant current chopper type circuit. The idea is that it lets you run at the higher voltage but limits the on time to limit the total current to a safe level.
I am using this Adafruit stepper controller and the same stepper motors and 12 volt power supply on that page: https://learn.adafruit.com/adafruit-dc- ... per-motors These are the parts that Adafruit recommends using with this board. Everything was bought from Adafruit at the same time.

Here is Adafruit's example code for controlling the stepper board with their library: https://github.com/adafruit/Adafruit-Mo ... perTest.py What I would like to see is an example of how to do something like start slowly from a stop, go faster and faster until it reaches maximum speed, and then gradually slow down again to a stop. Should this be done using setSpeed(), delays, or changing i2c clock rate?

Thanks!

Return to “General discussion”