Interview technical Question about keypad

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

Interview technical Question about keypad

Postby tst » Fri Mar 18, 2011 4:03 pm

today I attend an interview, the interviewer ask me an question and i duno how to answer it.
Can you connect the 4x4 keypad to the PIC microcontroller if there is only 1 I/O port for you to use? The interviewer ask me go home and find it out myself. Anyone have the idea?
tst
Apprentice
 
Posts: 33
Joined: Sat Sep 18, 2010 9:41 pm

Re: Interview technical Question about keypad

Postby Brian Griffin » Fri Mar 18, 2011 4:22 pm

tst WROTE:today I attend an interview, the interviewer ask me an question and i duno how to answer it.
Can you connect the 4x4 keypad to the PIC microcontroller if there is only 1 I/O port for you to use? The interviewer ask me go home and find it out myself. Anyone have the idea?


It could.

The keypad is connected to a resistor network first, and then to a astable 555 timer and each key can generate a specific frequency, just like a musical keyboard.

The square wave is fed into the I/O pin.

The MCU intepretes the frequency.

And get the key information from the lookup table.
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: Interview technical Question about keypad

Postby tst » Fri Mar 18, 2011 4:46 pm

Thanks Brian. Do you mind to teach me how to connect it? Let say that I am using cytron 4x4 keypad, there are total 8 pin. so I need 8 astable 555timer?

Astable 555 timer: http://www.kpsec.freeuk.com/555timer.htm#astable
4x4keypad: http://www.cytron.com.my/viewProduct.ph ... wUYOr1yFg=
Attachments
555ast.gif
555ast.gif (4.7 KiB) Viewed 6181 times
tst
Apprentice
 
Posts: 33
Joined: Sat Sep 18, 2010 9:41 pm

Re: Interview technical Question about keypad

Postby ABSF » Fri Mar 18, 2011 6:42 pm

tst WROTE:today I attend an interview, the interviewer ask me an question and i duno how to answer it.
Can you connect the 4x4 keypad to the PIC microcontroller if there is only 1 I/O port for you to use? The interviewer ask me go home and find it out myself. Anyone have the idea?


Wow, is this a trick question? Because 1 I/O port can be a port with 8 bits.....

But it can be done. Just read this application Note at Trick #7

http://ww1.microchip.com/downloads/en/d ... 40040b.pdf

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: Interview technical Question about keypad

Postby ABSF » Fri Mar 18, 2011 7:03 pm

There is a disadvantage using the above method. If you press more than one key, the ADC would be confused and would give you the wrong keypress.

If you use Brian's method. The 4x4 keypad may have to be broken into 16 push button switch connected to 16 unique resistors. A keypress will connect one of the 16 resistors into the 555 osc replacing your R2. This will give a unique frequency (preferably in audio range). The square wave will be counted by PIC to determine which key is pressed.

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: Interview technical Question about keypad

Postby tst » Fri Mar 18, 2011 7:26 pm

ABSF WROTE:The 4x4 keypad may have to be broken into 16 push button switch connected to 16 unique resistors.


Thanks Allen. How to connect it to 16 resistor since there is only 8 pin for the 4x4 keypad. The unique resistor you mean are bulit-in resistor in keypad?

ABSF WROTE: A keypress will connect one of the 16 resistors into the 555 osc replacing your R2. This will give a unique frequency (preferably in audio range). The square wave will be counted by PIC to determine which key is pressed.

what is R2? How is the connection looks like? Do you mind to sketch it? All the keypad pin (8pins) are connected together to 1 555timer? Sorry that I have too many question. Thanks a lot.
tst
Apprentice
 
Posts: 33
Joined: Sat Sep 18, 2010 9:41 pm

Re: Interview technical Question about keypad

Postby robosang » Sun Mar 20, 2011 10:49 am

ABSF WROTE:There is a disadvantage using the above method. If you press more than one key, the ADC would be confused and would give you the wrong keypress.

If you use Brian's method. The 4x4 keypad may have to be broken into 16 push button switch connected to 16 unique resistors. A keypress will connect one of the 16 resistors into the 555 osc replacing your R2. This will give a unique frequency (preferably in audio range). The square wave will be counted by PIC to determine which key is pressed.


Good method! Learn something new today :lol:
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: Interview technical Question about keypad

Postby tst » Thu Mar 24, 2011 1:51 pm

Anybody can answer my question?
tst
Apprentice
 
Posts: 33
Joined: Sat Sep 18, 2010 9:41 pm

Re: Interview technical Question about keypad

Postby Brian Griffin » Fri Mar 25, 2011 12:08 am

tst WROTE:Anybody can answer my question?


ABSF has given you very clear hints about the keypad. Have you read about the operation of the 555 timer?
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 1 guest

cron