Shop OBEX P1 Docs P2 Docs Learn Events
Is there a preferred method for connecting a switch input? — Parallax Forums

Is there a preferred method for connecting a switch input?

Don MDon M Posts: 1,652
edited 2012-11-01 14:01 in Propeller 1
By method I'm referring to whether you tie a pin high (through resistor) and then pull it low with the switch or vice versa. Any pro's or con's? I would probably gravitate to tying high and pulling low but wanted some of the "experts" opinions here.

Maybe it really doesn't matter?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-11-01 09:49
    I tend to use the pullup / connect to ground method for the following reasons:

    1) The pullup can be close to the device (microcontroller) in question and Vdd is readily available there. By having the pullup associated with the input pin, it's always there if the switch is somehow disconnectable.

    2) The only wires needed to the switch are the signal line and ground. Ground can be used with twisted pair wiring and/or shielded cable for noise protection. You can use Vdd, but then the noise protection depends on the quality of the bypassing between Vdd and ground.

    3) For switches permanently mounted close to the input pin in question, it probably doesn't matter which scheme you use.
  • Martin_HMartin_H Posts: 4,051
    edited 2012-11-01 09:49
    I asked the same question a few weeks ago. Here's a pointer to the thread

    http://forums.parallax.com/showthread.php?143174-Switch-or-Whiskers-pulled-up-to-3.3-or-pulled-down-to-0-when-open.
  • tonyp12tonyp12 Posts: 1,951
    edited 2012-11-01 10:01
    If you look at it as voltage divider that have two resistor value at the extreme high or low end (open vs closed switch)

    And that voltage is like water flowing in to the middle line (that goes the the mcu input) and it fills up/empties out if you press switch.
    5M is like a tiny drip
    10K is like a 1mm small pipe
    2 ohm is a 1 foot wide pipe.

    1mm pipe will never fill up the middle line if it has a 1 foot wide drain pipe connected etc.
    974 x 707 - 111K
  • Don MDon M Posts: 1,652
    edited 2012-11-01 10:42
    Thanks all.
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2012-11-01 11:03
    Don't forget the capacitor if its an AC switch, (we want a tiny spark).
    And no capacitor if the switch has gold contacts, (we don't want a tiny spark).

    Duane J
  • jmgjmg Posts: 15,173
    edited 2012-11-01 14:01
    Don M wrote: »
    By method I'm referring to whether you tie a pin high (through resistor) and then pull it low with the switch or vice versa. Any pro's or con's? I would probably gravitate to tying high and pulling low but wanted some of the "experts" opinions here.

    Maybe it really doesn't matter?

    The processor does not care, either way.
    However, other considerations can apply :

    If the switch is remote, taking the chip Vcc out into the 'real world' is generally considered risky. Slips to GND or worse, raw-battery become costly...

    ESD considerations also prefer a GND pathway, and there, some series resistance (100 ohm-1K) in EACH wire, can lower the ESD current levels, and therefore the disturbance voltages - you will see some TACT buttons come with an extra ESD pin, because of this problem.
Sign In or Register to comment.