Control steppers with arduino or raspberry pi?

we have this robotic arm at our school that is broken and we are trying to make it work. The motors are shot and we have no idea were the controller went. We are just going to put stepper motors instead. The problem is we have no idea how to control the motors. So my question is: How can you control 6 stepper motors individually using an arduino uno, arduino mega, or raspberry pi?

sort by: active | newest | oldest
rickharris3 months ago
JohnM703 (author)  rickharris3 months ago
Thank you for the reply, but I'm looking more for something to control 6 motors. I am able to control 1 right now but I need to be able to control 6 using 1 device

I thought I had given enough clues

is a good starting place.

Stepper control: 2 data outputs - 1. Direction - 2. Number of steps.

You can either have 1 controller giving out the information and multiplex it to the required stepper controller using and gates.


Have each stepper motor controller by it's own controller and then a master controller telling them what to do via a serial link - I2I or SPi for example.


Get a microcontroller with lots of output pins. You can buy I/O expanders if you want to use a smaller controller.

-max-3 months ago

Microcontrollers are typically better for low-level tasks that require accurate/fast timing. Embedded ARM linux platforms are typically not running real-time OS's on them, and you are generally working with all of the bloat and overhead associated with going through the kernel for all the operations.

In essence, you have the ability to control the hardware directly with a platform like arduino, using things like timers, interrupts, serial protocol hardware, etc. In fact, it's not uncommon to use both a Pi and a Arduino as a system, where the Arduino controls lower-level tasks such as timing and have the Pi used for things that are much more computationally expensive to do higher level "thinking and planning."

JohnM703 (author)  -max-3 months ago

do you know how I could do that?

-max- JohnM7033 months ago

3D printers have been built with the arduino platform, I know the mega is up to the task of driving a bunch of steppers, I've personally seen it work. You should research this, find an opensource project for one of these 3D printers and... *ahem* "borrow" some of the code from it. If the project was coded well, it will be well organized and loosely coupled, having "low-level" subroutines and classes/objects in one file for controlling steppers, and higher level code that parses the G code and creates an interface. Then just strip away the irrelevant classes and functions. I think driving steppers will require a driver board.

You may find yourself in a position needing to be able to program the arduino through the pi, so you will need to install avrdude and some C++ compilers (these should be preinstalled on most common Pi distro's). There is a way you can do all the compiling and uploading through the terminal, so you don't need the arduino ide. In most programming languages, you can actually execute bash commands directly! This is very powerful, as it enables the ability to upload any .hex file to your arduino so it can do exactly what you need on-the-fly.

Once you have the code on the arduino, you will probably also want to some interactive interface to it. So you might create your own custom serial data interchange format, or use one that already exists, like messagepack.


If you are going to be getting all of this to work well, expect this it to take at least a month, or longer if you do not find any suitable pre-existing libraries / or if it must be entirly your own code.

JohnM703 (author)  -max-3 months ago

I never thought if that. Thanks

iceng -max-3 months ago

So what you seem to be suggesting is to use the Pi as the joystick and button executive human interface that decides (determines) which Arduinos are needed to selected with move motor commands to accomplish a desired robotic arm motion.

Perhaps a Pi sensor based analog contact including vision feedback to verify the desired activity is being achieved would be included...