Does the 4X4 matrix keypad need diodes to install an extension cable? (Solved by work-around)
mikeologist
Posts: 337
I'm building my 4X4 matrix keypad to a 5X5. The first step for me is to add an extension cable that lets me wire in the extra two pins needed.
The issue I'm having is that adding a simple extension cable causes the 7 key and the * key to both read as *.
I have installed the resistor and pull-down resistor needed, but I'm wondering if adding some 1N4148 diodes to the keypad inputs would eliminate this issue?
If that's likely to help I can just replace the orange jumpers 0-4 with the diodes, or should I do 5 up and 5 down?
I've attached pictures and the modified files.
**After everyone's help, I just ended up making a keypad that doesn't leak**
**Pictures and code below**
**Thanks everyone, this was a huge help**
The issue I'm having is that adding a simple extension cable causes the 7 key and the * key to both read as *.
I have installed the resistor and pull-down resistor needed, but I'm wondering if adding some 1N4148 diodes to the keypad inputs would eliminate this issue?
If that's likely to help I can just replace the orange jumpers 0-4 with the diodes, or should I do 5 up and 5 down?
I've attached pictures and the modified files.
**After everyone's help, I just ended up making a keypad that doesn't leak**
**Pictures and code below**
**Thanks everyone, this was a huge help**
Comments
http://forums.parallax.com/discussion/152388/resolved-buggy-reads-from-4x4-keypad-to-propeller-using-4x4-keypad-reader-spin
I have them installed, see the picture. That is unless I've done so improperly, which is entirely possible.
I will do so in just a bit and post my results. Thanks a bunch for your help.
Adding a cable adds capacitance, which can mean you need more settling time on any Scan code.
Line 87 shows:
I believe Line 87 should be:
Also, there is a little bit of parallax effect in your picture (no pun intended), so it is hard to trace some wires to the FLiP. The bottom most wire almost looks like it is plugged in to P1 not actually P0, but otherwise, I don't see any wiring issues apart from resistor values.
According to the 4x4 keypad docs, the inline resistors should be 1k which would reduce line capacitance if that is the issue; the pull downs are not listed in the Parallax document, but listed in several forum threads as a fix.
Ken Gracey
However, when I change line 87 from 10 to 9 I lose keys. the bottom row doesn't show up because everything is shifted by one somewhere else in my code.
I'll comb back through and try to find the other mistake that's responsible.
That was in fact a parallax effect and the pins were properly aligned.
I updooted your helpful answers
Sure appreciate it. In fact I built this from the BOE tutorial, but the resistance values pictured were different than what worked.
Thanks to WBA Consulting though, I'm back on track.
I will create a new thread with pictures, diagrams, and code when I complete the upper keys in the next couple days.
With the 10k pulldown and 1k inline I still got the false reading, so I subbed the inline for 10k and it worked great. I have some 2.2k I could put in there instead to get me close to that ratio. I can also bump the pulldown to 15k when my next box-o-junk shows up.
What does that ratio preserve or represent?
Realized my mistake. With the 10k pulldown I had 220 inline. Switching now to your spec of 10k pulldown and 1k inline.
Thank you for explaining that.
The leaky keyboard just bothers me.
The more I thought about using diodes the more I realized I just need to toss the whole keypad and make one that doesn't leak.
So I made a test model and it works flawlessly without any resistors.
What I saw as the source of the leaks was the unrestricted hot bus that was connecting 4 keys. I believe that the polarity switch allows the signal to go down the intended line and any other well grounded neighbors that share the bus.
My solution was to use 1N4148 diodes off of the hot bus to every button.
Works like a charm and I got to test out my wire wrapping skills, been a while.
Attached the modified code.
What do you all think?
Thanks a bunch for your help. I updated the header for easier searching.
Ultimately I need a 45 key keyboard.
In a 2D matrix this will take 14 pins minimum.
With the use of diodes a third dimension can be added.
In 3D it could be 3X3X5, only use 11 pins, and still allow for multitouch.
Then I can turn it into an SPI with a PSoC 42xx.
I'll post the results of both in a new thread.
Using 16 resistors have 64 keys on only one pin.
Using charlieplexing have 72 keys on 9 pins.
Using a 4024 and two 4051s have 64 keys on three pins and can press more than one key at a time.
I prefer using a ps2 keyboard.
I would love to see your schematic with the 4024 and 2x 4051s if at all possible, please.
Charlieplexing takes a lot of clock cycles; that is if I'm reading the code samples properly.
Using SN74AHCT373N Latches for a 2-bit counter to cycle the 4 inputs and a 74147 encoder I could take my 3D array down to 5 pins.
It would take about 100 1N4148 diodes, the two ICs mentioned above, and run 42 keys on just 5 pins with multi-touch; this will use very little code.
Should cost about $9-10.
This same setup would allow for 8 input pins and 4 outs X 4 pages, netting 128 keys on the same 5 pins.
You really made me read and think with this post, thanks.
I would love to use a ps2 keyboard but I need specific keypad and I like to make things :cool:
Diodes: they encode 8x8 rows and columns in binary, but key 000,000 can't be used because it's the same code as no key.
Resistors: 8x8 columns connected to series of 1K, rows connected to series of 10K, key press makes a unique resistance from 11K to 88K, much higher for no key.
Charlieplexing:
http://forums.parallax.com/discussion/download/94687/CharliePlexing.jpg
4024 and 4051s: binary counter drives 8row and 8column multiplexers to connect a pin thru (counted & pressed) key, other two pins reset and increment counter.
PS2 keyboard: often used with propeller and needs 2 pins.
That's very helpful. I get exactly how they're used now, thanks.
We described very similar applications.
Also, I forgot about reserved values so I'd have to revise my total to 126.
3 to 10 is awesome. use two latches to make a 2 bit counter and you can turn those three inputs into a single clock line. Then simplify it further by combining the concepts as a ripple counter with the first unused pin tied to the reset. The CD4020BE would do nicely and give you 14-1=13 scan pins for the price of 1 clock pin.
Then we're pretty much in sync for encoding the other end to 3 pins.
Assuming 10 in reverse, minus reserved values, nets 323 buttons, and I'm guessing around 700 clocks to read and decode with multi-touch.
Now, If I can synergize a bit further: I love the idea of a single clock pin, but I hate the idea of my tiny propeller having to decode the multi-touch. To that end I'm keeping the output of my keypad decoded.
Running with that concept I should maximize my inputs.
For 42 keys I'll make 7 inputs (CD4020BE). 3 outs, and 2 pages for a total of 1+5=6 pins. This config take a single clocked input and produces a 5-bit parallel output. While this may sound less-than-optimized, I estimate that it will only take about 60 clocks to read it with multi-touch.
You've really pushed me to put together something cool. I can't wait to share the results.
I think 74373 works as a shift register when it's latches are connected like a chain. 74573 almost the same but its pins are in nice order of ins on one side, outs on the other. Other chips I can't recall, are serial in parallel out, and parallel in serial out type shift registers, with which any matrix should be scannable with 4 pins or less. That method maybe a simpler alternative to counting and multiplexing.
I still have to read the rest of the comment again and think about it, but you eliminate the extra counts on a 4020 by shorting the next count to the reset pin. Then if you are running n inputs you run n+1 cycles in the software and ignore the last return. That will restart the cycle with only one extra clock.
See what I mean about 4020, maybe use 4040 instead.