Cascade of 74hc595 to control several stepper motors

Dear All!

I have been for a long time looking for an example of sketch in which the usual shift register (like 74hc595) is used to control stepper motors. In fact since I am using SEVERAL usual steppers (28byj-48 with ULN2003 driver) I am trying to find a code for a cascade of 74hc595.

So far I have been able to find lots of examples how this works with LEDs, but never - with stepper motors. If you have ever come across such a sketch, would really appreciate a link (or if you have something that can be used as basis, would be grateful for sharing).

Many thanks in advance!!!

You will still need the ULN2003s

How many steppers do you want to control ?
Will each be getting a different set of step pulses ?
Can your Arduino generate all those pulses at the correct intervals ?

...R

Robin, thank you.

I will have 40 stepper motors. Ideally would like to control them all simultaneously. E.g. simultaneously instruct at which angle each of the motors should rotate.

Given the number of motors I came to conclusion that a cascade of 74hc595 shift registers should be the most economical way to organise the grid (of course with extra ULN2003 for each motor too).

However, I am struggling with finding an example of a code in which 74hc595 is used to control steppers. All "shiftout" and similar sketches relate to controlling a chain of LEDs, and I cannot understand if it is possible to use 74hc595 to control stepper motors at all.

many thanks!

He should be able to generate the output for 40 motors.

I built an 8x8x8 RGB LED cube using ATmega328p and at its lowest output rate setting it can output 1,280,000 bits per second via SPI on an interrupt and it still had some processing power left to do animations at a decent speed. So, 40 bits at lets say 1Khz (idk, just seems like this is a good number) would only be 40,000 bits per second.

Hi,

I will have 40 stepper motors. Ideally would like to control them all simultaneously. E.g. simultaneously instruct at which angle each of the motors should rotate.

So you have 40 stepper motors which you want to control all at once, but each stepper different number of steps.
Or all steppers to move in unison/phase/speed/as one?

Tom.... :slight_smile:

arduinolearner:
I will have 40 stepper motors. Ideally would like to control them all simultaneously. E.g. simultaneously instruct at which angle each of the motors should rotate.

I am assuming each motor will need to be controlled separately.

I don't have any 28BYj steppers but I am aware that they require more computational effort from an Arduino than would a bipolar stepper motor that is controlled with a stepper driver that just requires step and direction signals.

How many steps per second will your motors require?

I think it would be a challenge for an Arduino to control 40 bipolar motors, never mind 40 unipolar motors, unless they are moving slowly.

Organizing the steps to be propagated through the cascade of 74HC595s will add a further computational burden.

I have a 74HC595 but I have not used it yet. Looking at the datasheet I wonder can you send new data to it while the existing outputs remain unchanged and then cause the new data to appear on all the outputs at the same time? It looks to me that the new data will propagate through the output pins - for example if you want to set pin 7 to 1 and all the rest to 0, does that mean that each pin will briefly display a 1 as the value is clocked in? I wonder if that process would be suitable for controlling a stepper motor, whereas it may not matter with LEDs.

...R

Thank you Tom and Robin. Indeed - each stepper - different number of steps. They should start simultaneously, but each should rotate independently from others. Robin, the challenge you are describing is exactly what I am struggling with. May be that is the reason why there is little or no examples of controlling many stepper motors by Arduino. The closest I could find was the following, but not sure if it can be reworked into controlling several motors simultaneously. Projects from Tech: Arduino Shift Register Stepper Motor Controller

Robin2:
I have a 74HC595 but I have not used it yet. Looking at the datasheet I wonder can you send new data to it while the existing outputs remain unchanged and then cause the new data to appear on all the outputs at the same time? It looks to me that the new data will propagate through the output pins - for example if you want to set pin 7 to 1 and all the rest to 0, does that mean that each pin will briefly display a 1 as the value is clocked in? I wonder if that process would be suitable for controlling a stepper motor, whereas it may not matter with LEDs.

...R

Yes, you can send data to it without affecting the outputs. There is an internal latch that buffers the shift register. When you activate the latch clock, all the shift register bits are transferred to the output simultaneously.

Again, I was able to push 1.28Mbps out of the SPI on an interrupt with only minor strain on the ATmega328p, So I cannot imagine this to be too much of a hassle.

However, let me give you this to keep in your back pocket.
Adafruit 24-Channel PWM Shield

I see from the link that you can use the RCLK pin to hold the value until all the new data has arrived - so that dispenses with one of my concerns.

I don't understand how the PWM shield (that @Ps991 has linked to) is intended to work? I presume it can generate 24 different PWM signals on receipt of instructions from the Arduino that are the equivalent of pwm(11, 123)

If that is correct I can't see what relevance it has to stepper motors which require differently timed pulses, not different duty factors.

The problem I foresee with the 40 stepper motors is that the Arduino has to calculate the timing for steps for 40 devices before it can even consider sending out any data.

@arduinolearner you MUST make an estimate of how many steps per second a typical motor will need. Without that it is impossible to have an opinion about whether the project can work.

...R

Thank you everyone. To respond to query - the speed is not very significant for the project. The key is the ability to control many motors at once. The above gives lots of food for thought and trying. I am surprised however, that having spent quite some time searching, still looks like there were little or no projects where shift registers were used to control steppers...hope it is actually doable in real life

Sorry, I have never used stepper motors, I figured they just work on duty cycle. :confused:

I just googled "shift register stepper motor" and I got many results of people using shift registers to control stepper motors...so...?

arduinolearner:
the speed is not very significant for the project.

Why are you so reluctant to put a number on it ? Something that is not significant for 1 motor might become quite impossible when there are 40 of them.

Ps991:
never used stepper motors, I figured they just work on duty cycle.

Steppers are very different from DC motors. They move by alternatively switching on and off the current in different coils. From the point of view of the Arduino the current is either full on or full off. The timing is what governs the speed. (The more complex aspects of controlling the current are dealt with by the specialized stepper motor drivers and are not visible to the Arduino).

...R