Software To Control Stepper Motors
How to Control a Stepper Motor from a PC. Software Having connected the stepper motor we are now ready to control it from the PC. For this you will need to install the AutoStep software that comes with the StepperBee. Insert the installation disk and follow the, all too familiar, installation sequence.
- MOONS' is a global leading supplier of motion control and intelligent lighting products, including stepper and servo motors, drives, controllers, gearheads, and power supplies etc. That make the world moving in better ways!
- The motors wires have been connected to stepper driver’s “A+”, “A-” and “B+” “B-“. Stepper Motors for all three axis have been connected to their driver boards. If you already have installed the software (below), then you are ready to connect the Arduino board to the computer through USB cable.
I have three stepper motors connected to the drv8825 drivers to an arduino uno.
I am using the example code below (from here), which works fine for moving multiple stepper motors at the same time BUT they all move for the same number of steps and in the same direction. I would like to tweak the code so that all of them move at the same time but each one for a different number of steps and in different directions. The motor with the least steps would probably have to wait for the motor with the most steps to finish its movement before going again.
Rummikub original game online free. Thank you in advance for your help!
James Waldby - jwpat7migrated from electronics.stackexchange.comFeb 6 '16 at 20:40
This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.
Free Stepper Motor Control Software
3 Answers
Stepper Motor Driver Arduino
You would first have to provide all the necessary information to yourstep()
function: direction and number of steps for each motor. Thenyou just have to stop the loop at different points for each motor. Youdo this by running the loop up to the number of steps of whichever motorneeds to run for longer, and making the steps of each motor conditionalon the loop index, as follows:
It would be more elegant to put the data for all the motors in an array,and you would probably want to do so if you have more than three motors.
Edgar BonetEdgar BonetYou need a struct for each stepper with a timestamp, a position and rate of change and a loop that updates the postion based on rate which is the change in position over some time:
Stepper Motor Tutorial
This is a back-of-a-napkin sketch of course. It is only supposed to illustrate how you can update any number of things concurrently.
The important thing is that you only call delay once. And presumably it would be only a very short delay compared to the unit of time for the rate. In the above example it would adjust the stepper position every 100ms. You would need to experiment with the timing to find a good behavior given the speed of the stepper, speed of the code and maximum permitted rate.
Beware that there is a lot to think about beyond this. For example, you should initialize the timstamps with different timestamps so that the motors are not all running at the same instant and thus try to minimize the total power consumed by the motors at any particular time.
Note that I have never played around with stepper motors but this type of loop is a common programming idiom for handling things concurrently.
I have two ideas:
- I don't have personal experience working with the AccelStepper Library, but I believe it implements a class that allows you to work with multiple steppers.
- I plan on controlling two steppers for a project of my own (a self-balancing robot implemented with an STM32 processor), and I plan on using hardware timer interrupts to control the speed of my motors. A quick google search shows that a similar approach is possible with Arduino. You can probably use
Timer0
, as 1ms is fairly fast for a single step. This has several benefits..- The refresh function will run on set intervals, (allowing you to control the speed very precisely.
- It will run with the correct timing, even if there is a function in
loop()
that is taking a long time.
Note: do NOT put any delay
statements in your interrupt handlers. If you do this, it will probably prevent other interrupts from occurring and cause some API functions (such as millis
or micros
) to misbehave. In addition, the execution of anything in loop
is halted while the interrupt is being handled, meaning that you would effectively stop everything until the interrupt is done. See the caveat in Arduino reference page for delay
.