ADC capacitor problem with keypad

Thread Starter

aamirali

Joined Feb 2, 2012
412
I have connected keypad to adc pin, cap size is 0.1uF. Problem is by connecting this capacitor the value don't change instantaneously due to which ADC value gets wrong & if I don't connect this then there is noise on pin. How to tackle this issue. I am sampling pin at 10ms
 

crutschow

Joined Mar 14, 2008
34,281
Since you haven't posted your circuit we can only guess.

10ms is too fast a sample rate. You need to allow time for switch bounce which may be 50ms or more.

Why are you using the ADC input instead of a digital input?

Try a smaller capacitor value.
 

THE_RB

Joined Feb 11, 2008
5,438
Agreed. Or very high value resistors in the keypad circuit giving slow voltage ramp times.

Both can be fixed by software debouncing;
1. get ADC every 10mS
3. if 5 ADC readings in a row (50mS total) all match a button, the button is pressed!
 

Thread Starter

aamirali

Joined Feb 2, 2012
412
I have adc keypad as in AN2034 by cypress semiconductor app not. Problem is adc pin of keypad is by around 15 cm wire. So I have to coonect a capacitor at adc pin. Which creates problem as voltage don't change instantaneously

Also I am sampling at 10ms. each means when a fall from threshold observed , I measured first read after 20ms again & match it
 

ErnieM

Joined Apr 24, 2011
8,377
Wow, that's almost 6 inches. Is there a source of noise nearby, say an electric motor or similar sitting on top of these wires? If not... it's probably not noise pickup.

Do you have a direct way to measure noise? Oscilloscope is best, or are you just assuming noise due to the response of your program?

AN2034 has 12 figures discussing various schemes. To get more then vague guesses you'll have to show a schematic of your work.
 

Thread Starter

aamirali

Joined Feb 2, 2012
412
attached is the ckt. I have attached capacitor of 0.1uf as I saw variation in reading without it. After it that variation has stopped, as thought it was due to long wire connector I have.

I think I should connect small capacitor value, but I don't know how small or how to calculate it.
 

Attachments

crutschow

Joined Mar 14, 2008
34,281
...............................
I think I should connect small capacitor value, but I don't know how small or how to calculate it.
Sometimes you just have to experimentally determine the value. Use a smaller and smaller value until the noise is a problem. Then I would use about double the minimum (last) value that worked.
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,377
I think I should connect small capacitor value, but I don't know how small or how to calculate it.
Neither would anyone else reading this thread as you did not include your resistor values.

Some places to put a capacitor are from Vdd to Vss as close to the PSoC as possible. A second such cap should be placed on the same lines down at your keypad.

0.1uf is the typical value for such a bypass cap.

How are you testing this circuit? Do you have any way to get data out of it beyond a blinkie LED?
 

THE_RB

Joined Feb 11, 2008
5,438
Software debouncing can be very powerful.

If you get multiple contiguous matching readings from the ADC, you know a button is pressed and has been held stable for X mS.

A few counts of ADC noise or HF noise spikes etc will all be completely negated by the software debouncing.

Like ErnieM said; how are you testing? I like to have a LCD display the ADC value a few times a second, and then can check what the ADC value is for each button condition, and can hardcode the midpoints between real button ADC values.
 
Top