Reading a Keypad

FYP Starter Pack, ICs, Voltage Regulator, Resistor, Capacitor......

Re: Reading a Keypad

Postby shahrul » Mon Oct 31, 2011 12:44 am

You understand keypad operation here, keypad lesson.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: Reading a Keypad

Postby ober » Mon Oct 31, 2011 11:57 am

You can also refer to one of our DIY project Details Description and sample source code to understand more. The schematic also there, PR9-B. It uses exactly the same keypad.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1440
Joined: Wed Apr 15, 2009 1:03 pm

Re: Reading a Keypad

Postby low5545 » Mon Oct 31, 2011 12:46 pm

Read it but I still don't understand.
low5545
Discoverer
 
Posts: 70
Joined: Wed Jul 27, 2011 5:55 pm
Location: Kuala Lumpur

Re: Reading a Keypad

Postby sich » Mon Oct 31, 2011 4:56 pm

As you can see in PR9-B Detail Description, the columns are pulled up to +5V and also been connected to PIC's I/O pins (RA0-RA3). Whenever one of these I/O pins is given signal LOW (0V), you will know that only the buttons located in that particular column will give LOW when it's pressed.
keypad diagram.jpg

In other word, if the PIC sensed LOW from one of the I/O pins connected to rows, it must be the buttons linked to that particular column which is given LOW at that very moment. If you press on the buttons on other columns which are NOT given signal LOW, they'll only give HIGH because they are all pulled-up.
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 603
Joined: Tue Apr 21, 2009 2:15 pm

Re: Reading a Keypad

Postby low5545 » Mon Oct 31, 2011 6:44 pm

Does that mean that pins K5 - K8 are set as input and pulled LOW; K1 - K4 are set as input and set high. And when you press button 1 (example) C1 and R1 will connect. When that happens, the voltage will short to K5 instead of K1 because K1 is pulled up to high (internal pull up resistor). This will make the reading on K1 to show LOW from HIGH and at K5 HIGH from LOW. This way, I can read the keypad, right?
low5545
Discoverer
 
Posts: 70
Joined: Wed Jul 27, 2011 5:55 pm
Location: Kuala Lumpur

Re: Reading a Keypad

Postby ABSF » Tue Nov 01, 2011 7:07 am

low5545 WROTE:Does that mean that pins K5 - K8 are set as input and pulled LOW; K1 - K4 are set as input and set high. And when you press button 1 (example) C1 and R1 will connect. When that happens, the voltage will short to K5 instead of K1 because K1 is pulled up to high (internal pull up resistor). This will make the reading on K1 to show LOW from HIGH and at K5 HIGH from LOW. This way, I can read the keypad, right?


Nop, K5-K8 are set as output and K1-K4 are set as input. You dont need resistors at the output ports because the outputs of PIC are not "open-drain" or "open-collector". You might not need the 4x10K resistors as some of the input ports in PIC have "weak-pull-up" built in if you read your data-sheets carefully.

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: Reading a Keypad

Postby sich » Tue Nov 01, 2011 9:48 am

Hi Allen, welcome back! :D And low5545, Allen is right about the connection. However, I'm not sure whether the PIC used in PR9-B has weak pull-up but apparently the diy project uses resistor to pull-up the lines.

Refer to Listing 3: All columns are pulled-up and the corresponding PIC pins are set as outputs. All PIC pins connected to rows are set as inputs. The process to detect button press is conducted column-by-column. If you want to detect any button in Column 1 (eg: Button 1), you'll have to set RA0 to LOW. Then test the input pins (RE1, RE0, RA5 and RA4). If Button 1 is pressed, Column 1 is connected to Row 1. Since Column 1 is set to LOW, Row 1 will get LOW signal and RE1 will detect LOW too.
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 603
Joined: Tue Apr 21, 2009 2:15 pm

Re: Reading a Keypad

Postby low5545 » Wed Nov 02, 2011 6:15 pm

If columns are set as input, rows are set as outputs (LOW). If a button is pressed, the current will short to the row and columns will get a LOW reading. If so, how can you determine the row of the button?
low5545
Discoverer
 
Posts: 70
Joined: Wed Jul 27, 2011 5:55 pm
Location: Kuala Lumpur

Re: Reading a Keypad

Postby ABSF » Wed Nov 02, 2011 7:47 pm

low5545 WROTE:If columns are set as input, rows are set as outputs (LOW). If a button is pressed, the current will short to the row and columns will get a LOW reading. If so, how can you determine the row of the button?


The trick is in the software. You do not send '0000' on the row in one scan and expect to read 16 keys on the column. What we do is scanning one row at a time using the patterns '1110' '1101' '1011' & '0111' to read 4 keys on the column per scan. As the row is looping very fast (key debounce can also be taken care by software), it would appear that you are getting instant key detection in a matter of milli-seconds.

The diagram you posted is not very informative. If you can get one with all the switches drawn out properly and the inputs and outputs are replaced using transistors, it would be more apparent to you and easier for you to grab the concept.

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Next

Return to Electronic Component

Who is online

Users browsing this forum: No registered users and 3 guests