+ Reply to Thread
Results 1 to 7 of 7

Thread: 'What is a microcontroller" 'Pushbutton Resistor Question (Page 76)

  1. #1

    Default 'What is a microcontroller" 'Pushbutton Resistor Question (Page 76)

    The example on page 76 of What is a microcontroller, and other examples in this chapter use 2 resistors to perform pulldown or pullup operations on a button. I understand why you would have to use resistors to do this in a pull-down style swtich, however i really would like an explanation as to why you would need to do this with a pull-up style switch?

    So long as the pin is set as an input, why are the resistors being used? On top of this, why are these specific values being used in this case? a 220/Ohm and a 10K.ˇI've seen other examples in other text that have not used any resistors in thisˇapplication. (Just a switch to the pin on the 5volt rail).ˇI'm especially interested in why these values. Could they really be any value in this application so long as the Vss side of the switch is higher than the Vdd side?

    I would love to know why? Thanks in advance.

    ˇ
    Last edited by ForumTools; 10-01-2010 at 11:55 PM. Reason: Forum Migration

  2. #2
    Parallax Engineering

    Chris Savage's Avatar
    Location
    Rocklin, CA
    Posts
    12,334
    Blog Entries
    8

    Default

    Mike,

    ˇˇ In the examples the resistors serve very specific purposes.ˇ First of all, the 10K resistor is used for pull-up/down.ˇ The reason you need this is that without them, when the pin is not connected to Vdd or Vss it is floating, and thus is subject to drifting HIGH/LOW without the button being pressed at all.ˇ Simply waving your hand near it could cause a change.

    ˇˇ The 10K pull-up is used on an Active-Low Switch.ˇ This is where the pin normally reads HIGH, but pressing the button makes it LOW.ˇ The 10K pull-down is used on Active-High switch.ˇ Here the pin normally reads LOW, but reads HIGH when the button is pressed.

    ˇˇ As for the 220 Ohm resistor.ˇ While not absolutely required (As the 10K is), it's there for safety.ˇ What if you accidentally made the pin an output low, then pressed your active-high push-button?ˇ This 220 Ohm resistor helps save the I/O pin from damage during such a mistake, and is well worth the $0.05 to be safe.ˇ Beats a new Stamp Module.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
    Last edited by ForumTools; 10-01-2010 at 11:55 PM. Reason: Forum Migration

  3. #3

    Default

    That makes sense. I guess the question I have is, where did these specific values come from? Perhaps I'm looking to deep into this, but why specificly 10K. The 220, as that its offering protection in this case, could probably be anything (within reason... You would want it rather low), but 10K, what formula did this calulate off of?



    Thanks again! I could believe I got a response last night two minutes after I wrote a message!

    Mike.
    Last edited by ForumTools; 10-01-2010 at 11:55 PM. Reason: Forum Migration

  4. #4

    Default

    With the 10K, what you are looking for is a value, that if you have multiple switches in parallel, will not draw excessive current (10 10K's would be 1K).ˇ But, you don't want the value so high that input device doesn't get sufficient current to sense the state.ˇ 5V/10K = 0.5mA, more than enough for IIL and IIH (current inputˇlow and high).

    10K is a good medium range for pull-up/pull-downs.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel

    Electronic Systems Technologies
    Southern Illinois University Carbondale
    Personal Links - ˇLot of BASIC Stamp info
    and
    SelmaWare Solutions
    StampPlot Pro Version 3 Release 4
    Graphical Data Acquisition for your Micro and Imagination!
    Now allows additional controls to be added, or developed.
    ˇ
    Last edited by ForumTools; 10-01-2010 at 11:55 PM. Reason: Forum Migration

  5. #5

    Default

    An 'open' input is also known as an "antenna" -- as such, it will pick up the 60 HZ 'hum' coming off of light fixtures quite easily.

    So, you want SOME resistor tying it high or low. OK, so why 10Kohms? Well, you don't want too much current to be used for this purpose, but you want enough current to give you a 'hard' high or low. A 10 Meg-ohm resistor would provide -- let's see --
    V = IR, so I = V/R. 5/10e6 == 500 uA. Very small, could be affected by RF noise.

    10 Kohms: 5/10e3 == 0.5 mA. Reasonable amount, will swamp any micro-amp noise signal. I've used 22 Kohm resistors in the past for pull-up/pull-down purposes. 10K is just a nice round number that gives good results.

    Now, 220 ohms (5/220 == 22 mA) is enough to drive an LED. But its close to the max current a BS2 pin can source or sink. Plus, you have other uses for that current besides just getting a 'hard' one or zero, and heating up the resistor.
    Last edited by ForumTools; 10-01-2010 at 11:55 PM. Reason: Forum Migration

  6. #6
    Parallax Engineering

    Chris Savage's Avatar
    Location
    Rocklin, CA
    Posts
    12,334
    Blog Entries
    8

    Default

    Mike,

    ˇˇ Martin and Allan have answered these questions for you.ˇ I hope that helps you see why these values are typically used.ˇ While the 220 Ohm resistors are something I first saw used here at Parallax, 10K is common all over the world for pull-up/pull-down resistors, depending on the bus type.ˇ Some busses, such as I2C use 4.7K, as do some keyboard/keypad decoder chips.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
    Last edited by ForumTools; 10-01-2010 at 11:55 PM. Reason: Forum Migration

  7. #7

    Default

    I get it! Thank you all for your help.

    I'm so glad these forums are here. They are great!
    Last edited by ForumTools; 10-01-2010 at 11:55 PM. Reason: Forum Migration

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts