2
\$\begingroup\$

I'm sort of a newbie to this whole idea of shift registers and the Arduino shift register handling library. I've found many demonstrations online, where shift registers are daisy chained. But I need to connect multiple shift registers to my Arduino without daisy chaining them. My common sense says, Yes! you can, But I'm not quite sure and I don't have that IC on hand so that I can physically build the circuit and test.

I'm really shy and uncomfortable to ask this question to you guys whether if it turns out a stupid question. So.. please mercy on my soul :)

\$\endgroup\$
  • \$\begingroup\$ Why can't the SRs be chained? \$\endgroup\$ – uint128_t Apr 8 '16 at 19:06
  • \$\begingroup\$ they are for two different Circuit, It reduce the complexity of coding and some other issues with timing... But it can also be done by chaining the SRs... @uint128_t \$\endgroup\$ – Khaliddhali Apr 8 '16 at 19:18
  • \$\begingroup\$ Don't worry, it's a good question, though it could perhaps be improved with some details on why you want to do this, because as you can see, most people (including me) thinks that it's the wrong way to do it. \$\endgroup\$ – pipe Apr 8 '16 at 20:09
1
\$\begingroup\$

Yes. Each shift register typically requires three pins (data, latch, clock), but if your application makes it possible to share clocks or both clock and latch, then your required pin count will be less.

Keep in mind that if two shift registers are connected separately (no shared pins), they cannot be updated simultaneously (footnote: you can use the SPI peripheral to drive shift registers, and this can actually run while you bit bang other pins, so you sort of can update shift registers simultaneously. Sort of).

To expand on sharing latch/clock (assuming you are bit banging pins, and not using the SPI peripheral):

Shared latch: the SRs will update (the internal registers will be latched to the outputs) simultaneously. However, you will still have to clock the data to both SRs separately. The sequence would be "unlatch, clock data 1, clock data 2, latch".

Shared latch/clock: you can update the SRs simultaneously and clock the data out in a single sequence. In your clocking loop, you simply update both data pins. So the sequence is "unlatch, clock both data streams, latch". This is faster, but for many applications, this distinction won't matter.

\$\endgroup\$
  • \$\begingroup\$ what if I share the latch pin? can they be updated simultaneously then?Thanks @uint128_t \$\endgroup\$ – Khaliddhali Apr 8 '16 at 19:26
  • \$\begingroup\$ @Khaliddhali see my edits. \$\endgroup\$ – uint128_t Apr 8 '16 at 19:31
0
\$\begingroup\$

Why do you need to connect without daisy chaining?

The fastest and easiest way to update all your shift registers, using the existing simple Arduino tools, is to daisy chain.

In software, what you do is allocate an array of bytes, as many bytes as you have 595s. A single command will then shift the entire array out to all the 595s.

If one reason for not daisy chaining is that some 595s should not be updated, then simply load the corresponding byte with the old data, and that 595 will update to the same data, without any glitch. If you have different processes for different 595s, then simply alias their own pointers into the output buffer, each process can then update only its own bytes.

If you don't daisy chain, you will have to repeat the SPI byte out function for different pins, which consumes excess time, as well as excess pins.

Once the buffer transfer has been launched, it uses hardware, so is no extra load on the program. It would need to be a very large pipeline of 595s so that the latency through them became significant. Remember that if you drive all the latch pins in parallel, the outputs will all update at exactly the same time, regardless of their position down the pipeline.

\$\endgroup\$
0
\$\begingroup\$

While you can do this, if you need a lot of them and all of them are individual rather than chained, it might be easier to use an I2C GPIO expander, e.g. the PCA8574. Each of these chips provide 8 pins that can be independently controlled. They connect via the I2C bus and can be configured to one of 8 addresses, so you can use 8 of them with only 2 pins of your controller. This can be expanded by also using PCA8574As (which have a different fixed part of their address) to 16 chips per bus. Arduinos have a single hardware I2C port, but you can also control an I2C bus from ordinary IO pins, so can easily increase this to control more if necessary.

Of course, there is a downside to the pins being individually controllable, which is that if you want to change the output pins synchronously, you won't be able to. But if that isn't a requirement, I think using GPIO expanders is a simpler and more expandable route to controlling large numbers of outputs.

\$\endgroup\$
0
\$\begingroup\$

The anwser is Yes. The question is perfectly valid and it is applicable in certain scenarios where you need microsecond accuracy and out of gpios. Daisy chaining two 595 chips and sending two bytes would take double the time of sending just one instead.

Say you have a full 8-bit information which should be frequently updated on one of them, and only control bits that needs less frequent updates on another.

You could afford to lose one gpio in such a scenario.

You just need to assign separate STCP pins to each 595 in this case. DS and SHCP could be shared.

\$\endgroup\$
0
\$\begingroup\$

But I'm not quite sure and I don't have that IC on hand so that I can physically build the circuit and test.

you can do it, easier with HC164 than with HC595 but definitely doable: using the latch pin as a chip-select mechanism.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.