Page 1 of 1

8x8 matrix with 1 MCP23017

Posted: Mon Jun 22, 2015 8:57 pm
by Cole1717
Is it possible to setup an 8x8 matrix using 1 16 IO port expander via I2C? Could you use the left 8 ports for the columns and the right 8 ports for the rows? is I2C fast enough to update 64 LEDs reliably?

Thanks.

Re: 8x8 matrix with 1 MCP23017

Posted: Mon Jun 22, 2015 10:17 pm
by FTrevorGowen
Cole1717 wrote:Is it possible to setup an 8x8 matrix using 1 16 IO port expander via I2C? Could you use the left 8 ports for the columns and the right 8 ports for the rows? is I2C fast enough to update 64 LEDs reliably?
Thanks.
FWIW, some time ago I attempted something similar with 2 x MCP23008's (equivalent to 1 x MCP23017):
http://www.cpmspectrepi.webspace.virgin ... blePi.html
(Never quite got around to posting "working photo's though :( )
There are SPI versions of both chips if I2C proved "too slow". Also there's a SPI LED display driver I.C. that includes "hardware multiplexing" which makes "life much easier"!:
http://www.cpmspectrepi.webspace.virgin ... odule.html
(and, for it's more conventional use as an 8-digit display driver:
http://www.cpmspectrepi.webspace.virgin ... odule.html )
Trev.

Re: 8x8 matrix with 1 MCP23017

Posted: Mon Jun 22, 2015 11:10 pm
by DougieLawson
Cole1717 wrote:Is it possible to setup an 8x8 matrix using 1 16 IO port expander via I2C? Could you use the left 8 ports for the columns and the right 8 ports for the rows? is I2C fast enough to update 64 LEDs reliably?

Thanks.
It works really well with my £12 MCP23017 based matrix board.
http://www.modmypi.com/raspberry-pi/bre ... -board-kit

Code to drive that is here: https://github.com/DougieLawson/Raspber ... ter/matrix

Demo here: https://www.youtube.com/watch?v=trkmI00aYhg (that was filmed about two hours after I built the board running it with a beta version of the software).

Re: 8x8 matrix with 1 MCP23017

Posted: Wed Jun 24, 2015 8:12 pm
by Cole1717
Very cool. I plan on buying one of the Adafruit RGB LED matrices because they look awesome. I am more curious of the limitations of I2C and its possible applications.

Is it correct to say that SPI is great for when you have one or two "slaves", but I2C excels at having more because of the way it communicates with several other devices?

Thanks for your responses.

Re: 8x8 matrix with 1 MCP23017

Posted: Wed Jun 24, 2015 10:01 pm
by DougieLawson
With I2C you can have up to eight MCP23017s before you need a bus extender.

With SPI it's usually one device per CS (chip select) pin. SPI has an advantage that it runs faster.

Re: 8x8 matrix with 1 MCP23017

Posted: Sat Jun 27, 2015 5:38 am
by Richard-TX
You can have 8 MCP23S17 chips on each CS pin for a total of 16 chips per Pi. I have done it.

Re: 8x8 matrix with 1 MCP23017

Posted: Sat Jun 27, 2015 2:54 pm
by mikronauts
Or add a demultiplexer (like I added for MCP3208's) and you could run 8 * 8 MCP23S17's for a grand total of 1024 I/O's.

http://www.mikronauts.com/raspberry-pi/ ... and-howto/
Richard-TX wrote:You can have 8 MCP23S17 chips on each CS pin for a total of 16 chips per Pi. I have done it.