ADC capacitor problem with keypad

Discussion in 'General Electronics Chat' started by aamirali, Jun 28, 2013.

  1. aamirali

    Thread Starter Member

    Feb 2, 2012
    415
    1
    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
     
  2. crutschow

    Expert

    Mar 14, 2008
    13,052
    3,244
    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.
     
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    1. Remove cap.

    2. Find source of noise

    3. Remove source of noise.

    Easy Peasy.
     
  4. crutschow

    Expert

    Mar 14, 2008
    13,052
    3,244
    I think the noise is likely due to switch bounce.
     
  5. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    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!
     
  6. aamirali

    Thread Starter Member

    Feb 2, 2012
    415
    1
    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
     
  7. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    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.
     
  8. aamirali

    Thread Starter Member

    Feb 2, 2012
    415
    1
    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.
     
  9. crutschow

    Expert

    Mar 14, 2008
    13,052
    3,244
    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: Jul 1, 2013
  10. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    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?
     
  11. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    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.
     
Loading...