using a 4x4 16 btn keypad
samsn4
Posts: 49
I sure someone has messed with them before, question is how do i 'poll' and pin to wait for a high? the keypad that i have is a Greyhill with 8 pins, one pin per row/colum.
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Daniel Mueth
WSIU-TV Master Control
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Just plug it in and let's see what happens"
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Daniel Mueth
WSIU-TV Master Control
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Just plug it in and let's see what happens"
Comments
What you need is to provide a unary code (or it's inverse) to the row or column pins of the switch, and read the state of the remaining column or row. If any switch is closed, then a unary code will be read. Then the row and column values need to be converted from unary to binary and combined with one set shifted 2 positions to left for ms and ls half nibbles.
I have used this on a 4 x 7 set of switches, where the 7 lines are driven also to LED segments. The cathodes of six LEDs are controlled by FETs driven by another port (this was a -871 PIC, but matters none).
For debouncing I used several LED scan periods for a total of 20 ms (10 * 2 ms LED on time) of switch closed or open. If the code read is steady for the 20 ms, it is considered valid. Takes a bit of code, but is fast compared to human push/release times.
If you are interested I could supply the PIC code for this operation.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
You'll learn more by understanding how it works and coming up with a strategy than by asking on the board after you've only had it a day.
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
StampPlot - GUI and Plotting Software
Southern Illinois University Carbondale, Electronic Systems Technologies
http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=
1. See these threads about the Propeller and keypad scanning:
http://forums.parallax.com/showthread.php?p=661586
http://forums.parallax.com/showthread.php?p=646590
2. This thread discusses a Propeller object that supports numeric keypads with a PS/2 interface:
http://forums.parallax.com/showthread.php?p=633302
3. This BS2 thread cites a Nuts and Volts magazine column No. 22 that supposedly addresses keypad applications complete with code that might easily be ported to spin. But unfortunately the link to the Nuts & Volts article cited in the post is broken.
http://forums.parallax.com/showthread.php?p=653177
However, I was able to find the Nuts & Volts No. 22 column on the Parallax Web site. Here are the links:
Column Text:
www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol1/col/nv22.pdf
Accompanying Code:
www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol1/code/nv22.zip
4. A hardware keypad decoder solution: E-Lab Digital Engineering Inc. (www.elabinc.com) offers the EDE1144 hardware keypad decoder chip that sells for $7 USD in an 18 pin PDIP RoHS compliant package (www.jameco.com P/N 171970). I belive the EDE1144 chip is a pre-programmed PIC processor. See the E-Lab site (link above) for more info.
When & if you come up with a solution, please share it with us.
Good Luck, David
Attached is a small schematic of a keypad decoder I found somewhere. It uses an analog approach via an A/D converter. You can decode a keypad with only two pins via a delta-sigma A/D. I don't have any code to go with this; I've never implemented it.
David
I will be shure to post my code for all. I'm calling it the Prop Car.
Thanks Again
edit: added pic of car
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Daniel Mueth
WSIU-TV Master Control
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Just plug it in and let's see what happens"
Post Edited (samsn4) : 11/16/2007 11:46:53 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Daniel Mueth
WSIU-TV Master Control
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Just plug it in and let's see what happens"
The keypress routine returns the scan code of the first key closure seen.
The getkey routine calls keypress about every 10ms and returns the
scan code if the keypress is the same for at least two consecutive calls.
As Martin H said you need to develop a strategy.. flowchart.
Pencil down a flowchart as to what is required.
Once you done stuff like that for years these things Graphically appear in your mind
If you have a 16 WAY keypad the simplest all digital way is to use 4 outputs
and 4 inputs...
There are many way's to scan a Keypad.
A very common strategy is or could be ..
1·· >> detect a keypress ( do not care which one)
···· This would involve setting all·the ROW pins·high and detecting a HIGH on· any the COLUMN pins
2 If you have a 1 on any of the COLUMN pins turn off all·ROW PINS
·· and now turn on each·ROW pin by itself...
3· keep track of which ROW pin is high and detect which COLUMN pin is high.
Some simple math and a lookup table and your away.
cheers
Ron Melbourne OZ
VAR
· long· number
PUB KeyPadRead | index
· dira[noparse][[/noparse]16..19]~~
· dira[noparse][[/noparse]20..23]~
·
·
·
·
·····
···· repeat index from 16 to 19
····· outa[noparse][[/noparse]16..19]~
····· outa[noparse][[/noparse]index]~~
······ if ina[noparse][[/noparse]20] == 1
········ number := 10 + index
······ if ina[noparse][[/noparse]21] == 1
········ number := 30 + index
······ if ina[noparse][[/noparse]22] == 1
······· number := 50 + index
······ if ina[noparse][[/noparse]23] == 1
······· number := 70 + index
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank's Brian
www.truckwiz.com
·"Imagination is more important than knowledge..." ·· Albert Einstein
http://www.diycalculator.com/subroutines.shtml· My favorite website ( Bet you can't guess why)
Post Edited (Brian Beckius) : 11/19/2007 6:31:44 AM GMT
4X4 Keypad scan demo, key scan codes appear on a debug LCD.
This code is written top-down to illustrate the keypad scan process.
There is an option to output key-clicks or beeps to a pin; tested with a Piezo speaker.
There is also an option to set the key-press delay/repeat rate.
Comments include a schematic diagram of the keypad and interface.
Regards,
David
Post Edited (Drone) : 11/21/2007 2:08:17 PM GMT
(Once I wanted to do an electronic tachometer and speedometer for my Renault 12 , be careful with the bright of LEDs, under daylight they are dim, but at night they can be quite bright, so a dimming is a sure bet. I love these things !