Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > Electronic Projects Design/Ideas/Reviews


Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution.

Reply
 
LinkBack Thread Tools Display Modes
Old 9th February 2004, 08:47 AM   (permalink)
Default Keypad Implementation using A/D on a PIC18Fxxxx

Mabuhay,

Anyone from the community who have done keypad implementation on a PIC using Analog-to-digital conversion?

Any info, materials and/or a sample snippet ...

Thank u.
rrb011270 is offline  
Old 9th February 2004, 09:34 AM   (permalink)
Default

I've never actually done it, but I've seen it done a lot over the years.

The technique is very simple, you feed +5V through a resistor to the A2D input, so it now reads 5V - no button pressed. You then have a series chain of resistors from this point, with switches down to ground. So when you press a switch it creates a potential divider with the upper feed resistor. By carefully selecting the resistor values you can find which key was pressed by measuring the voltage.

It's usual to have one key which shorts directly to ground, so that key would read 0V, no key 5V, and all others somewhere inbetween.

How many buttons are you wanting?.
Nigel Goodwin is offline  
Old 9th February 2004, 10:35 AM   (permalink)
Default

Quote:
Originally Posted by Nigel Goodwin
I've never actually done it, but I've seen it done a lot over the years.

The technique is very simple, you feed +5V through a resistor to the A2D input, so it now reads 5V - no button pressed. You then have a series chain of resistors from this point, with switches down to ground. So when you press a switch it creates a potential divider with the upper feed resistor. By carefully selecting the resistor values you can find which key was pressed by measuring the voltage.

It's usual to have one key which shorts directly to ground, so that key would read 0V, no key 5V, and all others somewhere inbetween.

How many buttons are you wanting?.
I am planning to have a 3x4 keypad on this project? can you help me on this? any information will do?

Thanx
rrb011270 is offline  
Old 9th February 2004, 11:33 AM   (permalink)
Default

Quote:
Originally Posted by rrb011270
I am planning to have a 3x4 keypad on this project? can you help me on this? any information will do?
Keypads are usually multiplexed, I don't think you can read them using an A2D. For a 3x4 keypad you need 7 I/O pins, and scan the keypad. There are details in my tutorials at http://www.winpicprog.co.uk, these use a 4x4 keypad, but there are comments on how to use them for 3x4.
Nigel Goodwin is offline  
Old 10th February 2004, 01:26 AM   (permalink)
Default

would this work...?
Attached Images
File Type: jpg keypad.jpg (17.0 KB, 708 views)
panic mode is offline  
Old 10th February 2004, 11:08 PM   (permalink)
Default

Where are you going to connect the pic's input to ?
Exo is offline  
Old 10th February 2004, 11:18 PM   (permalink)
Default

Quote:
Originally Posted by Exo
Where are you going to connect the pic's input to ?
I am planning to connect my keypad output to AN0 ---> an analog input for the PIC.

I guess this URL --> http://www.reed-electronics.com/ednm...amorim&stt=000 will give an insight that it is possible to design a keypad matrix that only use one analog port to the PIC microcontroller.

Thanx for your reply and input.
rrb011270 is offline  
Old 10th February 2004, 11:26 PM   (permalink)
Default

Quote:
Originally Posted by rrb011270
Quote:
Originally Posted by Exo
Where are you going to connect the pic's input to ?
I am planning to connect my keypad output to AN0 ---> an analog input for the PIC.

I guess this URL --> http://www.reed-electronics.com/ednm...amorim&stt=000 will give an insight that it is possible to design a keypad matrix that only use one analog port to the PIC microcontroller.

Thanx for your reply and input.
My question was to panic mode...

@rrb011270

Scanning keys using resistors an an ADC is common practive (philips even does so in some televisions) but, as you can see on the url you gave yourself, the resistors have to be placed between the switches. These 4 x 4 keypads you want to use are internally already pre-wired (in a matrix shape) wich prevents you from connecting those resistors. If you got a keypad wich allows you to connect every switch independently then there should be no problem.
Exo is offline  
Old 11th February 2004, 01:02 AM   (permalink)
Default

Hi exo,

You can read the voltage of the R8 for example.

Problem with the previous circuit is that multiple keys pressed at
once would not be detected. For example upper left key (A-G) would
short most of the network and any other key would not be detected.
Also circuit would continuously draw current.
After some thinking I came up with another circuit which should be better.
Attached Images
File Type: jpg keypad2.jpg (17.7 KB, 686 views)
panic mode is offline  
Old 11th February 2004, 02:05 AM   (permalink)
Default

Yep, that should work.
I'd recommend ratio for the R1-R7 values 1:2:3:4:4:8:12
For example
R1=100
R2=200
R3=300
R4=400
R5=400
R6=800
R7=1200

Resistor R8 is load and for good results it should be much bigger than
the other resistors if you want really linear system (the best would be to use constand current instead of fixed 5V source). I calculated things over using 10k for R8 and that looked very good. The output signal in this case
is only few mV and needs to be amplified of course.
Using lower value does work as well, it's just that graph is slightly bent. Values similar to R7 should be acceptable. Lower R8 also provides for larger output change. Anyway, it's an idea... use it on your own risk

:lol: :lol: :lol:
panic mode is offline  
Old 15th February 2004, 11:57 PM   (permalink)
Default

Quote:
Originally Posted by Exo
Scanning keys using resistors an an ADC is common practive (philips even does so in some televisions) but, as you can see on the url you gave yourself, the resistors have to be placed between the switches. These 4 x 4 keypads you want to use are internally already pre-wired (in a matrix shape) wich prevents you from connecting those resistors. If you got a keypad wich allows you to connect every switch independently then there should be no problem.
Thanx for provising an info..

BTW, I use a discrete switch here a surface mount type and a surface mount type resistor network for my switches...

With this I can select higher values of resistor in -order to have minimum current consumption. The only problem with higher resistor values is the equivalent resistance which exceeds the required impedance for the analog source... a 2.5K for PIC18Fxxxx sereis and most of the PIC16Fxxx series have 10K.

The solution I use in order to meet this impedance requirement esp. I am using the PIC18F1320 I have a voltage follower and a buffer rail-to-rail OPAMP with a teraohms input and a low impedance output.

With this configuration I can utilize the extra port of my PIC for access control and monitoring.

BTW, I got my circuits working now... esp. ADC part...

Thanx
rrb011270 is offline  
Old 17th February 2004, 12:10 PM   (permalink)
Default 3x4 keypad thinga magig?

Did it work?
egg0900 is offline  
Old 3rd March 2004, 11:11 PM   (permalink)
Default Re: 3x4 keypad thinga magig?

Quote:
Originally Posted by egg0900
Did it work?
The keypad resistor network really great and I have my code working with proper keypad mapping. The PIC code can detect what appropriate keys you press..
rrb011270 is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 02:09 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

eXTReMe Tracker