Independet 595 circuits sharing data lines?

Hello folks,

I need some ideas/feedback on how to solve a problem where I'm going to share four outputs from
an Arduino to different independent 595 circuits using two extra address lines.

Each unit will have a 2x DIP switch that can select the address.

I have searched for possible solutions, but have not found anything.

Below is a draft diagram of how I think this can be solved. I have assumed that the SER(ial input)
pin on each independent 595 circuit can be shared with no extra logic. It is the SRCLK, RCLK and
^SRCLR that need to be handled by the extra logic.

Only the important connections are shown.

Some comments/feedback on this would be nice. :slight_smile:

Why? Just connect them in series, and send out two bytes to load them up when any data changes.
SRCLK, RCLK, in common, MOSI into the first, its output goes to the input of the 2nd.

digitalWrite (ssPin, LOW); // D10 to RCLK
SPI.transfer (byte1); // D13 to SRCLK
SPI.transfter(byte2); // D11 to Serial Data in
digitalWrite (ssPin, HIGH); // outputs update on this rising edge

SRCLR HIGH,
OE/ LOW

Because each set of 595 (the picture only show one but there might be many) are on individual PCBs and each PCB can be connected with each other dependent on what you need at the moment. Each card will have two connectors so they can be daisy chained.

This are test/development cards. Each card will have it's own library and I do not want the sketch/library code to depend that card A is the first card, and card B is the second.

Beside - it's fun to solve the problem :slight_smile:

So why not run the 4 signals then?
Clock, Latch, Data In, from the master, or the prior card,
and Clock Latch, and Data Out, passed on to the next card,
and daisy chain them?
You’ll know how many are in the system at any one time, yes?

CrossRoads:
So why not run the 4 signals then?
Clock, Latch, Data In, from the master, or the prior card,
and Clock Latch, and Data Out, passed on to the next card,
and daisy chain them?
You'll know how many are in the system at any one time, yes?

Then the code for each card will need to know where in the daisy chain the card is... and it need to know the status of the other cards... since it need to shift data for all cards one of the cards need to be updated.

And since each card (having different functions) has a specific library, the libraries need to be dependent on each other. I don't think that is a good solution.

Sounds like you need a chip select for each shift register then.
That can come from a shift register on the master board.

So each slave get SCK, MOSI, and a unique latch that can be from the master chip select creator.

What about some addressable I/O expander such as PCF8574?

I have considered using PCF8574 but my I2C bus is already full of them. Designing something different is a challenge.

I have searched for a chip selector but have not found anything that match this idea. Any suggestions for such a chip?

You can use something like (digital) 2:1 multiplexer with a control signal determining if default states of the pins (defined by pull-up/down resistors) or Arduino signals are selected. Other option is to use a D-latch with the control signal driving the latch enable pin (if the board is selected the latch is transparent for Arduino signals, otherwise it holds the last state).

The control signal may be either the 74LS85 = output or simply a XOR gates with outputs wired-or together using diodes (you can use i.e. 74LVC2G86). Maybe there are better options.

In either case I would also use the OE input of the '595, sometimes it is very useful.

One shift register on the master, creates individual chip selects for the boards:

digitalWrite(masterSSpin, LOW);
SPI.transfer (0b11111110); // first chip's ss LOW
digitalWrite(masterSSpin, HIGH);

SPI.transfer (chip1data); // first chip's data

digitalWrite(masterSSpin, LOW);
SPI.transfer (0b11111111); // first chip's ss HIGH
digitalWrite(masterSSpin, HIGH);

digitalWrite(masterSSpin, LOW);
SPI.transfer (0b11111101); // 2nd chip's ss LOW
digitalWrite(masterSSpin, HIGH);

SPI.transfer (chip2data); // 2nd chip's data

digitalWrite(masterSSpin, LOW);
SPI.transfer (0b11111111); // 2nd chip's ss HIGH
digitalWrite(masterSSpin, HIGH);

Thanks for the suggestion. I'll do some testing. :slight_smile:

CrossRoads:
One shift register on the master, creates individual chip selects for the boards:

? HC595 does not have a SS pin. It always receives data.

Hi,
What is your project that has so much I/O?

What model Arduino are you using?

Have you built any of your project to prove operation so far?

Thanks.. Tom.... :slight_smile:

It's development boards I'm making. They should be able to connect in a daisy chain in any order without having the code to know about the order. Each card has one library and all the library need to know is the address (like I2C devices).

The boards can be used on Nano, Uno or Mega.

No, currently I'm trying to figure out the best way to solve this. I'm not in a hurry. Beside, I'm waiting for a bunch of 74SNxxx chips that I might need to build this.

Already made several different I2C boards using a 6 pin connector to daisy chain them. Working fine :slight_smile:

"HC595 does not have a SS pin. It always receives data."

Use the RCLK pin as the SS pin. When it goes from Low to High, the output register is loaded with whatever had been clocked in on the previous 8 SRCLK Low to High edges.

How about this - add a 74HC165 to each board with a set of DIP switches, with their parallel inputs pulled high.
Each board gets a unique address set with the DIP switches connecting the inputs to Gnd. (Or, use a DIP rocker switch than connect an input to 5V or to Gnd). After a Reset, send out a Load Signal (which can be the latch signal for the 74HC595), then read in via MISO and SPI.transfer() the "address" of each board. The order the bytes are received in tell the Master what is connected where.
A Low to High captures the state of the inputs, use one of the Master shift register outputs to make the Load signal.
They can be daisychained just like the 74HC595. The Serial output does not have an OE/ signal, you will need to add a gate to keep the output from driving MISO if you will have other SPI devices outputting data on MISO for the Master to read. (like one gate of a 74HC125).
Put a weak pullup on the Serial input of each 165, which can be over ridden by a connected device, or read in as 0xFF when nothing is connected.
Or find a chip that does have an OE/ pin.

Hi,
Have you looked at the MCP23017 which has I2C or MCP23S17 which has SPI connections?
The 23017 is 16 I/O, the MCP23008 is 8 I/O.

Tom.... :slight_smile:

Little pricier than 2 chips if that is a concern over multiple boards.
8 Addresses too, if that is the max # of slave boards, then common SCL/SDA or common CS could be used for SPI and eliminate the need for the master chip select creator.

Already filled the I2C with 23017 chips :wink: And 8574A...

And as I wrote above - I like the challenge to solve this :slight_smile:

Never thought about using the 74HC165 chip. May consider that.

CrossRoads:
"HC595 does not have a SS pin. It always receives data."

Use the RCLK pin as the SS pin. When it goes from Low to High, the output register is loaded with whatever had been clocked in on the previous 8 SRCLK Low to High edges.

How about this - add a 74HC165 to each board with a set of DIP switches, with their parallel inputs pulled high.
Each board gets a unique address set with the DIP switches connecting the inputs to Gnd. (Or, use a DIP rocker switch than connect an input to 5V or to Gnd). After a Reset, send out a Load Signal (which can be the latch signal for the 74HC595), then read in via MISO and SPI.transfer() the "address" of each board. The order the bytes are received in tell the Master what is connected where.
A Low to High captures the state of the inputs, use one of the Master shift register outputs to make the Load signal.
They can be daisychained just like the 74HC595. The Serial output does not have an OE/ signal, you will need to add a gate to keep the output from driving MISO if you will have other SPI devices outputting data on MISO for the Master to read. (like one gate of a 74HC125).
Put a weak pullup on the Serial input of each 165, which can be over ridden by a connected device, or read in as 0xFF when nothing is connected.
Or find a chip that does have an OE/ pin.

Something like this?

Not quite.
Load has to pulse low to capture the data at the inputs.
Then 8 clocks are applied to bring the data out, to MISO, or to another device.

digitalWrite (loadPin, LOW);
digitalWrite (loadPin, HIGH);
incomingData = SPI.transfer(0);

Got more bytes? Do more transfers.