CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Keypad design and the behavior of output_float()

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kd5uzz



Joined: 28 May 2006
Posts: 56

View user's profile Send private message

Keypad design and the behavior of output_float()
PostPosted: Sun Aug 08, 2010 4:54 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Aug 08, 2010 8:30 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Aug 09, 2010 5:51 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Aug 09, 2010 11:41 pm     Reply with quote

Here are some articles on keypad rollover issues:
http://www.lintech.org/comp-per/04KB.pdf
http://www.national.com/an/AN/AN-734.pdf
http://www.dribin.org/dave/keyboard/one_html
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Aug 09, 2010 11:56 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 11, 2010 11:32 am     Reply with quote

Thanks everyone. The links were very useful.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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