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.
This part is currently available as a free sample from TI.com. They shipped mine via FedEx today (Monday), should be here by Friday.

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?

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.

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.

 

I bought one and now have read the pdf 287 times... I can not figure out the commands!! I don't think I need to run any commands through it (servo,puls) just simple in's and outs so this should be simple!! -Anyone tried any picaxe basic with this? -I need the smallest of snippits of code.

The PCF8574 appears to need to be configured to an address, by tying the pins A2, A1, and A0 either high or low according to what you want. The PCF8574A starts at address 0111xxx0 where xxx depends on what you wire A2,A1,A0 as. The PCF8574 starts at address 0100xxx0, shown on page 8 Figure 9. What I read on the PICAxe I2C tutorial page 4  is some commands you are probably already familiar with, working with the I2C EPROM before. It looks like the writei2c command can be used, as in :

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

writei2c 0, (00000001,00000010,00000100,00001000,00010000,00100000,01000000,10000000,11111111)

I'd guess that code to run each of the IO pins individually on and off at a rate near 12 kHz, to lastly leave them all on til something else was sent. You could have a meter check the last, or have a slow loop that turned on each pin in turn for a second or so, before going on to address the next. The data sent might need a % in from as in %00001000 as that may be what the PICAxe uses.The readi2c could be used if you wanted to read what the pins are set from some external sensors or switches.

This is handy and so inexpensive. Potentially a solution for something I am working through now. Thanks!

Any thoughts about using this with servos? Can a pulsed signal be sent using the write command? --is it too much to ask for some code (for a picaxe)?

--Actually, I am curious about "sending" or "receiving" any of the picaxe codes. I.e. serout/in pulsin etc...

Wow, and this chip is only $1.58 from what I'm seeing online. Nice, I'll have to pick some up. Although, looking at the two options they list (PCF8574N and PCF8574AN) I can't tell what the difference is. I'm comparing the datasheets for each, and they're not identical but I don't see functionally how they differ. Any experience with that? Would both versions work equally well for this type of use, or is there one in particular we should choose?

Dan

I know one difference is the fixed part of the I2C address and that really tricked me in the beginning since I had bought the other version than the one used in the tutorial I was reading :-). Other than that I don't know of any differences.

The price I listed is from the Danish shop where I normally do my online shopping. I totally forgot to check other online stores. Thanks for the info - I'll update the price right away :-).

By the way NXP (the artist... erh... company formerly known as Philips) makes a lot of cool I2C chips. I know I'm interested in the I2C 4 channel analog to digital converter that also has a digital to analog converter onboard.

- Jimmy