Let's Make Robots!

PCF8574 Remote 8-bit I/O expander for I2C-bus

Vendor's Description: 

If you're ever in need of additional digital inputs or outputs then this chip may be an answer to your prayers. It only requires two connections from your microcontroller (the I2C bus wires) and it provides you with 8 pins that can be configured individually to be input or output.

What's great about this chip is that if you need even more inputs or outputs you can just add another one of these without the need for extra connections to your microcontroller - I2C rocks! The hardware I2C slave address can be configured to any of 8 different addresses meaning you can have a total of 8 of these chips on the same I2C bus.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hey, thanks again for the code -It worked great!... and did need the "%"...

At any rate, I noticed that it doesn't latch. It seems that it sets it's pins high only for a very short time following the write command. If I run a good loop, I can keep a LED on, if there is any pause, I only get a short blink. -- any thoughts?

I was guessing that the latched outputs meant that they stay set as the last data byte sent. It appears that they only stay "latched" for roughly 9 clock pulses at 100 (or 400) kHz from Figure 10 (page 9). I kinda wonder what sending just one byte would do, to see if it would hold it longer, but would really only expect it to hold it for that 9 100kHz clocks, after it had been sent. Something like :

i2cslave %0111xxx0, i2cslow, i2cbyte  ' for PCF8574A at address 0111xxx0

writei2c 0, (%00000001)

What you have done already may be the only answer possible, to get a sustained high or low on any one pin. If you divide up 100 kHz by 9 first, you get 11 kHz, which inverts to 9 microseconds for the time it takes for holding 1 byte. It might be possible to send out servo pulses with 9 usec resolution, which would give 11 different servo positions between 1 and 2 ms. Or if shifting to 400 kHz data rate, there should be a 4x resolution, for 44 or so positions. What I'm picturing is sending a continuous data stream for 2 ms of what you want 8 servos to be positioned at, then resting 20 ms to do other chores, then sending another 2 ms of data. That would be 22 bytes or so at 100 kHz, or 88 bytes sent at 400 kHz.  The first 11 (at 100 kHz) would be all ones to get to the minimum 1 ms for the servo, but the rest could be whatever wanted for an individual servo, up to another 11 ones for the far end of the servo swing. Think that might be right, don't have a way of trying it out.


Hi Chris,

I don't know if you sorted out the latching stuff already since your post is rather old, but I'm currently doing some experiments with implementing an I2C master on the Atmel Tiny26 chip and interfacing to the PCF8574A chip which in turn is controlling a LED, and I found that if I send only the address + write byte followed by one data byte to the PCF8574A, it latches just fine and the LED stays on/off according to the contents of the data byte for as long as the circuit is powered.