Reading Bits from a PCF8574A I/O Expander
Alan Bradford
Posts: 172
Hi,
It has been a long time since I did logical operations in Basic 101 at college (35 years), and I cant remember how to do this,
I am using some PCF8574A I/O Expanders with a BS2p.
I am using seperate chips for Input and Output.
I have the I2C commands working. I need to access the data.
I have·3 questions:
1) Once I input the Byte of Data, how·can·I·look at the individual bits? I am reading switch closures.
2) How do I turn on Individual Outputs?
3) The data sheets say I can connect 16 devices but they only have 3 addressing bits. How do·I address the second group of 8 Chips?
Thank You,
Alan Bradford
Plasma Technologies
www.plasmatechnologies.com
It has been a long time since I did logical operations in Basic 101 at college (35 years), and I cant remember how to do this,
I am using some PCF8574A I/O Expanders with a BS2p.
I am using seperate chips for Input and Output.
I have the I2C commands working. I need to access the data.
I have·3 questions:
1) Once I input the Byte of Data, how·can·I·look at the individual bits? I am reading switch closures.
2) How do I turn on Individual Outputs?
3) The data sheets say I can connect 16 devices but they only have 3 addressing bits. How do·I address the second group of 8 Chips?
Thank You,
Alan Bradford
Plasma Technologies
www.plasmatechnologies.com
Comments
In Pbasic, you can access bits like this:
If you need to access bits "dynamically" (i.e. as pseudo array) you can do it like this:
See above. If you are dumping the byte(s) to the I/O expander you can set bits as you need, then dump the byte to the peripheral chip.
I just checked the data sheets -- I don't see any mention of using 16 of these devices on a single I2C bus. Where did you read that? In my reading you would only be able to put 8 of these on a single bus given the addressing schema. You could have TWO I2C busses, with 8 on each... or am I missing something here?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Post Edited (Zoot) : 1/18/2009 6:58:46 PM GMT
The PCF8574 and the PCF8574A are the same chips, but each has a different address. So you could use 8 of each on the same bus.
**
That was just what i was looking for.
Thanks for the help.
Alan Bradford