Stepper motor : shift register vs atmega-328 i2c

Hi at all,

My name is Riccardo and I write from Italy.
I'm trying to move a bipolar stepper motor (like the Nema 17) drived by an EasyDriver or A4988 chip, that use only two pins to drive the motor (step, dir).
I need to move a large ammount of motors, and I'm searching some trick to do that. I've thought to make an i2c chain with Atmega 328p-pu and let that each drives some steppers, where is another arduino "master" with the movement library that drive all the 328 in i2c. Another options is to use shif register like 74hc595 that with 3 pin from the arduino have 8 exit each.

So my question is: with the shift register is possible to do that? Because the stepper board needs two digital pins (boolean - direction, pulse for the steps) to be drived, the 595 is able to put out digital pins?

My targhet is to work on the master like all the pins are connected to it, and let the 328 or 595 work to interpretate the signal from the master to the outputs.

Many thanks. Riccardo

How many motors do you want to control?
How many steps per second are required for each motor?
If two motors are moving at exactly the same speed and direction perhaps both could be controlled from the same step and direction signals.

...R

Hi, I need to control (for example) 64 motors, an 8x8 matrix, and each motor need to move indipendently from each others. Each motors needs to move smooth also at higher speed, so with the control board will do a lot of steps per seconds.

Riccardo

Radicator:
also at higher speed, so with the control board will do a lot of steps per seconds.

You must put a number on "higher speed" so that you can calculate whether an Arduino can work fast enough.

Suppose you have (say) one Arduino for every 8 motors. Can the controlling Arduino send commands to those 8 Arduinos without needing to send individual step pulses for each motor ?

You need to explain in a lot more detail what your project is trying to do.

...R

Hi,

the maximum step per second depends on the voltage that I apply to the control board, for example 12v (that is my targhet) let the stepper moves at least at 4000 step/s, so in the range each stepper will move from 0 to 3000 step/s but more often at lower speeds. Each 328 board will drive stepper as the free pin, so 2 pin per stepper is 8 stepper, that let free 4 more pins on the board (two for the i2c and two for other controls).

Each 328 board will have the library instead for the stepper and the control board, and the arduino master will only transfer in i2c a list of "step targhet" to each 328 and the 328 will switch the command to each motor.

This will be better than work with shift register instead the 328p-pu?

Thanks

Radicator:
This will be better than work with shift register instead the 328p-pu?

I don't really know what you have in mind.

My understanding is that a shift register is a passive device that would just distribute pulses coming from elsewhere.

If you need 4k steps/sec per motor and you have 8 motors on one Arduino that means 32k steps per second - or 31 microsecs between steps. A single step needs two actions - a HIGH followed by a LOW. That means an average of 15 usecs per action. It does not leave a lot of time for the Arduino to do anything else - such as communicate with another Arduino.

I think you can easily see that a single 16MHz Arduino could not possibly control all 64 motors.

I think you need to write some experimental code for a single Arduino to see if you can get the performance you need when it is doing everything you want it to do.

...R

But if I send in i2c a packet of targhet positions to other atmega it'll demand to other 328p the work, so one atmega will drive at least 8 motors and the master will only setup the connections and send the targhet, right?

Riccardo

Radicator:
But if I send in i2c a packet of targhet positions to other atmega it'll demand to other 328p the work, so one atmega will drive at least 8 motors and the master will only setup the connections and send the targhet, right?

That sounds reasonable - but it still needs to be tested to prove it will be suitable.

I worry about your use of the words "at least". I would be more comfortable with "at most" - but you need to test it.

...R

Hi,

with the atmega 328 pinout (8 pin free) I can attach 4 stepper each, in these days I'll do some test and write soon news, thanks at all.

Riccardo

The analog pins can also be used as digital pins - which might give you 6 more pins.

...R

First make sure you can write the software to generate 8 sets of pulses at the
rates you require - what approach are you using for this?

MarkT:
First make sure you can write the software to generate 8 sets of pulses at the
rates you require - what approach are you using for this?

That is what I was trying to say, but you have expressed it much more clearly.

...R

I use a stepper library that let me put in only 3 value: targhetPosition, acceleration and max speed. The library will automatically send the output to the stepper board a boolean pin for the direction, and a pulse pin for the steps, according to the accel. and speed sets before.

Meanwhile I've see better the board layout, and I have 20 pin free to use, so 2 for i2c and 2 for buttons (for example) Let me free 16 pin to make some!

Yesterday I was able to transfer an int, long and float through I2c, separate each character, put all toghether in an array, transfer it, and rebuild my value in the 328, it works.

Now I want to change the code to transfer multiple number (int for me is enough) switching from the three value that I need to transfer, and let those three value go only to the targhet stepper, then send another three to the next motor.

Thanks, Riccardo.