Controlling 32 or more stepper motors

Hi Everyone,

I don't have much experience working with Arduino or electrical projects, but I am totally enjoying learning through some basic (LED / Servo-related) exercises with my Arduino UNO. I am planning to build a project that would have 32 light-weight discs (approx 30 mm diameter), each rotating and controlled independently from each other using Arduino UNO. There is no constraint on the rotation speed as long as it's not super slow, so anything higher than 9 rotations per minute should be fine. However, the rotation must be precise at 10 degrees angles.

Based on my research so far, I am planning to use 32 stepper motors for this project. At first I thought of using 5V DC 28BYJ-48 stepper motor with ULN2003 driver since they appear to be most common. But turns out this will need 4 pins per stepper, hence requiring 128 pins in total. Since Arduino UNO has limited digital IO pins, some kind of IO expander for I2C would be required. I found MCP23017 (16 pins) which can be daisy-chained 8 times, totalling to 128 pins (lucky!!), and it also ships as expansion board which is good (easy for me to work with). While this solution seems to be okay, I do not like it because it doesn't seem extensible (e.g., if 10 more steppers need to be added in future).

Upon reading more, I found A4988 driver requires only 2 pins per stepper but the motor needs to be bipolar (i.e., not 28BYJ-48). This would need 64 pins in total, and hence only 4 of the MCP23017 need to be daisy-chained. This design is extensible (which is great!), but working with this driver appears complicated. Unlike the ULN2003, there doesn't seem to be a simple driver board easily available which I can simply plug and start using. This means I will have to worry about heat sinks, capacitors, soldering, etc., which I am trying to avoid.

Now, I have multiple questions here:

  1. Am I correct in assuming the 128 pin solution (32 x ULN2003) with 8 x MCP23017 is not extensible when trying to add 10 more steppers? If not, it would be great to understand what I am missing here.

  2. What would be a good suggestion for a small bipolar stepper motor that works with A4988 or an easy-to-use driver?

  3. MCP23017 is a digital IO expander, and so inputs/outputs are binary ON/OFF. Would that be compatible with stepper drivers like A4988 and ULN2003?

  4. How do I understand the current requirements for stepper motors? The datasheets don't seem to have such info. For example, see these two:
    https://mm.digikey.com/Volume0/opasdata/d220001/medias/docus/2534/108990003_Web.pdf
    https://pdf1.alldatasheet.com/datasheet-pdf/view/1132391/ETC1/28BYJ-48.html

  5. How do I calculate the current requirements for the overall project? Assuming each stepper takes 25mA, each driver takes 50mA, and MCP23017 needs 125mA, would the total current requirement be (25 + 50) x 32 + 125 x 8 = 3400mA? The numbers in this example are arbitrary but I am trying to understand how to calculate and how to connect the external power supply to these components.

  6. Out of curiosity to understand future limitations, what is the maximum possible number of stepper motors I can control using a single Arduino UNO?

Hoping for some help. Thank you!

2 Likes

no, every stepper motor takes 180-200ma, so that's 8,360ma, or 8.36A.

a good one is 28byj-48, it's compatible with the A4988 but uses 180ma, but it uses 5V.

any amount, max is 6, but if you have lots of shift registers IO extenders, clock speed is the limit!
and memory.

1 Like

With enough I/O expanders, more than you could possibly want to control.

But if the motors are all supposed to be independent, one Arduino can command only one stepper to take one step at any one time.

So the more motors, the slower everything will happen. Start with two motors, then four, and see how it goes. Furthermore there is a memory limitation, as you have to keep track of each motor state independently. 2000 bytes on an Uno do not go far.

Arduino knockoffs are cheap, so have a few of those, each controlling a manageable number of motors.

2 Likes

are this 32 motors independent or are in 4 fixed on one ring so actually it are 4 rings ?

not really. Stepper motor 28byj-48 5V from unipolar to bipolar

it is always only 1 pin from 4 active, so you may use demultiplexer, need 2 pin, but if you take counter like CD4017, it need 1 pin

2 Likes

Thanks @LoganTheEngineer7. Let me check out 28BYJ-48 again.

I meant the maximum possible when using IO extenders.

1 Like

Thanks @kolaha. The 28BYJ-48 unipolar to bipolar conversion looks very interesting. Hope I don't screw it up :slight_smile:

All are independent. No rings or any other co-dependencies.

Is there a simple demux board/breakout that I can try this with? Also, does demux interact fine with the IO expanders?

1 Like

Why is it that absolute beginners take on projects that are absoloutly beyond their current state of knowledge? We see it over and over again. I suppose all those simple questions are the clue.

Anyway, as you have seen there are two types of stepping motor, 4 phase and bipolar. Any 4 phase motor can be wired up to look like a bipolar motor. The current any motor takes depends on two things, the main one being the resistance of the coils, the other is the speed it is running.

Now, rather counterintuitively, the slower a stepping motor is moving, the greater is the current, to the point that a stopped motor takes the maximum current. But the faster it moves the lower is the torque. So when you ask it to go fast, the torque drops, and when the torque developed is less than is needed to overcome the mechanical load, (that includes the inertia of the motor plus anything it is moving), the motor stalls and so draws the maximum current.

The resistance of the motor's coils along with the voltage that is driving it governs the stall current that is needed. But the higher the voltage then the faster it will run, because the current gets into the coil windings quicker.

Now you can get stepping motors with a wide variety of coil resistances, requiring a few mA to many amps per winding. So it is absoloutly vital for any design that you choose what motor you are going to run. Without knowing that it is just silly to postulate any design. So first off choose your motor and tell us what it is.

If you want to avoid these things then forget this project all together, because it is not going to happen without all these things, and more. Scaling up anything is hard. Think of the difference between making a few loafs of bread in your kitchen, to being able to supply a high street shop. Electronics scaling up is harder than that.

3 Likes

oh yeah, shift registers don't really work with sensors, but rather outputs, I still think clock speed is the limit.
and memory, don't forget memory!

1 Like

Thanks @jremington. It would be great to understand how many possible servos that could be with enough I/O expanders. Since MCP23017 could only be daisy-chained 8 times, I can see a physical pin limitation to 128. How can I go beyond that?

This is a great point I hadn't considered. Let me try this.

I had thought about this. But is there a way to synchronize multiple Arduinos so that they start at the same time? Otherwise the stepper movements might appear unsynchronized.

1 Like

yeah, you can program them to communicate so they'd be in sync.

1 Like

It looks like @lavekravo might not be worried about knowing where things are.

However the other concern is he said:-

That is very unlikely to be achievable, because stepping motor angles do not tend to be multiples of 10. That could render the whole project unachievable.

But again as I said:-

2 Likes

1 Like

Thanks @Grumpy_Mike. Let me check out wiring 4-phase to look like bipolar.
Your motor current explanation is helpful.

It seems I will go with 28BYJ-48, wired to be bipolar.

It would be easier if there was something like a breakout board that contains all those parts in a package. But I get your point, it's not as easy :slight_smile:

1 Like

That sounds super cool. I will read more about this as well.

1 Like

I'm thinking 1 Arduino is the "master" or the brains and controller, while the others are "slaves" or the ones the read/write pins and send/get data to and from the "master".

That's true. I don't care about positions. I will only signal steps and direction from the current position.

In that case I can change my math to work with whichever precise angle steppers can give me, nearest to 10 degrees. No worries.

1 Like

yeah, before you ask, yes, I'm basically talking about SPI communication.

So it is like running the "follower" to mock like a IO expander? I wonder what's the impact on latencies or reactiveness in this situation compared to IO expanders.

1 Like

So that is going to be super slow, because of the gear box.

But wiring it as a bipolar motor requires you to drive the motor with a circuit called a H-bridge, that is an added complication not mentioned yet.

That motor moves at 4096 steps per revolution. So I assume you can do the maths.

It is always good to look at the data sheet for anything you use. Here it is for the motor you are planning to use:-
stepd-01-data-sheet-1143075.pdf (193.2 KB)

I'm not sure, I never tried this before, just an idea, but I will take a leap and say no, Arduinos are not as reactive or responsive as IO expanders.
maybe, unless... we do DPM!
DPM takes 0.5 µs to do something, that's fast!

2 Likes