Wednesday 19 March 2014

Why use MCP23008 / MCP23016 / MCP23017 expanders . Part 1 / 2


The first thing which I test for on any new embedded micro is a usable I2C bus aka TWI , two wire .

I2C comes into its own with the use of I/O Expanders, which can give you up to 128 extra I/O pins per bus and only need 3 or 4 wires from the controller.

An added advantage of this is that the controller is isolated from the expander, so with only a simple logic level converter on SDA and SCL rails , the voltage on the expander can be different to the controller , 5 volt logic on the expanders on a controller which is only 3.3 volt tolerant, plus if anything goes wrong you will most likely blow up a cheap easy to replace chip instead of a forever dead pin on your embedded micro.   

If my last part was why, then I guess this part should be named HOW.

Firstly I would like to hope that you know all the basics of I2C,  like needing pull up resistors and that if possible only one resistor should be fitted with a value of between 1k and 10k, I've found that normally a value of 2.2k or 4.7k works best for me.
You should check if pull up resistor are installed on the board by default which some are like the Arduino due , Raspberry pi and the udoo board , but all of my other platforms do not , Arduino mega , Arduino duemilanove , flyport , MBED Arc Pro.

WIRING the chip



The thing you should do when trying to interface any chip is to know the pin out by downloading any maker documentation.

The MCP2308 and MCP23017 are very easy to wire , where the MCP23016 is just a little bit more complex due to need of extra components.
The first thing which confused me on the diagram was the term VSS and VDD, which I found that VSS is what you normally call Ground / the negative supply and VDD the positive supply , at this case 3.3 or 5 volts. ( VCC normally ) 
Don`t forget if the chip is 5 volt powered and your controller is not 5 volt tolerant both the SDA and SCL need to pass through a logic level converter.
The other thing you need to know are the address and reset pins.
Firstly the reset pin, which should be connected to the positive supply , but the chip can be reset by a connecting to ground. 


Addressing and software I will tak about in the next part

Learning Fritzing so the next part with be delayed



Please feel free to leave me a comment, so I know I'm not alone. 

7 comments:

  1. Hello Peter, you are not alone. Even though I am fairly new to all this, I am in a very similar frame of mind (I want to get many I2C devices working in the easiest way); I am trying to get setup with both Udoo Quad & Teensy 3.1, so I have just purchased 'MCP23017 Port Expander' & 'PCF8574 I2C Port Expander'. I have found it quite hard to find information, there does not seem to be many people interested in or willing to share information. When I read your blog post, especially as you are working with an Udoo, I was very happy. It is very encouraging & uplifting to know that there are people trying to achieve the same goals. Getting I2C port expansion working is a very useful goal.

    ReplyDelete
  2. How did you kill the udoo? Or did it just die on its own? I have the quad and Its been terribly slow.

    ReplyDelete
    Replies
    1. KILL , will the usb port stopped working .
      not my fault !!!

      Delete
  3. Was there ever a part 2 to this?

    ReplyDelete
    Replies
    1. Was working all hours , so for a year just didn't have the time.
      Got some free time again , so learning to program again , but using the spark photon now.

      Delete
    2. This comment has been removed by the author.

      Delete