Shop OBEX P1 Docs P2 Docs Learn Events
To pull up or pull down..... with buttons — Parallax Forums

To pull up or pull down..... with buttons

TJHJTJHJ Posts: 243
edited 2009-01-05 20:04 in General Discussion
So I have been pondering this issue for a while now, which is better or does it not really matter?

In the case of button switches, mainly.

Case 1.

Usually I make a button connection with 3.3v on the button side, and a 1k to ground.
So the issue I can is see is that if the pin was set as an output, potently it could sink the max current to the pin damaging the prop.

3.3v
|
|    ___
----- | ------|-----<Prop IO PIN
              |
             >
             <1k
             >
             <
              |
            GND






Case 2

But i see commonly it reversed with it being pulled up to vcc, and the switch pulls down to ground. The PDB board works this way, this is what got me considering it.
In case 2, it seems to me that you would excessively be sinking current all the time though the 1k resistor, not much but it would matter in battery apps ect, But it will never over current the prop pin...


GND
|
|    ___
----- | ------|-----<Prop IO PIN
              |
             >
             <1k
             >
             <
              |
            3.3v






So which is better? and why?

Thanks for help always.

TJ

Comments

  • kwinnkwinn Posts: 8,697
    edited 2009-01-01 07:28
    Pullup is more common, and the pullup resistor is usually 4.7K to 10K range to reduce power consumption.
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-01-01 09:09
    Hello TJ,
    in BOTH cases there could flow a high current if the button is CLOSED

    if the button is opened, IO-pin is output and has the wrong logical stae the current is

    3.3V / 1000 Ohm = 3.3 mA which is NO problem for the propeller.



    1 case Pull-down: IO-PIN outpout and LOW button closed a high current will flow INTO the prop

    2 case Pull-up: IO-PIN outpout and HIGH button closed a high current will flow OUT of the prop

    to make it REALLY REALLY save you have to add a currentlimiting resistor like shown below

    This creates a voltagedivider but the ratio between the resistors is so high that the voltage-levels ar still
    far away from the threshold-point of 1.6V

    The voltagedrop across the 330 ohm resistor is maximum

    3.3V / (10000 + 330) * 330 = 0.105V

    so
    in case of pull-down the prop-pin gets 0.105V as LOW-voltage

    in case of pull-up the prop-pin gets 3.3V - 0.105 = 3.195V instead of 3.3V as a high signal

    but now in case of
    IO-PIN set as output
    the current is limited to (3.3V / 330 ohm) = 10mA which is save for the prop


    3.3v
    |
    |    ___
    ----- | -----|----330----<Prop IO PIN
                 |
                 >
                 <10k
                 >
                 <
                  |
                GND
    
    




    GND
    |
    |    ___
    ----- | -----|----330----<Prop IO PIN
                 |
                 >
                 <10k
                 >
                 <
                  |
                3.3V
    
    




    best regards

    Stefan

    Post Edited (StefanL38) : 1/1/2009 9:17:10 AM GMT
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-01-01 09:33
    The concept of pullups was historically used in TTL (transistor-transistor logic) of the 70's to minimise current. With current technology this no longer applies. Similarly, back then it was not common to be able to switch an an input to be an output. With a pullup, you have to invert the pin in software because usually the software uses a 1 internally to indicate the switch is depressed. Sometimes the logic provided an internal pullup, so with the switch to ground no resistor was necessary.

    As Stefan says, if you want to be sure, put in a series resistor, although I would use at least 1K with a 33K (10K-100K) pulldown/pullup.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Prop Tools under Development or Completed (Index)
    http://forums.parallax.com/showthread.php?p=753439

    cruising][noparse][[/noparse]url=http://www.bluemagic.biz]cruising[noparse][[/noparse]/url][/url]

    This is a [noparse][[/noparse]b]bold[noparse][[/noparse]/b] test.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-01-05 20:04
    This thread is being moved from the Propeller Forum to the Sandbox Forum as it general and not specific to the Propeller.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
Sign In or Register to comment.