EXTENDER module i2c PCF 8574


#1

Greetings!
Thank you for XOD!

I ask you to make two program modules:
for
i2c PCF 8574
all use it as an I \ O port extender.
PCF8574
as examle )))

1st (first) module
so that the 8-bit input is sent to the address i2c PCF 8574
8 in(dots)

2nd (second) module to return 8 bits when reading from i2c PCF 8574
8 out (dots)

note for PCF 8574 inverted HI \ LOW sines and for the relay it is better to take this into account immediately

images:


analog
https://voltiq.ru/wp-content/uploads/pcf8574-io-expansion-board-i2c-6.jpg

Thank you!


#2

There already exists i2c-send-byte and i2c-request (see i2c-request-bytes-6 & duplicate for i2c-request-bytes-1). The only thing left is to convert your bits to byte for write & byte to bits for read.

To convert bits to byte, you can shift-left (maybe you need shift-right, but I think left) B7, add it to B6, shift the output again & add to B5, etc. until you add B0. Feed the last add to your output byte pin.

To convert byte to bits, feed byte to 8 bitwise-and nodes, each with the 2nd number being just the bit you want (1, 2, 4, 8, 16, 32, 64, 128 for B0 - B7) & feed each bitwise-and to the appropriate output pin.


#3

thanks.
now I’m old and it’s hard for me to move the bits))
you did not meet the example?


#4

Add Library “gweimer/utils” to get bits-to-byte and byte-to-bits nodes. utils-example shows how to use them.


#5

Thank you!!!
fine
i try it