Trying to get my head around a switching problem and was wondering if anyone could help me (or suggest a direction i can look into) before i resolve it with a more "mechanical" solution.
I have a 22 switch pad (from an old printer) that i am attempting to repurpose. It has a 15pin male header, of which, pins 6 to 13 are used as switch connections.
The picture attached kind of explains the connections, the ones in red all share a common connection (pin 9), as do the yellow (pin 6), blue (pin 7) and green (pin 8 ). This is where I start to get confused!
The basic ones I can get my head around but it is the ones that share common "paths" that have me scratching my head a bit!
For example if pin 9 is +5V then i know when each of the pins (7-13) is +5V the switch is being closed. If i do the same for pin 6 then i know when a switch on red or yellow is closed but not which one it is. If i reverse the polarity then i know which number out is high but not which switch caused that state!
I was planning on using this to connect using shift registers (in both in and out flavours) through an Uno so that each time a button is pressed a hex address is shown on 4 digit seven segment display. Am i going about it the wrong way? Is there a better approach i can look at to learn this? Do i need to use analog to read each switch state and 5 different voltages?
All of this is just another step in learning but I am just not getting it yet!
Thanks for any help or ideas you may have!
Craig
PS. the one that has confused me even more is the "?" switch which is between pin 10 and 11!!!
It has a 15pin male header, of which, pins 6 to 13 are used as switch connections.
the picture shows 6 red buttons and 4 "commons". So a total of 10 pins to be used for the Button Matrix. This does not fit in "Pin 6 to 13".
by the way: i would start with the UNO only, and learn how the matrix is working i.e. if the matrix is working like described.
After you are confident with your matrix, you can add a port expander.
noiasca:
This does not fit to your picture
the picture shows 6 red buttons and 4 "commons". So a total of 10 pins to be used for the Button Matrix. This does not fit in "Pin 6 to 13".
I think i may have explained the picture badly, sorry!
I traced the pins and conections with a multimeter and this picture was the best i could think of to show what i meant! I will need to take a photo or two of the actual board and set-up in order to show what i mean i think as, everytime I try to explain it, it just gets more confusing!
by the way: i would start with the UNO only, and learn how the matrix is working i.e. if the matrix is working like described.
After you are confident with your matrix, you can add a port expander.
Gonna have to go "back to the drawing board" as I think i am just confusing the issue here. My guess is it is such a specialist keypad that it just doesn't work as "logically" as I would hope! Going to take a couple of pictures and see if i can explain myself better!
So, I hope this is a little clearer. In the keypad trace picture you can see that the "common" pins are actually used more than once, which is where i have become very confused.
I may have to just re-use the actual rubber keypad and the housing but remake the circuit board that it is making contact with. that way i can re route the pins and actually seperate the "common" pins properly.
If anyone has any other ideas then i am open to suggestions!
Before I look at these, the puzzle in your original diagram is that pins 7 and 8 are shown as both a "common" and among the red, yellow and blue keys. I thought you may have confused the wiring but actually this appears to somewhat resemble "Charlieplexing".
As such, the flexibility of the port expanders - or admittedly as noiasca suggests, just using an Arduino (I do not find UNOs particularly appropriate, Nanos are more versatile) - will be required, not shift registers. The "Keypad" library will be useless.
Without usable pictures, I cannot discern how many conductors are in that ribbon cable - it seems to use an abbreviated colour set. We cannot see the other side of the board but it appears to have more components than just the buttons so I wonder what else it may do.
That is the whole problem right there, I was wondering if it was something commonly used but i just hadn't come across yet (hence asking here) or if it was something peculiar to this salvaged part that the original manufacturer aproached in an "odd" way, if you see what i mean.
My guess is the answer is....Charlieplexing!
There are a few more components on the other side, they are 5 LEDs and 5 220ohm resistors (sharing a common and therefore 6 pins...), I didn't want to confuse the problem more so i just included the 8 that are connected to the switch, pin 6 through 13. The extra pin seems to be a ground to the machine base via the metal enclosure, i guess to help control stray or static charge from what would have been motors.
OK, it all makes sense now. There are no "commons", it resembles (but is not actually) Charlieplexing; it uses "nCr" coding so the eight wires can code (8C2) up to 28 buttons.
Your code would therefore work by pulling one line (OUTPUT) LOW with all the others set as INPUT_PULLUP and reading all the following lines, then restoring that first line to INPUT, setting the next LOW and reading the following, etc.
So for the first line, you read the following seven, for the next you read the following six and so on. In this case, not all the matrix positions are filled (only 22 out of 28) but to account for that would unnecessarily complicate the code.
Have you figured out the one with the question mark yet?