Teach us! ..about I2C I/O expanders

Discussion in 'General Electronics Chat' started by Captain E, Jul 7, 2015.

  1. Captain E

    Thread Starter Member

    Jun 16, 2015
    81
    6
    Hello fellow humans.

    I'm having a lot of trouble learning about I2C I/O expanders, and I want to ask you kind people if someone would be willing to teach me some?
    (not only for me, also everyone else who wants to learn, of cource)
    I dont know much yet, but I've really tried looking at tutorials on this, but they are few and I get confused at the most stuff because of explaination that's not suiting me.
    I dont want to know how they are made and such, but how I can use it and understand what the things I do, does. Also, I've never learnt how to read a device's documentation, as I think they are too complex :/

    My case if anyone's wondering: I have got a MCP23018 I/O expander (link here), and want to be able to get both more inputs and outputs with it.

    I'm thinking that everyone that knows anything about I/O exporters in general, could write it here, and together we can get some kind of total guide of them. For example, you can write about any part you know well, for example:
    - programming for them
    - making circuits for them
    etc.


    I am very happy for every help I (and others) get!
    If you are one like me and also would want this, tell us here so people know there is a bigger will of this.

    Thank you all in advance for every help you try/succeed to give!
    ~ Captain E
     
  2. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,771
    971
  3. Papabravo

    Expert

    Feb 24, 2006
    10,152
    1,794
    By your own admission the inability to read a device datasheet actually makes any expository prose we might write subject to the same problem. My friends and I who made successful careers in industry became expert at reading them quickly and it has just never been a problem for us. I suggest you go back to the source and work your way to the parts that are confusing and ask articulate and pointed questions. Maybe you just had too many people telling you that you were doing a "good job", when the reality was something else.

    The chip you are talking about seems like a straightforward expander that offers you 16 general purpose I/O points with a convenient two-wire serial interface. What's not to like about it?

    Two questions:
    1. Do you understand how an I/O port works on a PIC Processor?
    2. Do you understand how the I2C protocol is used to read and write registers?
    Without affirmative answers to both questions anything more that I may write about the device at this moment is pointless.
     
    Last edited: Jul 7, 2015
    Captain E and OBW0549 like this.
  4. Captain E

    Thread Starter Member

    Jun 16, 2015
    81
    6
    Ok then I'll try learn read datasheets :/
    Mods may delete if wanted.

    Pardon
     
  5. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,545
    1,252
    I have to agree with Papa. I2C is not a beginner's topic, and the 23018 is a 2nd or 3rd generation part with lots of internal configurations. You might start with an older part like the 9556/57.

    ak
     
    Captain E likes this.
  6. Captain E

    Thread Starter Member

    Jun 16, 2015
    81
    6
    When you're on it,
    is there any good simple technique to get either more inputs/outputs to the Arduino uno? I need a total of about 20-25 of analog inputs.
    I have only found things in I2C :/
     
  7. Papabravo

    Expert

    Feb 24, 2006
    10,152
    1,794
    The simple way in hardware is to use an analog multiplexer in conjunction with one or more onboard A/D converter(s).
    WRT to the I/O expander, it might be helpful to look at I2C from the master point of view which you can find in the more extensive datasheets for the PIC processors that have I2C hardware in them. I was kind of hoping you could elaborate on what is causing you difficulty in understanding the I/O expander. Help us out 'cuz the crystal ball is in the shop for repairs this month.

    For a complete reference you might want to try
    http://www.nxp.com/documents/user_manual/UM10204.pdf

    NXP is the successor to Philips Semiconductor, the company that originally designed the I2C bus.
     
    Captain E likes this.
  8. nigelwright7557

    Senior Member

    May 10, 2008
    487
    71
    I just used to bit bang the PIC I/o ports.
    One pin for clock and the other for data with pull up resistors.
    If you read the data sheet for the device you want to read/write to/from you will see it isn't too difficult.
     
    Captain E likes this.
  9. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,648
    764
    I recall using a memory chip with 16C57 PIC micro, by bit banging. Maybe a year later I learnt it was just I2C in action. Complex yes but not impossible.

    BTW, so many words to say "I do not understand"?
     
  10. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,648
    764
    Could the 74HC595 fit the bill?

    Play with it before trying to actually using it. Make sure you understand how it works. It is simple.

    EDIT to add

    Three of them cascaded will provide 24 outputs. I got them working in minutes.

    I soldered a very compact board with 8 LEDs for checking the outputs visually while applying a very slow clock.

    /EDIT

    EDIT to add

    Make sure you get straight what goes first: MSb or LSB.

    /EDIT
     
    Last edited: Jul 8, 2015
    Captain E likes this.
  11. Captain E

    Thread Starter Member

    Jun 16, 2015
    81
    6
    Thanks a lot guys! :D
    you're the best

    Cap
     
  12. pwdixon

    Member

    Oct 11, 2012
    488
    56
    But the guy wanted lots of analogue inputs and this is a digital output option.
     
  13. pwdixon

    Member

    Oct 11, 2012
    488
    56
    Captain E likes this.
  14. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,648
    764
    Oh sí! Post #6

    I wasted everybody's time. Sorry. Analog and multiplexer. My bad.
     
  15. Captain E

    Thread Starter Member

    Jun 16, 2015
    81
    6
    You can never have to much info :3 Thanks!
     
  16. Papabravo

    Expert

    Feb 24, 2006
    10,152
    1,794
    The reason there are so many registers inside an MCP23018 is that a bidirectional I/O port is a fairly complex animal. There are two identical 8 bit ports within the device so the number of required registers is twice the number required for a single register. Each port has an output latch which stores the output values for each bit, even if that bit is not an output. When you read a port you are sampling the present value on each pin. When you write a port the data goes to the output latch. From there only the bits configured as outputs have their data enabled onto the pins. This is the fundamental thing you need to know about bidirectional digital I/O ports.

    As another aid to understanding look at the default values for each register after a power on/reset and understand the default configuration of the device in tables 1-2 thru 1-5. Once you understand that default configuration you can formulate a plan for changing it to suit your needs.
     
Loading...