I would like to build an organ pedal board and use Raspberry Pi as signal processor.
The pedal board will have 32 inputs, one for each key.
I am planning to use magnetic sensors (like A3144), which, can send true / 1 or false / 0 signals to the Raspberry Pi (correct me if I am wrong, I never used this kind of sensor before).
What I don’t know is how can I have 32 inputs, since the Raspberry Pi board has less than 32 I/O pins.
I have the impression I need another component for that (like a converter… or something), but again, I don’t know what I need to build the electronic part of this project.
How can I connect more inputs to the Raspberry Pi? What would be the best way to build this?
The pedals should work simultaneously as well.
-
set it up as a keypad matrix …… 8×4 will cover the 32 keys …. 6×6 would allow you to read 36 keys …… both of these arrangements would require 12 data pins if no external circuitry was used – jsotola Apr 8 at 15:01
-
Yes, matrix keypad is the standard configuration. In my Arduino days I DIYed 16 key key pad using single keys connected as a matrix. Then I read MagPi about MCP23008 and found MCP’s app notes on how to use MCP23008’s two 4bit ports to make a 16 key key pad. That app notes is very good, and I followed the notes and made a keypad, using polling and interrupt. Of course a simple setup is to use 8 Rpi GPIO keys as a 4 x 4 matrix to handle 16 keys. Perhaps I can give an answer here recommending both methods. – tlfong01yesterday
-
@tlfong01 Can you please post an answer with more details? That would be great. Haven’t started this project yet. – Ionică Bizău 23 hours ago
-
@Ionică Bizău – Yes, I can post a short answer, perhaps over the weekend. BTW, I have a midi keyboard, but I have not idea if the keys are capacitive or else. You might like to read the following about my keyboard and my answer which partly relates to your project – raspberrypi.stackexchange.com/questions/96083/… You might also read the following about mcp23008 based 4 x 4 keyboard design. This design can easily be scaled up using mcp23x17, to 16 x 16 = 256 keys. ww1.microchip.com/downloads/en/AppNotes/01081a.pdf– tlfong01 20 hours ago
The best way depends on factors only you can determine.
I give a couple of ways.
- use two MCP23017, each of which supply 16 digital IO. They use the I2C bus (pins 3/5, GPIO 2/3) and up to 8 can be used on the bus.
- use 4 8-bit input shift registers. They provide 8 digital inputs each. They can use the SPI bus and you can daisy chain as many as you want. If needed you could instead bit bang reading the devices from any GPIO.
The shift registers are probably better for your application. They are likely to be more responsive as you can drive the SPI bus much faster than the I2C bus.
-
Thanks! I will look into that. I forgot to mention that the pedals should work simultaneously as well. Will that do it? – Ionică Bizău Apr 8 at 7:34
-
-
-
So, will 32 A3144 sensors connected to two MCP23017 chips connected to RPi do the job? Will that work? 🙂 – Ionică Bizău Apr 8 at 8:04
-
I believe that will work. I’m just worried about the responsiveness. I would prototype both suggestions unless money is really tight. – joan Apr 8 at 8:11
Question
How to make a Rpi compatible keypad, with more than 32 keys?
Short Answer
- 12 Rpi GPIO pins scanning a 8 x 4 matrix keypad (8 x 4 = 32 keys)
- MCP23x08 x 2 – 16 GPIO pins scanning two 4 x 4 keypads (4 x 4 x 2 = 32 keys)
- MCP23x17 x 2 – scanning 8 x 4 keypad (8 x 4 = 32 keys)
Step 1 – Start with a cheapy (US$1) 4 x 4 push button keypad, program 8 Rpi GPIO pins to scan keypad, using edge and level interrupts.
Now that I have the schematic, I can start coding. But I only know python, and I heard that python is poor in keypad interrupt mode event driven programming, which node.js and javascript are best at.
I know very roughly the keypad scanning algorithm:
1. Connect GPIO 0, 1, 2, 3 to Row 0, 1, 2, 3
2 Connect GPIO 4, 5, 6, 7 to Col 4, 5, 6, 7
3. Set GPIO 0, 1, 2, 3 as Out 0, 1, 2, 3
4. Set GPIO 4, 5, 6, 7 as In 0, 1, 2, 3
5. Loop IN 0, 1, 2, 3 until any IN is low
6. ...
I am a bit tired. I guess I should let Johnny B take over, perhaps show us a node.js program, then a javascript, and I will follow him with python 🙂
Have a nice weekend.
/ to continue, …
Long Answer
/ to add later, …
Appendix A – Research Notes
/ to add later, …
Appendix B – References
MCP23x08/mcp23x17 References
AN1081 Title: Interfacing a 4×4 Matrix Keypad with an 8-Bit GPIO Expander -04/12/2007 Mike Curran
Description:
This application note discusses interfacing a 4x4 matrix keypad
with MCP23X08 8-Bit GPIO Expander.
GPIO Expanders provide easy I/O expansion using standard serial
interfaces such as I2C and SPI. They are especially useful in
applications where pin count is limited on the microcontroller
unit (MCU) or if remote inputs / outputs (I/O's) are needed.
MCP23008/MCP23S08 Data Sheet 03/28/2019 625KB
Errata MCP23008 Rev. A Silicon Errata 11/07/2005 146KB
AN1043 – Unique Features of the MCP23X08/17 GPIO Expanders 06/27/2006 297KB
AN972 Title: I/O Expansion Using the MCP23X08 and PIC10F202 01/31/2005 Pat Richards
MCP23008/MCP23S08 Evaluation Board User’s Guide
Keypad
AliExpress 8pin 4×4 Matrix 16 Keys Button Keypad – US$0.58/pièce
How to ask a question
How to create a Minimal, Complete, and Verifiable example – StackOverflow
How to debug small programs – Eric Lippert’s blog 2014mar05
How to ask technical questions to get quality answers – opensource.com
Categories: Uncategorized



