Shop OBEX P1 Docs P2 Docs Learn Events
Easy Propeller I/O Expansion — Parallax Forums

Easy Propeller I/O Expansion

T ChapT Chap Posts: 4,198
edited 2007-03-09 14:16 in Propeller 1
Once in a while people are looking for more I/O, so I wanted to post this very easy solution that works great for many applcations. The device is the PCF8575 I2C 16 bit I/O expander. It can connect to the existing SDA and SCL lines(that are on the boot EEPROM), you can connect 8 IC's total on the bus, so you get 7*16 extra I/O if you are keeping the EEPROM on the bus as well, just give each IC their own address.

Using Mike's minimali2cdriver.spin, the example below shows how easy it is to set the pins to a desired state. Keep in mind the outputs are very low power and will not do any real work except for sinking, so pullups are required to source anything. The schematic shown allows connections for the I/O, plus I added the ULN2803 transistors for sinking larger devices like relays etc. The device can be used as inputs when the start byte includes the direction bit. If in input mode, the chip will output an Interrupt pulse back to the processor on any pin state change. I have used this in a few projects and it is a no-brainer, maybe somebody will get some use out of it.

OBJ
  i2c   :   "minimali2cdriver"

PUB  SetSomePins
    i2cstart(25)     'start the transaction
    i2c.write(25, %0100_000_0 + 0)    '   pin start(25), device type(0100), address(000), write mode(0)
    i2c.write(25, %10000000)    'first byte
    i2c.write(25, %10000000)    'second byte
    i2c.stop(25)




Post Edited (originator) : 3/12/2007 5:15:34 AM GMT

Comments

  • IWriteCodeIWriteCode Posts: 16
    edited 2007-03-09 09:09
    I've been using the PCF8574 a lot, which is the essentially the same, only a 8 bit I/O expander...

    Also, by adding P82B715 buffer chips, you can extend the I2C lines up to 300 meters... which means you can have remote I/O at distant location!
  • JavalinJavalin Posts: 892
    edited 2007-03-09 09:15
    You can also use the MCP23016 i2c IO expander - example of which is in the i2cObject on the Object Exchange

    and the article about them from the excellent Jon Williams - http://www.parallax.com/dl/docs/cols/nv/vol5/col/nv109.pdf

    james
  • KlossKloss Posts: 43
    edited 2007-03-09 12:08
    From the commercial point of view, it does not make much sense
    to use I2C or SPI IO-expanders. For the price of one expander chip,
    you can get a complete microcontroller (with I2C, SPI and ADC).
    Example:
    PCF8574: 1,65
    ATMeaga48: 1,50

    (Prices in Euro, taken from a german catalog distributor)
    Same situation for external ADC's. For the price of an external 10 bit ADC,
    I can buy a microcontroller with 10 bit ADC.
    Not that I'm too cheap to spend 2 dollars for a hobby project, but I'm
    a professional developer and like it to have as much as possible in one
    chip for a good price.
  • IWriteCodeIWriteCode Posts: 16
    edited 2007-03-09 13:38
    The difference is, that an IO expander works without software. If you use a microcontroller for expanding IO, you have to develop software for it... and software = expensive.

    Not to mention the fact, that for a microcontroller, you need more components then just the microcontroller... and you need to arrange methods for inserting the firmware / and updates in case of bugs etc...

    Post Edited (IWriteCode) : 3/9/2007 2:07:32 PM GMT
  • JTCJTC Posts: 60
    edited 2007-03-09 14:16
    · I just looked at Digikey·part #·· 296-13105-2-ND····· $0.85

    for the· PCF8574

    Jim
Sign In or Register to comment.