Do shift register give me individual controll over connected steppers?

I read this tutorial on how to controlling four stepper motors with shift register using 74HC595 shift register. I got a (maybe) stupid question. Does this give me individual control of every steppermotor so I basically just can loop throught the steppers and give them individual instructions or am I running them in parallell? I guess this gives me individual controll since if not it wouldnt make any sense making the effort but just want to make sure. :slight_smile:

Thanks

Well, the stepper control outputs are separate outputs on the shift registers, so they can be controlled separately.

The ‚Äútrick‚ÄĚ is that in your code, you have a variable whose value you shift out into the registers. To control each particular stepper, you alter only the bits in that variable which correspond to the particular stepper without altering any other bits. Then you shift the variable out to the registers.

Said tutorial is however doing it the hard way!

Easier to use a ready-built port expander module.

One or more of these connects to your I2C interface.

Thanks! That is a great tip! Is it possible to chain these to get even more ouputs?

I saw this for example.

But it says that you can chain 8 of them. I need lots of outputs :smiley:
Can you technically chain the one you linked to?

At the moment I am actually already using the i2c, connecting multiple arduinos as slaves to an raspberry pi. Is it possible to continue connecting portexpander through the i2c to the arduino i2c slaves?
As the example below giving me lots of IO:

Raspberry pi (i2c master)
-> Arduino1 (i2c slave) -> 16 IO portexpander module -> 16 IO portexpander module 16 -> IO portexpander module
-> Arduion2 (i2c slave) -> 16 IO portexpander module -> 16 IO portexpander module 16 -> IO portexpander module
-> Arduino3 (i2c slave) -> and so on ...

Well the port expander you cited physically ‚Äúchains‚ÄĚ, but they are actually parallel on the I2C bus, each one must have a different address set and there are 8 addresses (three jumpers) available, so eight devices with 8 I/O each.

The module I cited above using the PCF8575 has 16 I/O and while this chip also has 8 addresses available, that particular module only allows four to be selected - I believe other versions of the module make all eight available. You again connect them all in parallel, each having a different address selected, you just have to perform the parallel wiring differently. :grinning:

As long as the I2C addresses of these devices differ from those you are presently using, you can connect them all together. You will however have to remove the pull-up resistors from all but two or three of the modules, leaving them on those at the ends of the wiring.

@acroscene, I'm not sure your idea will work. The Arduino would have to be an i2c slave to the pi but an i2c master to the I/o expanders. I have read that multiple masters on the same bus is allowed with i2c, but I never heard of Arduino being used this way.

I also do not see the need for the Arduinos in your plan. The pi could control all the I/o expanders directly. Up to 8 pcf8575 can be attached to the same bus, giving 128 outputs. If more are needed, you could add a tca9548 i2c multiplexer, allowing up to 64 pcf chips with 1024 outputs.

Controlling a large number of stepper motors this way might be limiting. I2c bus is relatively slow, and this could limit the maximum speed at which the steppers can be instructed to turn.

Another option would be to use dedicated stepper controller chips. These can generate the signals to turn stepper motors at a given speed and direction without constant updates from a central processor, so the slow speed of i2c would not be a problem.

Ok. Thanks for the answer. I run into another possible solution using TCA9548A 1-to-8 I2C multiplexer. Im not sure but would that allow me to connect multiple parallell port expanders. For example like this:

Raspberry pi (i2c master) -> 
TCA9548A output1 ->
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
TCA9548A output2 ->
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
TCA9548A output3 ->
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
- portexpander module IO 8 channel
And so on

And so on giving me 512 outputs from i2c.

8 (outputs from TCA9548A) √ó 8 (number of parallell portexpanders) √ó 8 (outputs from each portexpander) = 512 outputs

Since my plan is to use the cheap stepper 28BYJ-48 with the driver ULN2003 it will let me connect 512/4=128 steppers using this configuration. It is fine but ideal would be to be able to connect over 200 steppers. Dont know if there are expansions for this number of channels only through one i2c bus ....

Would you say that my assumption above is correct?

You will however have to remove the pull-up resistors from all but two or three of the modules, leaving them on those at the ends of the wiring.

sorry didnt got that? why do I need to do that? and how can I do that?

Sounds as if you are making one of those "clock clocks" or whatever they are called. :grinning: We've had that question before.

How do you plan to determine the reference position of each stepper?

Paul__B:
How do you plan to determine the reference position of each stepper?

My plan is to use a reset switch to reset the position every now and then :slight_smile:

PaulRB:
I also do not see the need for the Arduinos in your plan. The pi could control all the I/o expanders directly. Up to 8 pcf8575 can be attached to the same bus, giving 128 outputs. If more are needed, you could add a tca9548 i2c multiplexer, allowing up to 64 pcf chips with 1024 outputs.

Posted the same time :slight_smile: Seems similliar to the solution I was thinking of in post #5. But how did you got 1024 outputs? As I understood it there are 8 outputs from the PCF875 with the possibility to use 8 in parallell = 64 outputs ... * 8 using TCA9548 = 512 ?

acroscene:
My plan is to use a reset switch to reset the position every now and then

So exactly what is a ‚Äúreset switch‚ÄĚ, how is it mounted and how will you be connecting all of them?

hm. not 100% sure yet how to connect everything but the reset switch is just a switch that gives an input to the code for resetting the position of the stepper to 0.

I got this working using multiple arduino mega connected to i2c but using TCA9548 and PCF875 seems like a cheaper solution :slight_smile:

acroscene:
As I understood it there are 8 outputs from the PCF875 with the possibility to use 8 in parallell = 64 outputs ... * 8 using TCA9548 = 512 ?

No such chip as pcf875. There is pcf8574 with 8 outputs and pcf8575 with 16 outputs.

Perfect. Thanks for answer. I also found this chip MCP23017 which seems to be recommended. I dont know how it differ from PCF875. However it seems to be widely availible so if it works the same it would be a perfect solution

In that case:

Raspberry pi (i2c master) ->
TCA9548A output1 ->
- portexpander module MCP23017
- portexpander module MCP23017
- portexpander module MCP23017
- portexpander module MCP23017
- portexpander module MCP23017
- portexpander module MCP23017
- portexpander module MCP23017
- portexpander module MCP23017
TCA9548A output2 ->
- portexpander module MCP23017
- portexpander module MCP23017
- portexpander module MCP23017
- portexpander module MCP23017
- portexpander module MCP23017
- portexpander module MCP23017
- portexpander module MCP23017
- portexpander module MCP23017
and so on.

That would result in 8 (outputs from TCA9548A) * 8 (number of parallell portexoanders) * 16 (outputs from each portexpander) = 1024 outputs.

This would work right?

Yes, mcp23017 is very similar to pcf8575, but often a little more expensive, a little more complex to use, a few more features, but those features probably no benefit to your particular project.

Another possible option to drive your steppers could be tpic6b595. Each chip is similar to 74hc595 + uln2803, so might be able to drive 2 steppers directly with no need for uln2003. But you need to check the current required by your chosen steppers is below 150mA per coil. They can be chained to give any number of outputs, although some signal buffer chips will be needed for a large chain, such as 74hc14 or similar. They can be driven with the pi's spi pins.

Thanks!

Im about to order the mcp23017 anyway :slight_smile: for trying. I got a bit confused. At the place where I order there multiple models of mcp23017. I guess they are about the same, just different manufactures. Or are there any difference between these two:
https://eu.mouser.com/ProductDetail/Adafruit/732/?qs=GURawfaeGuDsiwNCtfEn8A%3D%3D
https://eu.mouser.com/ProductDetail/Microchip-Technology/MCP23017-E-SP/?qs=usxtMOJb1RyESXZDw7ia5A%3D%3D

I guess not?

I think they are the same. Same manufacturer, one has a more detailed part number. The ‚Äú-E/SP‚ÄĚ is explained on page 38 of the data sheet. ‚ÄúE‚ÄĚ is the temperature range of the chip (-20C to 125C) and the ‚ÄúSP‚ÄĚ means a dip chip which is what you need for using with breadboards, strip board etc.

Oh well, I did suggest … :roll_eyes:

Thanks Paul :slight_smile:

Actually maybe I will try both chips. See which one works best for my purpose

But if i would buy and try with PCF8575 as well. Which one should I pick? There are two pages of the same chip at mouser

https://eu.mouser.com/Search/Refine?Keyword=PCF8575

Well, although there are some concerns about the quality of things direct from China (and I doubt Mouser obtains them from anywhere else! :astonished: ) I would favour an assembled module like this one

Another Aliexpress link

which correctly brings out all three address selection pins.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.