Page 1 of 1

Shift Register output (e.g. 74HC595, TPIC6B595)

Posted: 12 Sep 2021, 01:43
by RalfE
Is it possible to implement support for shift registers e.g. 74HC595 or the Power Logic version TPIC6B595 or similar?
Or are there already other possibilities / tricks to connect them to ESP Easy (via rules)?

Re: Shift Register output (e.g. 74HC595, TPIC6B595)

Posted: 12 Sep 2021, 13:57
by Ath
Currently, those shift registers aren't supported in any plugin (AFAICS).
Using a lot of code, it will be possible to manipulate GPIOs in a way that the outputs go as you need, but as the rules do not have 'while' or 'for' support (yet), that is 'somewhat tricky', to say the least :shock:

Re: Shift Register output (e.g. 74HC595, TPIC6B595)

Posted: 12 Sep 2021, 21:46
by TD-er
We do have the msec loop timer and you can keep track of the state in a variable.

Still "somewhat tricky" is a bit of an understatement.

Re: Shift Register output (e.g. 74HC595, TPIC6B595)

Posted: 12 Sep 2021, 22:46
by RalfE
Still "somewhat tricky" is a bit of an understatement.
That's exactly why my question.

There are solutions for everything, but the effort has to match.

ESP32 and output driver are of course also possible ...

Only for the small 8266 would the possibility of being able to use more outputs simply by means of a shift register without much effort, even with the corresponding switching capacity (6B595), enable further applications.

Re: Shift Register output (e.g. 74HC595, TPIC6B595)

Posted: 12 Sep 2021, 23:18
by Ath
Well if the max. nr. of gpio's is an issue, then an I2C port expander, like the MCP23017 (16 gpio's) or PCF8574 (8 gpio's), would be even better, as they only require 2 ESP gpio pins (SDA/SCL), where such shift register would best be controlled using 4 gpio's. And the PCF and MCP are already fully supported by ESPEasy, and multiple of these can be used, as they have easy changable addresses.

Re: Shift Register output (e.g. 74HC595, TPIC6B595)

Posted: 12 Sep 2021, 23:20
by Ath
TD-er wrote: 12 Sep 2021, 21:46 Still "somewhat tricky" is a bit of an understatement.
That's why I quoted it :P

Re: Shift Register output (e.g. 74HC595, TPIC6B595)

Posted: 12 Sep 2021, 23:58
by RalfE
For cheap and simple, the PCF8574 also has disadvantages (initial state, max 20ma, ....).

I would like to switch a slightly larger number of relays and solenoid valves (100mA) with the least possible effort ...

Re: Shift Register output (e.g. 74HC595, TPIC6B595)

Posted: 13 Sep 2021, 08:21
by Ath
RalfE wrote: 12 Sep 2021, 23:58 For cheap and simple, the PCF8574 also has disadvantages (initial state, max 20ma, ....).

I would like to switch a slightly larger number of relays and solenoid valves (100mA) with the least possible effort ...
That are indeed valid arguments, I'll see if I can mock something up, but I only have evenings and weekends available for this hobby, so it may take some time.

Re: Shift Register output (e.g. 74HC595, TPIC6B595)

Posted: 13 Sep 2021, 09:30
by TD-er
RalfE wrote: 12 Sep 2021, 23:58 For cheap and simple, the PCF8574 also has disadvantages (initial state, max 20ma, ....).

I would like to switch a slightly larger number of relays and solenoid valves (100mA) with the least possible effort ...
You may need to check the datasheet, but most of those ICs can "sink" a lot more than they can "source".
What this means is that when it "sinks" a current, it only connects it to GND.
When it needs to "source" it, this means the IC must supply the current for the connected device, so the current for all attached to the outputs must be delivered by the Vcc pin of the IC.

Not sure what you need to switch.
If it is an AC current, you may also want to look at "SSR" or "Solid State Relay".
Then you essentially just turn on an LED on the low voltage side.
N.B. Most SSR's can only switch AC current, not DC, as they switch at the zero crossing.

Re: Shift Register output (e.g. 74HC595, TPIC6B595)

Posted: 13 Sep 2021, 10:20
by RalfE
That is already clear to me, only PCF8574 is not enough for the reasons mentioned above.

I also have different test setups here, ESP32 + ULN driver, ESP8266 + PCF + inverter (because of initial state) + driver (discret and ULN), everything works.
Only ESP8266 + TPIC6B595 (+ I2C_sensor depending on the application) would be the simplest solution, but unfortunately it is not yet supported by ESP Easy.

For my intended application, I like ESP Easy best because of the flexible rules (after testing Tasmota and ESPHome), the only disadvantage is the lack of SPI function ....

Re: Shift Register output (e.g. 74HC595, TPIC6B595)

Posted: 13 Sep 2021, 10:26
by TD-er
RalfE wrote: 13 Sep 2021, 10:20 [...] the only disadvantage is the lack of SPI function ....
What is missing for SPI?

Re: Shift Register output (e.g. 74HC595, TPIC6B595)

Posted: 13 Sep 2021, 11:19
by RalfE
What is missing for SPI?
as written above ... control x595 shift register via SPI ...

Re: Shift Register output (e.g. 74HC595, TPIC6B595)

Posted: 16 Jan 2022, 23:04
by Ath
I have created PR #3917 adding support for 74HC595 (and compatible) chips to ESPEasy. Not using SPI, but the more commonly used serial-shift, as provided via the Simsso/ShiftRegister74HC595 library, that I modified to not use C++ template features, as that adds code for each count of daisy-chained chips.
Currently 'limited to 16 daisy-chained chips, but I will, probably soon, raise that to a higher count (64 or 256, not sure what would be useful).
Also want to add support for sending text to a set of 7-segment displays, similar to P073, but will need to find a diagram how these are usually connected.

Re: Shift Register output (e.g. 74HC595, TPIC6B595)

Posted: 22 Jan 2022, 15:29
by Ath
An couple of updates have been made to the code, so a newer build is available from the Github actions run (should be completed in a couple of minutes after this post).