xreef / PCF8574_library

PCF8574 library. i2c digital expander for Arduino, Raspberry Pi Pico and rp2040 boards, esp32, SMT32 and ESP8266. Can read write digital values with only 2 wire. Very simple to use and encoder support.
Other
216 stars 62 forks source link

PCF8574 output low active, init active #15

Closed barneyz closed 4 years ago

barneyz commented 4 years ago

I use 8 relais modules with active low input, because the PCF8574 has active low outputs. On my init routine

pcf_out1.begin(); for (int i = 0; i < 8; i++) // Init PCF { pcf_out1.pinMode(i, OUTPUT); // 8 Ports init as output pcf_out1.digitalWrite(i, 1); } With this code, all relais switch on at init for 100ms.

So i changed writeMode and writeByteBuffered in the library from private to public and set both to a new init value:

pcf_out1.writeMode = B11111111; pcf_out1.writeByteBuffered = B11111111; pcf_out1.begin(); for (int i = 0; i < 8; i++) // Init PCF { pcf_out1.pinMode(i, OUTPUT); // 8 Ports init as output pcf_out1.digitalWrite(i, 1); } This shortens the output init time to 10ms active time, so the relais are not able to switch.

I do not understand the 10ms, a SSR will switch Is it possible to init the PCF without any active time?

(I use an Wemos Lolin 32(ESP32) and #define PCF8574_LOW_MEMORY)

xreef commented 4 years ago

Hi barneyz, I must do some test, when I find sometime I try to manage It. Thanks Bye Renzo

xreef commented 4 years ago

Hi, sorry to wait so much, i put on new branch a versione that support all

https://github.com/xreef/PCF8574_library/tree/INPUT_PULLPUP_Test

If you want try, now input are start LOW with INPUT, to have a HIGH value at first must be use INPUT_PULL_UP

pcf8574.pinMode(P0, INPUT); pcf8574.pinMode(P1, INPUT_PULLUP);

For OPUTPUT there is a new parameter and you can specify if start in LOW or HIGH

pcf8574.pinMode(P6, OUTPUT, LOW); pcf8574.pinMode(P6, OUTPUT, HIGH);

I think this is risolutive.

Thanks

barneyz commented 4 years ago

Thank you very much, i tested it and it works for me 👍

petr-novak-digibrocz commented 2 months ago

Not working now, any changes?

Thank you