Cole1717
Posts: 29
Joined: Mon Mar 16, 2015 10:44 pm

8x8 matrix with 1 MCP23017

Mon Jun 22, 2015 8:57 pm

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.

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 4956
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: 8x8 matrix with 1 MCP23017

Mon Jun 22, 2015 10:17 pm

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.
Still running Raspbian Jessie on some older Pi's (an A, B1, B2, B+, P2B, 3xP0, P0W) but Stretch on my 2xP3A+, P3B+, P3B, B+, A+ and a B2. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

User avatar
DougieLawson
Posts: 35381
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: 8x8 matrix with 1 MCP23017

Mon Jun 22, 2015 11:10 pm

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).
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Cole1717
Posts: 29
Joined: Mon Mar 16, 2015 10:44 pm

Re: 8x8 matrix with 1 MCP23017

Wed Jun 24, 2015 8:12 pm

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.

User avatar
DougieLawson
Posts: 35381
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: 8x8 matrix with 1 MCP23017

Wed Jun 24, 2015 10:01 pm

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.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: 8x8 matrix with 1 MCP23017

Sat Jun 27, 2015 5:38 am

You can have 8 MCP23S17 chips on each CS pin for a total of 16 chips per Pi. I have done it.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

User avatar
mikronauts
Posts: 2705
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: 8x8 matrix with 1 MCP23017

Sat Jun 27, 2015 2:54 pm

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.
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

Return to “Interfacing (DSI, CSI, I2C, etc.)”