View previous topic :: View next topic |
Author |
Message |
rrb011270
Joined: 07 Sep 2003 Posts: 51
|
Keypad Implementation using A/D |
Posted: Thu Feb 05, 2004 9:53 pm |
|
|
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. |
|
|
kypec
Joined: 20 Sep 2003 Posts: 54
|
simple implementation |
Posted: Fri Feb 06, 2004 4:13 am |
|
|
Hi,
if you want I will send you an Excel sheet which I used
for calculation of resistor values in ladder configuration.
The values were originally calculated for PIC with internal
comparator module but it can be also used for PIC with
A/D converter module of course.
All you need to do is just to type in your voltages, number of scanned keys and then obviously write some C functions for measuring
the analog input (Vx) and evaluating obtained value.
good luck with your project,
kypec |
|
|
mechwu_2.0 Guest
|
Re: Keypad Implementation using A/D |
Posted: Fri Feb 06, 2004 6:20 am |
|
|
I calculated as below for 3x4 and 4x4 keypad but never tested.
Let us know if it really works.
best wishes.
Ref. see Tip #7 of this AP notes.
http://www.microchip.com/1010/pline/picmicro/category/embctrl/8kbytes/devices/12f675/9827/index.htm
----------------------------------------------------------------
Code: |
+5V --------------------
| | |
10k 6.7k 3.3k
| | |
1 2 3 -40k-|
|
4 5 6 -30k-|
|
7 8 9 -20k-|
|
* 0 # -10k-|---> To Analog Port
|
50k
|
GND
key: 1 2 3 4 5 6 7 8 9 * 0 #
---------------------------------------------------------------------------
A/D: 128 132 137 142 147 153 159 166 174 182 191 201
---------------------------------------------------------------------------
130 134 139 144 150 156 163 170 178 187 196
---------------------------------------------------------------------------
if (y<120) key = '?'
else if (y<130) key = '1'
else if (y<134) key = '2'
....
else key = '#'
+5V -----------------------------
| | | |
12k 9k 6k 3k
| | | |
1 2 3 A -37k-|
|
4 5 6 B -25k-|
|
7 8 9 C -13k-|
|
* 0 # D - 1k-|---> To Analog Port
|
47k
|
GND
key: 1 2 3 A 4 5 6 B 7 8 9 C * 0 # D
---------------------------------------------------------------------
A/D: 125 129 133 138 143 148 154 160 166 174 182 190 200 210 222 235
---------------------------------------------------------------------
127 131 135 140 145 151 157 163 170 178 186 195 205 216 228
---------------------------------------------------------------------
if (y<120) key = '?'
else if (y<127) key = '1'
else if (y<131) key = '2'
....
else key = 'D'
|
|
|
|
mechwu_2.0 Guest
|
Something I forgot ... |
Posted: Fri Feb 06, 2004 12:11 pm |
|
|
1. The contact resistance of keypad is not considered in my design.
2. The contact resistance of keypad might get rusted after years ... |
|
|
rrb011270
Joined: 07 Sep 2003 Posts: 51
|
Re: simple implementation |
Posted: Sat Feb 07, 2004 7:19 am |
|
|
kypec wrote: | Hi,
if you want I will send you an Excel sheet which I used
for calculation of resistor values in ladder configuration.
The values were originally calculated for PIC with internal
comparator module but it can be also used for PIC with
A/D converter module of course.
All you need to do is just to type in your voltages, number of scanned keys and then obviously write some C functions for measuring
the analog input (Vx) and evaluating obtained value.
good luck with your project,
kypec |
Hello Kypec, I'll love if u can send me the Excel sheet for my reference in the calculation of the resistor... my email address is [email protected]..
If u have some other points please share it coz I'll love to implement this keypad thing using PIC A/D. A snippet will be a good start for my projects...
I'll wired the switches and the reset of the circuits on monday... I'll keep u posted..
once again thnx for the info/tips |
|
|
rrb011270
Joined: 07 Sep 2003 Posts: 51
|
Re: Keypad Implementation using A/D |
Posted: Sat Feb 07, 2004 7:43 am |
|
|
mechwu_2.0 wrote: | I calculated as below for 3x4 and 4x4 keypad but never tested.
Let us know if it really works.
best wishes.
Ref. see Tip #7 of this AP notes.
http://www.microchip.com/1010/pline/picmicro/category/embctrl/8kbytes/devices/12f675/9827/index.htm
----------------------------------------------------------------
Code: |
+5V --------------------
| | |
10k 6.7k 3.3k
| | |
1 2 3 -40k-|
|
4 5 6 -30k-|
|
7 8 9 -20k-|
|
* 0 # -10k-|---> To Analog Port
|
50k
|
GND
key: 1 2 3 4 5 6 7 8 9 * 0 #
---------------------------------------------------------------------------
A/D: 128 132 137 142 147 153 159 166 174 182 191 201
---------------------------------------------------------------------------
130 134 139 144 150 156 163 170 178 187 196
---------------------------------------------------------------------------
if (y<120) key = '?'
else if (y<130) key = '1'
else if (y<134) key = '2'
....
else key = '#'
+5V -----------------------------
| | | |
12k 9k 6k 3k
| | | |
1 2 3 A -37k-|
|
4 5 6 B -25k-|
|
7 8 9 C -13k-|
|
* 0 # D - 1k-|---> To Analog Port
|
47k
|
GND
key: 1 2 3 A 4 5 6 B 7 8 9 C * 0 # D
---------------------------------------------------------------------
A/D: 125 129 133 138 143 148 154 160 166 174 182 190 200 210 222 235
---------------------------------------------------------------------
127 131 135 140 145 151 157 163 170 178 186 195 205 216 228
---------------------------------------------------------------------
if (y<120) key = '?'
else if (y<127) key = '1'
else if (y<131) key = '2'
....
else key = 'D'
|
|
Hello mechwu_2.0,
How many bits u use for the A/D in order to get the values of the resistors.
I plan to use it on a 10-bit A/D
Thnx |
|
|
mechwu_2.0 Guest
|
To: rrb011270 |
Posted: Sat Feb 07, 2004 8:12 pm |
|
|
1. For 10-bit A/D, simply multiply my numbers by 4.
2. The contact resistance of my keypad is 20 ~ 100 ohm depends on how hard it is pressed, measureded with a multimeter. check it out with your keypad.
Best wishes |
|
|
rrb-pic Guest
|
Re: To: rrb011270 |
Posted: Sat Feb 07, 2004 8:18 pm |
|
|
mechwu_2.0 wrote: | 1. For 10-bit A/D, simply multiply my numbers by 4.
2. The contact resistance of my keypad is 20 ~ 100 ohm depends on how hard it is pressed, measureded with a multimeter. check it out with your keypad.
Best wishes |
1. For 10-bit A/D, simply multiply my numbers by 4. ---> what u mean by this? do u mean the A/D value will be multiplied by 4.?
this for clarification....
thnx |
|
|
rrb011270. Guest
|
Re: To: rrb011270 |
Posted: Sat Feb 07, 2004 8:19 pm |
|
|
mechwu_2.0 wrote: | 1. For 10-bit A/D, simply multiply my numbers by 4.
2. The contact resistance of my keypad is 20 ~ 100 ohm depends on how hard it is pressed, measureded with a multimeter. check it out with your keypad.
Best wishes |
1. For 10-bit A/D, simply multiply my numbers by 4. ---> what u mean by this? do u mean the A/D value will be multiplied by 4.?
this for clarification....
thnx |
|
|
Guest
|
|
Posted: Sat Feb 07, 2004 9:48 pm |
|
|
For 4x3 keypad with 8 bit-A/D value 0 ~ 255, I said:
if (y<120) key = '?'
else if (y<130) key = '1'
else if (y<134) key = '2'
....
else key = '#'
For 4x3 keypad with 10 bit-A/D value 0 ~ 1023, it should be:
if (y<480) key = '?'
else if (y<520) key = '1'
else if (y<536) key = '2'
else if (y<556) key = '2'
....
else key = '#'
You can recompute the numbers based on the resistor network for better performance. for example, key '1' gives roughly 1023*(50k)/(10k+40k+50k) = 511.5, key '2' gives roughly 1023*(50k)/(6.7k+40k+50k)=529, so, the decision point should better be (511.5+529)/2 = 520, well, still the same as 130 x 4 in this case, so,
if (y<480) key = '?'
else if (y<520) key = '1'
...
should work
Best wishes |
|
|
Guest
|
|
Posted: Sun Feb 08, 2004 5:17 pm |
|
|
Hello,
Can this method of keypad implementation using a one channel A/D say, AN0 incorporates with #int_ad be possible?
need your comments....
thanx |
|
|
Guest
|
Re: Keypad Implementation using A/D |
Posted: Sun Feb 08, 2004 11:20 pm |
|
|
mechwu_2.0 wrote: | I calculated as below for 3x4 and 4x4 keypad but never tested.
Let us know if it really works.
best wishes.
Ref. see Tip #7 of this AP notes.
http://www.microchip.com/1010/pline/picmicro/category/embctrl/8kbytes/devices/12f675/9827/index.htm
----------------------------------------------------------------
Code: |
+5V --------------------
| | |
10k 6.7k 3.3k
| | |
1 2 3 -40k-|
|
4 5 6 -30k-|
|
7 8 9 -20k-|
|
* 0 # -10k-|---> To Analog Port
|
50k
|
GND
key: 1 2 3 4 5 6 7 8 9 * 0 #
---------------------------------------------------------------------------
A/D: 128 132 137 142 147 153 159 166 174 182 191 201
---------------------------------------------------------------------------
130 134 139 144 150 156 163 170 178 187 196
---------------------------------------------------------------------------
if (y<120) key = '?'
else if (y<130) key = '1'
else if (y<134) key = '2'
....
else key = '#'
+5V -----------------------------
| | | |
12k 9k 6k 3k
| | | |
1 2 3 A -37k-|
|
4 5 6 B -25k-|
|
7 8 9 C -13k-|
|
* 0 # D - 1k-|---> To Analog Port
|
47k
|
GND
key: 1 2 3 A 4 5 6 B 7 8 9 C * 0 # D
---------------------------------------------------------------------
A/D: 125 129 133 138 143 148 154 160 166 174 182 190 200 210 222 235
---------------------------------------------------------------------
127 131 135 140 145 151 157 163 170 178 186 195 205 216 228
---------------------------------------------------------------------
if (y<120) key = '?'
else if (y<127) key = '1'
else if (y<131) key = '2'
....
else key = 'D'
|
|
How can we change the resistor value such that the gap between buttons is large enough to prevent mistrigger? I need your comments please...
Thanx |
|
|
mechwu_2.0 Guest
|
. |
Posted: Mon Feb 09, 2004 5:45 am |
|
|
I did my design by trial and error to equalize the gap between buttons. Considering 8 bit A/D with 5 V for 0 ~ 255, each step is 5000 mV / 255 ~ 20 mV, and my design gives a minimal gap of 4, which means roughly 80 mV, so, it should work under a noise less than 10 mV, which shall not be difficult. Anyway, I never tested, so, that'a all I can say.
Good luck |
|
|
|