Searching \ for ' Scanning a 4x4 keypad' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=scanning+4x4+keypad
Search entire site for: 'Scanning a 4x4 keypad'.

No exact or substring matches. trying for part
PICList Thread
'[PICLIST] Scanning a 4x4 keypad'
2000\12\02@083013 by Peter Reynolds

flavicon
face
Dear All

You must forgive me if this seems to be a very basic question, but I am
having trouble working out this concept. I know that it is possible to scan
a 4x4 keypad using 4 inputs and 4 outputs of, for example a 16F876. What I
am having trouble with is wheter it is better to use interrupts, or just a
straight scanning regime. Can anyone give me some advice on this, please?

Peter Reynolds -                             For the latest in IT Services
Synstar Business Continuity                  Check out our NEW web site
Technical Consultant                               http://www.synstar.com
020 738 82888 Ext.7994

This communication contains information that is confidential. It is for the
exclusive use of the intended recipient. If you are not the intended
recipient, please note that any distribution, copying, or use of this
communication, or the information in it, is prohibited. If you have received
this communication in error, please notify me by e-mail or by telephone, and
then delete the e-mail and any copies of it.

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2000\12\02@090013 by Quentin

flavicon
face
Peter Reynolds wrote:
>
> Dear All
>
> You must forgive me if this seems to be a very basic question, but I am
> having trouble working out this concept. I know that it is possible to scan
> a 4x4 keypad using 4 inputs and 4 outputs of, for example a 16F876. What I
> am having trouble with is wheter it is better to use interrupts, or just a
> straight scanning regime. Can anyone give me some advice on this, please?
>
>
It sounds to me the problem you have is when to check for key press and
how many times and how to tie the scanning into the rest of the program?

Best is not to initially scan the keypad everytime to get keypress. Call
a subroutine where you make all the scan lines high, then read the
inputs to see if any of them is high (or set) This takes up minimum
steps. If any is, then you start scanning to see which key it is. If not
return to rest of program.

Or as you say, use the interupt of portB and then run key scanning in
the interupt routine. Just leave all your scan lines high (or set)
though.

The choice is yours depending if you want to interupt your program and
at what level. First example gives you more control but the second is
more automatic.

Quentin

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2000\12\02@100330 by Byron A Jeff

face picon face
>
> Dear All
>
> You must forgive me if this seems to be a very basic question, but I am
> having trouble working out this concept. I know that it is possible to scan
> a 4x4 keypad using 4 inputs and 4 outputs of, for example a 16F876. What I
> am having trouble with is wheter it is better to use interrupts, or just a
> straight scanning regime. Can anyone give me some advice on this, please?

Better is so subjective. Much better to be concerned with good enough.
Good enough is when the application performs the task required.

The basic question here is what else needs to be done other than the
keyboard. If the rest of the application is driven by the keyboard input
then it's perfectly acceptable to sit and wait for keyboard presses in a loop
then respond to them. However if there's other stuff going on then an interrupt
based system allows for those other activities to occur while waitint for
keyboard input.

Keyboards are very slow devices. Even a 50ms timer interrupt is sufficient
for monitoring a keyboard.

Hope this helps,

BAJ

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu


2000\12\03@124813 by Harold Hallikainen

picon face
On Sat, 2 Dec 2000 15:58:10 +0200 Quentin <.....qscKILLspamspam.....ICON.CO.ZA> writes:
>
> Best is not to initially scan the keypad everytime to get keypress.
> Call
> a subroutine where you make all the scan lines high, then read the
> inputs to see if any of them is high (or set) This takes up minimum
> steps. If any is, then you start scanning to see which key it is. If
> not
> return to rest of program.
>
>

       I like polling in an interrupt (a timer interrupt). That way you get
pretty uniform response time. I agree that you should first poll to see
if ANY key is down. My normal practice is to do as above, but reverse.
Since inputs float, you have to either pull them up or down with a
resistor (or the weak pull-up on port B). I tend to use pull-ups (often
those on port-B). So, set all the output lines driving the keyboard low,
then look for a low on any of the input lines. If there is no low, you
can exit immediately, since no key is down. If there is a low, you can
determine which row or column (depending on how you've connected the
keyboard) based on which line is low. Then drive each output low
sequentially to find which column or row (again, depending on wiring) is
pressed.
       If each scan yields the same scan code, decrement a debounce counter.
When the debounce counter hits zero, flag that you've got a key.

Harold



FCC Rules Online at http://www.hallikainen.com/FccRules/

________________________________________________________________
GET INTERNET ACCESS FROM JUNO!
Juno offers FREE or PREMIUM Internet access for less!
Join Juno today!  For your FREE software, visit:
dl.http://www.juno.com/get/tagj.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2000\12\04@025118 by Roman Black

flavicon
face
Harold Hallikainen wrote:

>         If each scan yields the same scan code, decrement a debounce counter.
> When the debounce counter hits zero, flag that you've got a key.


Thanks! That's very clever. I have always done it by checking
for valid keypress and then using a timed debounce delay. Using
a decremented counter for scan combination on every scan
is a great idea and something I never would have thought of. :o)
-Roman

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\12\04@033555 by o-8859-1?Q?K=FCbek_Tony?=

flavicon
face
Well here we go again,
>Harold Hallikainen wrote:
>
>>         If each scan yields the same scan code, decrement a debounce
counter.
>> When the debounce counter hits zero, flag that you've got a key.
>
>Roman Black replyed:
>Thanks! That's very clever. I have always done it by checking
>for valid keypress and then using a timed debounce delay. Using
>a decremented counter for scan combination on every scan
>is a great idea and something I never would have thought of. :o)
>-Roman

Well Scott's 'vertical counters' is a very nice piece of
s/w for this kind of thing :)
Look at his site or in the piclist site ( for example
on pic->i/o->keyboard )

/Tony


Tony Kübek, Flintab AB            
²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²
E-mail: EraseMEtony.kubekspam_OUTspamTakeThisOuTflintab.com
²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\12\04@034001 by William

flavicon
face
K|bek Tony wrote:

> Well here we go again,
> >Harold Hallikainen wrote:
> >
> >>         If each scan yields the same scan code, decrement a debounce
> counter.
> >> When the debounce counter hits zero, flag that you've got a key.
> >
> >Roman Black replyed:
> >Thanks! That's very clever. I have always done it by checking
> >for valid keypress and then using a timed debounce delay. Using
> >a decremented counter for scan combination on every scan
> >is a great idea and something I never would have thought of. :o)
> >-Roman
>
> Well Scott's 'vertical counters' is a very nice piece of
> s/w for this kind of thing :)
> Look at his site or in the piclist site ( for example
> on pic->i/o->keyboard )
>

   Where is the link for this site???

   Thanks!



{Quote hidden}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\12\04@044159 by o-8859-1?Q?K=FCbek_Tony?=

flavicon
face
Hi,

I wrote:
>> Well Scott's 'vertical counters' is a very nice piece of
>> s/w for this kind of thing :)
>> Look at his site or in the piclist site ( for example
>> on pic->i/o->keyboard )
>>

William replyed:

>    Where is the link for this site???
>
>    Thanks!

Ok, thought it was general knowledge :) but here goes:

Here's Scott's original code: ( look at pic_debounce )
http://www.dattalo.com/technical/software/software.html

Here an 'real-world' implementation of it:
http://www.piclist.com/techref/microchip/picboard.htm

A bit bloated agreed, but fully functional.

The thing is that the benefits of vertical counters are not really
obvious
at first. But once you start using them you really see what
could be done with them. There are easier ( and more ram conservatory )
implementations available but inregards to programflow they are really
hard to beat.
Particulary as there are *NO* delays needed for the debounce. Using the
timer
or the mainloop itself (for the sample delay) one just grab an sample of

the keyinput feed it to the debounce routine check the output. etc etc..

/Tony






Tony Kübek, Flintab AB            
²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²
E-mail: @spam@tony.kubekKILLspamspamflintab.com
²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...