Connect with us

I2C from scratch

Discussion in 'Microcontrollers, Programming and IoT' started by bigone5500, Mar 11, 2015.

Scroll to continue with content
  1. bigone5500

    bigone5500

    712
    120
    Apr 9, 2014
    I want to build an i2c circuit for my LED matrix. I am having trouble figuring out what chip to use to make this happen. I am hoping that there is an IC that I can solder in place and connect some headers to make it work.

    I have found this chip. I think it is what I need. MCP23008

    http://www.adafruit.com/product/593
     
  2. cjdelphi

    cjdelphi

    1,096
    104
    Oct 26, 2011
    i2c shift register .... sure what's your max current for each LED?
     
  3. bigone5500

    bigone5500

    712
    120
    Apr 9, 2014
    Each led is 20mA.
     
  4. hevans1944

    hevans1944 Hop - AC8NS

    4,495
    2,092
    Jun 21, 2012
    Looks like that device will drive eight LEDs, and you can put eight of them on a shared I2C bus for a total of sixty-four LEDs.

    How big is your LED matrix? Is it necessary that each LED is provided with its own latched driver?
     
  5. bigone5500

    bigone5500

    712
    120
    Apr 9, 2014
    My matrix is just an 8*8. I just want to build a board that will allow me to connect the power, ground, and the I2C wires to make the matrix work. I might just be overthinking this.
     
  6. hevans1944

    hevans1944 Hop - AC8NS

    4,495
    2,092
    Jun 21, 2012
    I don't think you are "overthinking" this.

    I will assume you already have a micro-controller, such as an Arduino Uno R3, that will support the I2S serial protocol in hardware, with appropriate software to serialize the data representing a row (or column, depending on wiring) of eight LEDs. Your software will need to provide eight addresses in the serial data header to select one of eight MCP23008 devices, one for each row (or column) of eight LEDs. The MCP23008 hard-codes the four most significant address bits as 0100 allowing you to hardwire-select the three least significant bits: A2, A1, and A0. Thus the address range is 0x20 to 0x27 (hexadecimal) for a total of eight devices.

    I would recommend, when laying out the PCB, that the address bits for each MCP23008 be committed to "0" (GND) or "1" (Vcc) by means of PCB traces. This avoids the problem of mounting eight 3-bit slide switches near the address pins on the PCB to select the address of each device. This address will never change and slide switches are notoriously unreliable IMO.

    You should either commit an inverter with a grounded input to provide logic "1" level to those address pins that require logic "1", or use individual pull-up resistors from the address pins to Vcc to avoid noise problems on the address lines. Your call whether to use pull-ups or the output of an inverter. If you run parallel traces of GND and Vcc near the address pins, you have the choice of whether to install a pull-up resistor to Vcc or a jumper to GND for each address bit at each device.

    Any way you look at it, you need 64 latched outputs to drive your 8x8 LED matrix. Even if you decided to use eight 8-bit latches on your PCB, you would still need three more bits to individually address each of these 8-bit latches, and some logic to decode the 3-bit address associated with each latch. So you would end up using eleven digital I/O pins on the micro-controller, eight for data and three to address eight latches. Meh! This could have some advantage when writing the software to address each LED, but not much. Software already exists for converting byte data to I2S serial data, so why not use it? Eight MCP23008 devices offers an elegant solution using just two wires and some software, plus a considerable savings in PCB real estate and component count.

    IMO you have made an excellent choice for your application. Please post some pictures (and perhaps some source code) when you get it working!
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-