|
|
View previous topic :: View next topic |
Author |
Message |
kd5uzz
Joined: 28 May 2006 Posts: 56
|
Keypad design and the behavior of output_float() |
Posted: Sun Aug 08, 2010 4:54 pm |
|
|
Hello everyone.
I'm designing a PCB that will incorporate a 4x4 keypad. I would like to be able to detect and decode multiple key-presses.
In an effort to save space on the board I would like to use the minimum number of components. Each input will need a pull-up or pull-down resistor (depends on the rest of the keypad design).
I see some designs that use resistors on the ROW lines to limit the current sourced by the PIC on those lines. I also see some designs that use diodes, the stated reason is to allow the decoding of multiple key-presses.
The code below uses output_high and output_low. My question is:
Can I instead use output_float on the ROWs I'm not checking, and use output_low on the 'active' row, allowing the pull-ups to pull the 'FLOAT' pins high? Why wouldn't this detect (and decode) multiple key presses (without the use of diodes)?
I feel like I'm missing something.
For the record I intend on using the RTOS to run a task similar to the code below every 100ms or so - any thoughts as to if that is too often/not often enough?
Example:
Assume a 4x4 keypad, user is holding (A,1), (B,1) and (B,2).
Code: | {
output_high(ROW_A);
output_low(ROW_B);
output_low(ROW_C);
output_low(ROW_D);
if (input(COL_1))
//key A,1
if (input(COL_2))
//key A,2
if (input(COL_3))
//key A,3
if (input(COL_4))
//key A,4
output_low(ROW_A);
output_high(ROW_B);
output_low(ROW_C);
output_low(ROW_D);
if (input(COL_1))
//key B,1
if (input(COL_2))
//key B,2
if (input(COL_3))
//key B,3
if (input(COL_4))
//key B,4
output_low(ROW_A);
output_low(ROW_B);
output_high(ROW_C);
output_low(ROW_D);
if (input(COL_1))
//key C,1
if (input(COL_2))
//key C,2
if (input(COL_3))
//key C,3
if (input(COL_4))
//key C,4
output_low(ROW_A);
output_low(ROW_B);
output_low(ROW_C);
output_high(ROW_D);
if (input(COL_1))
//key D,1
if (input(COL_2))
//key D,2
if (input(COL_3))
//key D,3
if (input(COL_4))
//key D,4
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Aug 08, 2010 8:30 pm |
|
|
The CCS kbd.c keypad driver floats the row pins, with a pull-up on each
pin. It then sets each column pin low, one at a time, and reads the row
pins to detect a keypress. That's similar to what you want to do, in
terms of scanning the keypad. |
|
|
kd5uzz
Joined: 28 May 2006 Posts: 56
|
|
Posted: Mon Aug 09, 2010 5:51 pm |
|
|
PCM,
Ah, exactly what I was thinking except swap ROWs for COLs, thank you.
Can someone explain what would happen if, using a basic matrix keypad with this code, would happen during multiple key presses? I don't see why I wouldn't be able to detect and decode multiple key presses. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Mon Aug 09, 2010 11:56 pm |
|
|
Quote: | I don't see why I wouldn't be able to detect and decode multiple key presses. |
In a short: Two-key-presses can be decoded without diodes, more than two possibly not. |
|
|
kd5uzz
Joined: 28 May 2006 Posts: 56
|
|
Posted: Wed Aug 11, 2010 11:32 am |
|
|
Thanks everyone. The links were very useful. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|