Go Down

Topic: Run stepper motor with constant speed independent from loop (Read 142 times) previous topic - next topic


Background: In my project I need to rotate a part slowly, 0-15 rpm, but with constant speed. I also want to know its position. Very little torque is required. My choices here seem to be a DC-motor or a stepper motor.
I decided to go for the stepper, because the DC-motor would require both a large gearing and an encoder. I will use an Arduino Mega for this project.

Now for the question: How do I make the stepper spin at constant speed no matter how long time the loop lasts?
I do not want the loop to pause while the stepper takes a couple of steps, but rather I want to tell it "run at this many steps/second untill I tell you otherwise." Much like you would PWM a DC-motor, and change it´s duty cycle only from time to time.

Do you have tips for motorshields/drivers that would enabel this? Or tips on what phrases to google to find answers?



Have a look at the second example in this Simple Stepper Code

While it will often be the case that successive iterations of loop() take different lengths of time you should always ensure that iterations are as short as possible, and always that there are several (perhaps hundreds of) iterations for every step of the motor.

Stepper Motor Basics

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

Go Up