74HC595 and 74HC165 with 4 or 5 pins at most

Hello folks,

Again new project, so would like to know your opinion before PCB making.

Need to replace MCP23017 based IO board. Was good to lit led or receive push buttons. But not that handy for control cabinet, relay switching and mainly receiving signals from AC contactors.
In short, MCP is like an antenna! Here is my advise to go that way.

  1. place your MCP board as far as you can from any cable AC loaded
  2. make sure your DC supply negative pole is connected to AC grounding (green yellow).
  3. even surge suppressor addon on the contactors did stop MCP IC used as input failing operation,need to reset, sometimes software init enough, sometime power cycle needed...
  4. gonna try ferrite core beads on input lines and power lines, but no trus in that IC any more

As replacement, want to use shift registers, as it should be much more reliable in compare to I2C MCP antenna :slight_smile: and also much cheaper these days. Few years ago MCP for 2.5$ and now even 20$/each. What a hell?

In my project I am limited to 10pin header interface, and I want to daisy chain as well. So count with me...

First two pins are power of course.

Third I want to use for 74HC595 OE' pin, as kind of hardware watchdog, to make sure outputs does not stay high in any case CPU is not in control...

4th is for 74HC595 Q' pin for daisy chaining

5th is for 74HC165 data daisy chaining pin

Here it comes, I have not 3 pins for each IC control.
Common CLOCK pin should be not an issue as long I will synchronise register read/write,right? :slight_smile:

I suppose it should work, anyone tried?

But I was thinking even 4 should be enough, means common LATCH pin. As long as there is more output registers than input registers.

Thinking about the code is shouldn't have any big disadvantages, or is it?

Any experience sharing is appreciated!
Kind regard Mira

If You make schematics and post it would be easier to know. No PCB can be made from this description.

Confusing story, but the whole idea of shift registers is that you only need three pins for as many 74HC595 chips as you need. I once chained 24 of them.
OE, which also can be common, can be used to disable the outputs during bootup of the Arduino.
Leo..

Evening!

It is not about schematic, its more about source code.

To control 74hc595 I need pins:
DS = data
SHCP = clock
STCP = latch

For 74hc165 I need other 3 pins:
DS = data
CP = clock
PE = latch

But I have only 5 pins available. So one idea is to use common CLOCK pin, means 1 CPU pin connected to both 74hc595 and 74hc165 arrays.
Should work just fine since source code sync reading and writing based on given common clock. Or?:slight_smile:

Common latch pin was maybe just bad idea.

Hi Mira,

It sounds like you are on the right track in replacing the MCP23017 with shift registers. Shift registers are generally more reliable in noisy environments and have lower cost. As for the number of control pins needed, you can definitely use the 74HC595's OE' pin as a hardware watchdog to ensure that outputs are not held high when the CPU is not in control.

Regarding daisy chaining, you can use the Q' pin of the 74HC595 for daisy chaining output registers and the data daisy chaining pin of the 74HC165 for input registers. You only need one CLOCK pin for all shift registers, as long as you synchronize the register read and write operations correctly.

As for using a common LATCH pin, it's possible if you have more output registers than input registers. However, if you have more input registers than output registers, you may need separate LATCH pins for each input register to prevent any data loss.

In terms of code, using shift registers shouldn't have any big disadvantages. You can use standard libraries such as the Arduino shiftOut() function or create your own functions to handle the data transfer.

Overall, using shift registers as a replacement for the MCP23017 should be a good choice. Just make sure to properly synchronize your register read and write operations and use separate LATCH pins for input registers if needed. Good luck with your project!

i have limited replies if you have further issue you can grab my GitHub from profile feel to contact

1 Like

Wow, thanks a lot mate! Much appreciated :+1:
Great to know my theoretical assumption was correct :slight_smile:
Also glad to hear interference resistance should be better when I2C woun't be in the game!

once more thank you!

You're welcome! I'm glad I could help. Don't hesitate to ask if you have any more questions or if there's anything else I can assist you with. Good luck with your project!

Iā€™m glad you have that sorted.
Power and ground noise are about half the problems others will have.

Hello,

For power lines I plan decoupling ceramic cap 100pF for every IC and 1uF for power lines entrance on the PCB.
No more measures on power lines.
I hope it will be OK, or would you recommend some other measure?

@hiibrarahmad Please explain why

1 Like

I would use opto isolators on inputs ( wired without a common ground) or spare relay contacts .
Probably the same for outputs .

Keep all the i/o wiring away from the internal circuits .

Make that 100n.
Leo..

@hiibrarahmad Can you explain why and more reliable than what?

1 Like

In comparison to MCP23017 I2C version based on my original post. More reliable because MCPs are like EMI antenna and also I2C bus is well known as not very interference resistant, because it is designed for internal communication within one PCB.

You are right, thanks for correction.

Yes, I use optocouplers for inputs, ground disconnected. for output is used ULN2803 and ground is connected. I use ULN because it is switching relay coils and IC has internal flyback diode.

Do you think common ground for ULN2803 might be the issue why MCPs failing?

Logic voltage is 3.3V and optos and ULN work with 24VDC

That does not explain why "shift registers are more reliable in a noisy environment"
If you are having EMI problems with I2C you will also have noise problems with HC logic devices

1 Like

I would not say it is I2C bus problem, because other devices on same bus are OK. Just MCPs are failing. So I would say l, it is problem of MCPs and interference. This IC would maybe have the same problems in SPI version.

For comparison I use bunch of DS18B20 OneWire sensors, signal cables are quite long and together with AC cables, havent had any issue so far!

I believe Shift Register will be same case.
Anyway main question point was if possible to control input and output shift registers by 5 pins only. So far it seems common CLOCK pin should be just fine.

Could also be the design of the MCP23017 circuit layout. Are you using the prefab plugins, or your own board design? Location of decoupling capacitors can matter. Just a thought.

The problem with the MCP23017 is that it is not compliant with the I2C specification.
The Vih = 0.8Vcc and the spec is 0.7Vcc. The Vil = 0.2Vcc and the spec says 0.3Vcc. That makes it more susceptible to noise.

If you still want to use the I2C bus, there are other I2C expander ICs available that meet the specs, like the PCF8575.

An I2C compliant device will actually be less susceptible to EMI than an HC logic device.

1 Like