More than 128 GPIO's needed


8 posts
by Arakis » Thu Nov 01, 2012 1:10 am
Hello,
i'm planning to create a chess computer with RPI. A chess board has 8x8 = 64 fields, each field has a LED and one reed contact, so 128 GPIO's are needed. But some other GPIO's are needed for LEDs like "chess", "your turn", and other user input/output.

The 64 LEDs are "output", 64 reed contacts are "input".

The question is, how can this be done? It's very important, that the electonic components in sum are not too, expensive, because i want to create multiple chess boards.

Maybe, i can use 4-5 PIC's, but not sure, if this is a good way.

Greetings,
Sebastian
Posts: 5
Joined: Thu Nov 01, 2012 12:29 am
by mahjongg » Thu Nov 01, 2012 1:18 am
Simple shift registers.
User avatar
Forum Moderator
Forum Moderator
Posts: 5278
Joined: Sun Mar 11, 2012 12:19 am
by rickseiden » Thu Nov 01, 2012 9:12 am
You can control 90 leds with 10 pins using charlieplexing, or you can get several shift registers with output enabled (such as this), hook them up in series, and run a large number of leds off them.

Here's my writeup on shift registers (not the one linked above): http://www.instructables.com/id/Using-a-shift-register-with-Raspberry-Pi/

Here's my writeup on charlieplexing: http://www.instructables.com/id/Charlieplexing-with-the-Raspberry-Pi/
There are 10 types of people in this world. Those that understand binary, and those that don't.
Posts: 398
Joined: Thu Aug 02, 2012 12:21 pm
Location: Buffalo, NY, USA
by Arakis » Thu Nov 01, 2012 1:07 pm
Hello,
thanks for the tip, the tip with the shift register helped a lot. I was able to create this in "logisim", to simulate this successfully.

But this works only for the output GPIO (the 64 LEDs). How can i listen for 64 input GPIOs (the 64 magnetic contacts)?

Greetings,
Sebastian
Posts: 5
Joined: Thu Nov 01, 2012 12:29 am
by techpaul » Thu Nov 01, 2012 2:03 pm
Arakis wrote:Hello,
thanks for the tip, the tip with the shift register helped a lot. I was able to create this in "logisim", to simulate this successfully.

But this works only for the output GPIO (the 64 LEDs). How can i listen for 64 input GPIOs (the 64 magnetic contacts)?

Greetings,
Sebastian

Use lots of 16bit I2C GPIO expanders eg NXP PCF8575 or the MCP2017
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
Posts: 1509
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
by Arakis » Thu Nov 01, 2012 2:55 pm
Thanks for the tip! I found out, i can simple use shift registers for reading, too.

I created a plan in Logisim, and all works fine. The "stupid" question i have now, is, where is the energy?!

chess.png
chess.png (6.5 KiB) Viewed 1048 times


For example, in my attached screenshot, in the above shift regsiter, the 4'th bit is set, the 4'th LED is on. But "LED input", "Write" and "Cycle" is "0", so how it is possible that the LED is on. And of course, there's only one wire, so it should not work.

Greetings,
Sebastian
Posts: 5
Joined: Thu Nov 01, 2012 12:29 am
by techpaul » Thu Nov 01, 2012 3:03 pm
Arakis wrote:Thanks for the tip! I found out, i can simple use shift registers for reading, too.

Yes but you will need to LATCH the values before shifting and latch again the next time you want read what the inputs are doing. Otherwise you WILL get weird results.
I created a plan in Logisim, and all works fine. The "stupid" question i have now, is, where is the energy?!
...
For example, in my attached screenshot, in the above shift regsiter, the 4'th bit is set, the 4'th LED is on. But "LED input", "Write" and "Cycle" is "0", so how it is possible that the LED is on. And of course, there's only one wire, so it should not work.

That is how that piece of software works not how electronics work
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
Posts: 1509
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
by Burngate » Thu Nov 01, 2012 5:20 pm
I'm not sure I've fully understood your question but ...

The energy to drive the LEDs comes from the power supply, feeding into the shift register (the pin you haven't marked), through its output and down to ground. The output of the shift register acts as a short circuit to the positive rail for a 1 or a short to ground for a 0

For a full diagram, you need to draw in the power rails (+ & gnd) for the registers and the grounds for the LEDs and the Pi
Wyszkowski's Second Law: Anything can be made to work if you fiddle with it long enough.
Brain surgery is easier than psychoanalysis
User avatar
Posts: 2749
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK