Issue with 4x4 input matrix?
thTechie
Posts: 7
Hi everybody!
Recently I got a couple of the 4x4 input matrices from the store (http://www.parallax.com/Store/Accessories/HumanInterfaceDevices/tabid/822/CategoryID/90/List/0/SortField/0/Level/a/ProductID/739/Default.aspx). I got them, hooked em up to the prop just as it says in the prop object that's given on that page. I was quite disappointed to find that only some of the buttons actually work right. I thought that it might just be a bad one, so I tried the second one I got, same results. So I thought it might be a bad pin or something on the prop (although all of the pins work depending upon the combo), so I tried it with a different prop, same results. So I tried different pins (because each of the buttons actually responds, but some don't go on and off like they should [they just keep alternating states], and others make it look like more than one button is being pushed at a time), same results. I even tried ditching the matrix and just connecting a wire and the rapid switching of states was gone, but oddly the multiple button pushes issue was still there, on both different props and different pins. This made me think it was possibly the code, but it's pretty easy code with not too much too it, so I really have no idea what's happening. Anybody out there have any suggestions on other things to try or is there some like magic way to get these to work or does anyone have their own experiences with these?
TL;DR: Can't get them to work, no matter what I do, they're hooked up exactly as the object for them says to hook them up and I've changed pins, and props with no luck. Suggestions?
Thanks a lot for anyone that can shed some light on this very frustrating situation!
Kenny
Recently I got a couple of the 4x4 input matrices from the store (http://www.parallax.com/Store/Accessories/HumanInterfaceDevices/tabid/822/CategoryID/90/List/0/SortField/0/Level/a/ProductID/739/Default.aspx). I got them, hooked em up to the prop just as it says in the prop object that's given on that page. I was quite disappointed to find that only some of the buttons actually work right. I thought that it might just be a bad one, so I tried the second one I got, same results. So I thought it might be a bad pin or something on the prop (although all of the pins work depending upon the combo), so I tried it with a different prop, same results. So I tried different pins (because each of the buttons actually responds, but some don't go on and off like they should [they just keep alternating states], and others make it look like more than one button is being pushed at a time), same results. I even tried ditching the matrix and just connecting a wire and the rapid switching of states was gone, but oddly the multiple button pushes issue was still there, on both different props and different pins. This made me think it was possibly the code, but it's pretty easy code with not too much too it, so I really have no idea what's happening. Anybody out there have any suggestions on other things to try or is there some like magic way to get these to work or does anyone have their own experiences with these?
TL;DR: Can't get them to work, no matter what I do, they're hooked up exactly as the object for them says to hook them up and I've changed pins, and props with no luck. Suggestions?
Thanks a lot for anyone that can shed some light on this very frustrating situation!
Kenny
Comments
There is a possibility that the connector is not hooked up right and you have high resistance in your wiring. It would not hurt to double check that.
I'd try to use a common way to run the keypad by pulling the input-lines low via resistor and drive the row-lines high by propeller pins. The change in the driver is not to much!
If this works the capacity-read-method might be unreliable depending on the type of keypad over the age.
I am presuming you are using pasm (assembler). I have not looked at the code you are referring to. However, I have some experience with similar keypads and found that the capacitance affects the results. So to summarise, after you set the outputs, place a few nops in the code before you readback the inputs. That way you should avoid the problem.
Detecting the keypress requires setting a single row or column to a different value and detecting that value on the column or row (notice the reversal of the names, if you output on the row you read the column and vice versa).
A quick look at the documentation and I do see a possible issue, they don't specify any biasing resistors on the input. I would put some weak pull-ups on the input lines to bias the inputs (without them the inputs are left floating which is generally considered a no-no).
So put a 10kOhm resistor on each input pin and tie it to 3.3V, place a 0 on one of the outputs and read the inputs, if any of the inputs are 0, the corresponding key is currently depressed. Repeat this for each output line (make it 0 while making all other outputs to 1) and you will get a matrix of all the buttons that are pressed during the scan sequence.
If you want to gain a better understanding of the keypad you can use a multimeter in continuity mode and explore the column-row-key mapping. While holding down a key, the multimeter will beep when you are probing its column and row line.
Welcome to the forum! ... Sorry to hear of your keyboard troubles... If I can ask a few questions, how far is the Keypad from the I/O's on the propeller? ...and are you positive you have pin1 on the keyboard corresponding with the correct I/O's? (It is common to get the order reversed.) How much electrical noise is in your environment?
Since this object works without any external components, it uses the I/O's themselves as capacitors. first the I/O is made an OUTPUT and charges, then the I/O is made an input and read... If a button is pressed, the I/O becomes discharged and is detected.
Multiple button presses are allowed with
the understanding that BOX entries can be confused. An example of a
BOX entry... 1,2,4,5 or 1,4,3,6 or 4,6,*,# etc. where any 3 of the 4
buttons pressed will evaluate the non pressed button as being pressed,
even when they are not. There is no danger of any physical or
electrical damage, that s just the way this sensing method happens to
work.
I needed to write a new code in order to overcome the problem with the cable extention!
I'll keep that in mind NikosG for when I actually decide to move this project off a breadboard.
Thanks again, you guys were great!
Kenny
1 (4,8)
2 (3,8)
3 (2,8)
A (1,8)
4 (4,7)
5 (3,7)
6 (2,7)
B (1,7)
7 (4,6)
8 (3,6)
9 (2,6)
C (1,6)
* (4,5)
0 (3,5)
# (2,5)
D (1,5)
(y,x) = connector pins shorted
when character is pressed
The above does not agree with the documentation "Figure 1: Matrix Keypad Connections" titled "4x4 Matrix Membrane Keypad (#27899)"
Can someone confirm my results? thanks - Dave
With the exception of your Columns being reversed, It does confirm correctly... you have the pin order swapped :-)
i.e. Your Pin 8 is actually Pin 1 ... same for the rest...
8 = 1
7 = 2
6 = 3
5 = 4
4 = 5
3 = 6
2 = 7
1 = 8
Is there a marking that indicates pin number 1, and if so, can you take a photo and double check your pin-out configuration ... I'll compare that to the older keypad and see if there is a discrepancy of either pin #1 and/or the column reversal. ...and see how that looks in the documentation.
Thanks
There was a change to the pin order in the documentation in April of this year....
...This should not have been changed, it was correct the first time. I think the figure in the referenced BASIC Stamp code was incorrect because it was in reference to an older keypad that we used, and that reference should have been updated instead.
Reference thread:
http://forums.parallax.com/showthread.php?131054-Keypad-Documentation-Error&highlight=27899
From what I can determine, initially (when the code was written) we used a different 4x4 keypad. Since then we have sourced a different 4x4 keypad that has a slightly different pin-out. The 'Quick-Fix' to keep compatibility was to swap the pin order AND swap the column order. It appears that the additional column swap was not observed, but that is the difference between the 'old' keypad, and the 'current' keypad that we are using. If you look on the back of the current 4x4 keypad, there is a small indicator denoting pin number 1.
Determine which Keypad you have:
Old Keypad: pins 1 and 8 are shorted with a button press of "A"
New Keypad: pins 1 and 8 are shorted with a button press of "1"
Old keypad pinout reference:
http://embrace.grayhill.com/embrace/IMAGES/PDF/D-06-09.pdf
I also had trouble with a matrix keypad. The wires I used to connect the keypad to the Prop interfered with Beau's driver. I added 0.1 caps to the columns (or it may have been the rows) and it worked great. I suggested this same fix to another forum member and it fix their problem as well. I think it's worth a try in your case.
This method might even work for Niko's long wires?
Here is the the modified "KeypadDemo1" code for the cable extension that Iused (post#8).
As you can see I have replaced the original values of KV[16] array with other values. However I don't know if these values work properly with all the other cables extensions with different length.