Possibly insane question

I am @ the forefront of a project that I won't be getting to the programming portion is several years away but I'd like to get this out of the way now. My question is, can an arduino (be is mega or otherwise) control up to 32 stepper motors? & Yes I am aware that they can't be powered by the arduino. If not what is the max # of motors that they can control?

If each motor has it's own controller, then the controller would likely have a "step" plus "direction" pin - so 2 pins minimum would be needed; you could possibly get that down to one pin if you could potentially find a "one-wire" stepper controller. This is all pure speculation.

Now - if you used an SPI or I2C system (basically a 2-wire serial bus) - or something like this:

http://www.kranenborg.org/ee/picaxe/twowirenetwork.htm

(subbing atmega's or attiny's for the picaxe, of course!)

...then the limits would be the number of addresses in the network. All of these examples (and any other bus-based topology) assumes a fairly "smart" controller for each motor.

If you are talking just bog-simple controller for each motor, though - 2 wires per motor (step and direction); on a standard Arduino UNO, where you only have a maximum of 20 digital i/o pins (all 14 "normal" digital, and using the 6 analog i/o pins as digital pins) - so 10 motors, max (no serial comms/usb possible, either - or anything else - that would just be an arduino controlling 10 motors).

Even with a Mega, while that number would increase, it still wouldn't be enough for 32 motors.

All of that said - nothing would stop you from instead using eight daisy-chained 595 shift registers (giving you 64 outputs - enough for 32 motors), and 3 wires from an Uno (clock, latch, and data); alternatively, you can find SPI/I2C capable 8 and 16 bit serial-to-parallel chips that you could hang off the SPI/I2C bus of the Uno, then use the 2-wire library to interface with them...

So - the answer to your question is a bit of "yes and no" - "no", if you just want to use an Arduino and nothing else (besides the simple controllers for the motors), "yes" if you don't mind adding a bit of hardware ("intelligent" bus, or "dumb" bit-bang interface).

The size of the program is another factor.
Let's say you used an UNO, it has 32K of flash (some used for the bootloader ~500).

that I won't be getting to the programming portion is several years away

Not a good idea. Never get all the hardware assembled and then look to program it, you could end up with a lot of junk.
Better to start small, just use one motor for what ever you want. Then write the software to control that.
When that is working extend the software to control all your motors even though you have not built them yet. Look at the performance and the effect on the one physical motor you have. If it is still OK then build the rest. If not get it to work with the minimum hardware and maximum software before spending several years building the hardware.

Nothing is worst than building a lot of stuff and then discovering a design flaw.

cr0sh:
If each motor has it's own controller, then the controller would likely have a "step" plus "direction" pin - so 2 pins minimum would be needed; you could possibly get that down to one pin if you could potentially find a "one-wire" stepper controller. This is all pure speculation.

Now - if you used an SPI or I2C system (basically a 2-wire serial bus) - or something like this:

SerialPower

(subbing atmega's or attiny's for the picaxe, of course!)

...then the limits would be the number of addresses in the network. All of these examples (and any other bus-based topology) assumes a fairly "smart" controller for each motor.

If you are talking just bog-simple controller for each motor, though - 2 wires per motor (step and direction); on a standard Arduino UNO, where you only have a maximum of 20 digital i/o pins (all 14 "normal" digital, and using the 6 analog i/o pins as digital pins) - so 10 motors, max (no serial comms/usb possible, either - or anything else - that would just be an arduino controlling 10 motors).

Even with a Mega, while that number would increase, it still wouldn't be enough for 32 motors.

All of that said - nothing would stop you from instead using eight daisy-chained 595 shift registers (giving you 64 outputs - enough for 32 motors), and 3 wires from an Uno (clock, latch, and data); alternatively, you can find SPI/I2C capable 8 and 16 bit serial-to-parallel chips that you could hang off the SPI/I2C bus of the Uno, then use the 2-wire library to interface with them...

So - the answer to your question is a bit of "yes and no" - "no", if you just want to use an Arduino and nothing else (besides the simple controllers for the motors), "yes" if you don't mind adding a bit of hardware ("intelligent" bus, or "dumb" bit-bang interface).

I will have them wired in series of two, 'cause for what they will be doing I will be needing two of them doing the same action when called uppon. So do you think that it would be a better idea to use the bus them together as you had stated or should I just wire up several different arduinos (or other micro controllers) together to get the same effect w/out overloading them?

Grumpy_Mike:

that I won't be getting to the programming portion is several years away

Not a good idea. Never get all the hardware assembled and then look to program it, you could end up with a lot of junk.
Better to start small, just use one motor for what ever you want. Then write the software to control that.
When that is working extend the software to control all your motors even though you have not built them yet. Look at the performance and the effect on the one physical motor you have. If it is still OK then build the rest. If not get it to work with the minimum hardware and maximum software before spending several years building the hardware.

Nothing is worst than building a lot of stuff and then discovering a design flaw.

In this case I would have to disagree w/ you. Because I'm going to have to make sure that the physical design is sound & able to w/stand the stresses that I will be putting it under before I get to the programing to make sure that that end works.

W/ the project that I'm doing (I'm sorry but I'm going to have to keep this under my hat for now) I need to make sure that it will work soundly w/ my layout long before I can get to the computer end of things. All I can say is that I am trying to digitize something that is sever thousands of years old lol. So far my small scale & my drawings work out just fine w/ a few adjustments but w/ the holidays coming up I'm going to have to put things on hold.

sofiadragon1979:
I am @ the forefront of a project that I won't be getting to the programming portion is several years away but I'd like to get this out of the way now.

We recently had a post from someone who had (allegedly) spent two years making a robot, and had allowed one day for the programming of it. That didn't end well.

I thought the Mega could control 48 stepper motors?
Oops - 48 servo motors. Never mind.

Steppers, need more control lines as was pointed out above.
http://www.tigoe.net/pcomp/code/circuits/motors/stepper-motors/

With a big project like this it is quite feasible to have more than one processor. One master one could use I2C to send commands to other ones.

The project will fail just as spectacularly with a software as with a hardware failure. You need to know at each stage of the project that both software and hardware can work. If you have limited resources (financial or engineering) I can imagine that the physical stuff may be a major challenge. However the reality is likely to be that the software is the most challenging part.

...R

sofiadragon1979:
W/ the project that I'm doing (I'm sorry but I'm going to have to keep this under my hat for now) I need to make sure that it will work soundly w/ my layout long before I can get to the computer end of things.

We recently had a post from someone who had (allegedly) spent two years making a robot, and had allowed one day for the programming of it. That didn’t end well.

Huh…go figure…

sofiadragon1979:
If not what is the max # of motors that they can control?

To some extent it depends how fast you need to step the motors. Ultimately stepper motors just need a few digital outputs and you can provide a huge number of digital outputs using shift registers if necessary, but if you need to step them at a high frequency then this would be an unwieldy solution. If you just need to move the motors around individually that would be more feasible. You also need to consider the complexity of your controlling algorithm - with that many stepper motors being controlled, you might easily run into scalability issues in the sketch itself.

If I were you I would start small and work up, rather than spend years on one aspect of the project and assume that everything else will work.

Grumpy_Mike:
Not a good idea. Never get all the hardware assembled and then look to program it, you could end up with a lot of junk.
Better to start small, just use one motor for what ever you want. Then write the software to control that.
When that is working extend the software to control all your motors even though you have not built them yet. Look at the performance and the effect on the one physical motor you have. If it is still OK then build the rest. If not get it to work with the minimum hardware and maximum software before spending several years building the hardware.

Nothing is worst than building a lot of stuff and then discovering a design flaw.

You really need to consider this. If you are planning on a repeating a process 16 or 32 times, there is no reason not to get one example working first as a proof of concept and then expand that to include the rest of the project once you have it working. If you try to jump in headfirst, what happens when it doesn't work? You may never find the problem (imagine a program with over 1000 lines of code, and that's assuming you only have 'one' problem, which is an understatement). You are going about this a bit backwards when you say you want the hardware working first before you get to the "computer end of things". The hardware doesn't even 'work' without the programming. I can't see how you would know if your setup even works without some sort of way to test that. It isn't even complicated to get 1 of your many motors working, so don't worry about the complications involved with just 1.

As far as your original question, if you are chaining pairs of motors together, essentially you really then only have 16 motors (assuming the pairs are indeed identical), and with 32 control wires, I don't see why a Mega could not handle this. The Port Manipulation control options are really cool too (you can set up to, I think, 8 pins HIGH with one single line of code, which will help in your control of that many motors).

That's just nuts, I'm anticipating @ least 2-3 years for getting the bugs out of the electronics alone, & thats on top of the 5-6 years that it's going to take me to get the bugs out of the physical end of things. I'm just currious about the stepper motor question just as kind of a pre-planning thing.

Robin2:
The project will fail just as spectacularly with a software as with a hardware failure. You need to know at each stage of the project that both software and hardware can work. If you have limited resources (financial or engineering) I can imagine that the physical stuff may be a major challenge. However the reality is likely to be that the software is the most challenging part.

...R

sofiadragon1979:
W/ the project that I'm doing (I'm sorry but I'm going to have to keep this under my hat for now) I need to make sure that it will work soundly w/ my layout long before I can get to the computer end of things.

The nice thing about electronics is that I can work out the code & make sure that the code works before I even hook anything up to my project. But w/ this project I HAVE to make sure that the physical end works before I can come close to working on the electronics end of it.

The stepper motors will be working the same actions as if they weren't there, so it's just like I had stated several times before.

sofiadragon1979:
The stepper motors will be working the same actions as if they weren't there, so it's just like I had stated several times before.

I can't make sense of that sentence, and it seems to bear no relation to any of your other comments in this thread, but if you feel that there are other aspects of your project that need to be addressed before you get to trying the stepper motors then that's your call to make, of course.

PeterH:

sofiadragon1979:
The stepper motors will be working the same actions as if they weren't there, so it's just like I had stated several times before.

I can't make sense of that sentence, and it seems to bear no relation to any of your other comments in this thread, but if you feel that there are other aspects of your project that need to be addressed before you get to trying the stepper motors then that's your call to make, of course.

I mistyped sorry, What I was meaning was that the unit will be working the same w/ or w/out the stepper motors, so I need to make sure that it works w/out the stepper motors before I add them. I was still hallf awake when I typed that before I'm sorry.