Hardware needed to control 30 steppers

Hi all,

I need to control 30 stepper motors (28BYJ-48) - (5V) .
Each motor has to be controlled individually.

How do I do this ? With a port expander ?
Could someone pls tell me which port expander is needed to use with Mega.

Thanks.

You will need a driver for each motor. Those motors, unmodified, are uni-polar so one of these drivers would work.

Using the top driver each motor would need 2 outputs. So 8 each (8 outputs) 74HC595 SPI shift registers or 8 each (8 outputs) MCP23008 I2C port expanders to control the 30 motors. That would take either 2 (I2C) or 3 (SPI) pins from the Mega.

I suspect most people buy the 28BYJ-48 steppers as a package with a ULN2003. The ULN2003s that I have expect 4 inputs from the Arduino.

Maybe you could add the resistors shown in the diagram to make them work with two Arduino pins - but I’m not sure how that can generate the correct sequence of pulses.

Even if the connection problem can be solved a potential obstacle with 30 steppers is the ability of a 16MHz Arduino to produce step changes at the necessary speed for all of them.

…R

I have used the two wire unipolar driver before and it worked OK. The stepper.cpp file shows the pin sequence for the two wire unipolar driver.

Another consideration is the power supply for that many motros.

IMO it depends on what the steppers should do. No problem if only one stepper moves at a time, but if the steppers have to move altogether, with different distance, speed and ramping, more controllers can simplify things considerably, including wiring.

Thanks all for your replies.

The motors come with their own driver.
Some of the motors should run together with different speeds or all together with different speeds.

I'm told I could use 3 Megas, I have read the article about master/slaving 2 Arduinos
but not sure how to go about it.

I’d start small, with one Arduino and as many motors as it supports without extensions. Controlling a considerable number of motors with a Mega requires appropriate code. Adding port expanders or further controllers adds more code later.

Master/slave may be quite simple, if you send all motion commands from a PC. Then you can address multiple Arduinos at different COM ports, or one Arduino relays the incoming commands to the proper target controllers.

DrDiettrich:
I'd start small, with one Arduino and as many motors as it supports without extensions.

I agree with that. For one thing you need to learn whether the Mega can perform as well as you need.

...R

You can multiplex the motors.
The Arduino can cycle faster than the motors physically step, so if you have drivers that hold state, you can ‘round robin’ all the motors to achieve ‘simultaneous operation.

I’d be starting with a struct to define each motor, and an array of those structs to define all 30 motors.

lastchancename:
The Arduino can cycle faster than the motors physically step,

That may not be true for 30 motors that are not exactly in sync. A lot will depend on how the step instant for motor 17 compares with the step instants for motor's 23 and 12 (for example).

...R

Typical stepper driver modules require an explicit pulse for every step, have no notion of position, speed etc.

Slightly different pulse starts are fine, they help to balance the power supply load.

Very true.
I’m guessing the processor will run several times faster than the compound of the step demand, so there should be a lot of leeway to interleave mixed/different step rates.

lastchancename:
I’m guessing the processor will run several times faster than the compound of the step demand, so there should be a lot of leeway to interleave mixed/different step rates.

I reckon it would be a good idea for the OP to set up a realistic test to satisfy himself that that is true.

The Arduino won't just have to generate pulses. It will need to figure out when the 4 output pins for a motor need to be updated and which pins need to be high and low. And it will probably also need to collect commands that tell it to change its behaviour.

...R

Second thread in a short time asking about dealing with lots of these steppers.

I'm almost thinking there may be a market for slightly more advanced driver boards. An ATtiny listening to I2C commands from a master Arduino, each controlling a single 28BYJ-48. The master then can send high level commands like "stepper 12 at 3.5 rpm".

In terms of master/slave the top level master (PC?) most probably has a script and only can send top level motor commands, which have to be executed by subordinate masters and slaves. More complex if various sensors control the movements of the motors, without a script.

I saw this :

and with the kind help of the author, I made one for an institute which cares for special need kids.

I understand there is a big difference between servos and steppers, but I thought there would be a
way to maybe apply the same approach.

It seems like I'm out of the ball park ?

I'm afraid so - very much so even.

Regular steppers, operated by a stepper controller board, take a pulse input to make steps. That's a single output of the Arduino toggling high/low at a certain speed - this can be done easily with the tone() function. A number of those functions can run concurrently, see documentation how many, definitely not 30.

The bipolar ones you want to use require four output pins of the Arduino, which are operated all together for each part of the step you make. That's a lot more work for the controller (and a lot more pins).

In contrast, the servos are all operated by an external controller board; the Arduino merely has to give the command to the respective servos where to go, and after that is done. Much easier on the hardware.

Maybe I just should have wrote what I'm trying to do and ask help !

How would you go about making something like this ? A much SMALLER one .

Is it possible to use DC motors with encoders instead of steppers ?
Can I control the speed of the DC's ?

ba47:
Is it possible to use DC motors with encoders instead of steppers ?
Can I control the speed of the DC's ?

Possible.
You have to read the encoder pulse (this is very timing sensitive), calculate how long it took before the previous pulse came in (or how long it took for n pulses to come in), check whether that's the correct speed, and if not adjust your PWM value accordingly.
Advantage is that you can use an external PWM board, so that part of the hard work can be offloaded.
If you want to run the motors in two directions you need an H-bridge (e.g. the TB6612FNG which can control two small motors); if just one direction a simple MOSFET to control the power to the motor will do. Depending on the speed, and how many pulses are coming in from the encoders, a single Arduino may be able to control them all. You'd also need some port extenders for all the other control pins of the H-bridge.

ba47:
Is it possible to use DC motors with encoders instead of steppers ?
Can I control the speed of the DC's ?

Reading an encoder (even with just one pulse per revolution) without missing pulses is hard work for an Arduino and so is the PID code to manage speed. It is very practical with a single motor (and maybe with two or three) but IMHO controlling 30 motors would be much less feasible than using stepper motors. It would also involve a lot of extra connections.

Using bipolar stepper motors that can be controlled by an A4988 or DRV8825 stepper driver would significantly reduce the computation load on the Arduino and each driver would only need two Arduino pins (step and direction). However the motors with drivers would be considerably more expensive than the 28BYJ stepper motors.

...R
Stepper Motor Basics
Simple Stepper Code