Shop OBEX P1 Docs P2 Docs Learn Events
Understanding Active-low and Active-high circuits — Parallax Forums

Understanding Active-low and Active-high circuits

Blackwolf189Blackwolf189 Posts: 2
edited 2005-12-02 17:21 in BASIC Stamp
On page 76 and 79 in What's a Microcontroller, can someone please explain to me how this circuit works. Why is there a resistor from P3 and how is the current traveling when the button is pushed and when it is released?

Comments

  • dandreaedandreae Posts: 1,375
    edited 2004-07-27 16:27
    Hello,

    Regarding pages 76 and 79 of the What's a Microcontroller.· When the button is pressed it completes the circuit as in the flow of current.· When the button is not pressed it acts like an "open" in the circuit (no current flow).· The 220 ohm resistor is used for the protection of the I/O pin against reverse current.· The 10k ohm resistor is to stop the I/O pin from floating.

    Thanks,

    Dave
  • Blackwolf189Blackwolf189 Posts: 2
    edited 2004-07-27 23:03
    Thanks that helps. What do you mean when you say floating
  • dandreaedandreae Posts: 1,375
    edited 2004-07-27 23:28
    When you are setting up the circuit you'll notice that you have an "open" until the button makes contact.· This means that·when you have an "open" the line is floating and you could quite possibly pick static or noise on the line·that would change the state of the I/O pin.· If you use a pull-down resistor in your circuit this insures that the line is driven low and not floating and therefore no static interference.

    Thanks,

    Dave
  • KenMKenM Posts: 657
    edited 2004-07-28 02:18
    To add a comment.....

    If an input pin·does not have a pull-up resistor (resistor from input to +5v) or the input pin does not have a pull-down resistor (resistor from input to ground) the pin is said to be floating.....

    You cannot guarantee if the pin will stay at a logic 1 or logic 0.· In fact, you can be pretty darn sure whatever state it is in while floating, it will randomly changes states...

    The voltage present on the input pin determines if the pin is in a logic 1 or·0, and when·there·is no pull-up·or pull-down resistor, the·state changes at random....imagine·a voltage on the pin drifting above and below the threshold for a logic 1·and logic 0......hence the term, floating.



    Ken Mathis
  • PaulPaul Posts: 263
    edited 2004-07-29 13:10
    To add another comment:

    Floating pins are also the hardest things to troubleshoot. You're there at 1AM trying to figure out why P7 is reading a "0" when it finially hits you that your missing a pull-up resistor. My advice is to have some 10K resistor-networks handy. I would petition Parallax to include these on the stamp chips but sometimes you need pull-ups and sometimes you need pull-downs.

    Paul Coy
  • KenMKenM Posts: 657
    edited 2004-07-30 02:13
    1:00am.......dang, you are good. When that one bites me it can be 3 am or later.· As the day gets longer, the brain power decays logrythimically (spelling?)......making the problem even harder to realize.
    Paul said...
    To add another comment:

    Floating pins are also the hardest things to troubleshoot. You're there at 1AM trying to figure out why P7 is reading a "0" when it finially hits you that your missing a pull-up resistor. My advice is to have some 10K resistor-networks handy. I would petition Parallax to include these on the stamp chips but sometimes you need pull-ups and sometimes you need pull-downs.

    Paul Coy
  • shawnpwilsonshawnpwilson Posts: 10
    edited 2005-12-02 01:55
    How does one determine what resistor value is needed·for a pullup· or pulldown?
  • Buck RogersBuck Rogers Posts: 2,175
    edited 2005-12-02 02:26
    shwanpwilson said...
    How does one determine what resistor value is needed·for a pullup· or pulldown?
    Hello from Buck Rogers
    Good question. For what I do in regular logic away from the stamps I typically start up with a 100 resistor. And then typically end up with either a 2K or 2.2K. YMMV
    yeah.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Buck Rogers

    www.gregg.levine.name
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-12-02 02:27
    Perhaps it's just tradition, but pull-ups and pull-downs are usually 10K, though 4.7K is also very common.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Clock LoopClock Loop Posts: 2,069
    edited 2005-12-02 06:02
    SO far 10k has worked perfectly for me. The only reason to use a high resistor like 10k is to stop stray current from flowing. Most logic devices require very little current to "see" the pull up or down level.

    If you measure the current that flows thru a 10k or a 1k you will see why 10k is better, in battery/power conserving situations.
  • shawnpwilsonshawnpwilson Posts: 10
    edited 2005-12-02 14:25
    Since a diode is a one way valve for current, could they equally as well be used as pull-up/pull-down components too?· Or would they only eliminate the potential for floating by 50%?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-12-02 14:44
    No, that won't work because the input pin is "floating" so no current will flow through the diode. If then you press a button to that does cause current to flow, the unprotected diode would probably burn out. As you gain more experience you'll see that pull-up/pull-down resistors are ubiquitous; so much so that many microcontrollers have them built-in and can be enabled by software. The BS2px gives you the ability to enable weak (~20K) pull-ups on the pins through the CONFIGPIN instruction.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-12-02 16:55
    Jon is correct in that the more common values are 4.7K and 10K.· I have found that there are actually better applications for each value.· For example 4.7K resistors are often used in I2C applications where only 2 lines are being pulled high.· Whereas 10K are often used in parallax bus applications or situations where several lines need to be pulled high/low.· In such a situation a higher value resistor limits the total current drop across the resistors.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • shawnpwilsonshawnpwilson Posts: 10
    edited 2005-12-02 16:56
    I know this one will probably test someone's patients but what would
    happend if there is both a pull-up and a pull-down at the sametime?· Would that just nullify everything and put the
    pin back to a potential floating state?· I know common sense would say noone would do it, but I'm just curious.

    Post Edited (shawnpwilson) : 12/2/2005 5:02:34 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-12-02 16:58
    On a TTL level input, having pull-up and pull-down resistors would hold the input voltage at 1/2 Vdd.· So that would usually be 2.5 volts, which would register as a HIGH.· On CMOS you could actually get some weird results.· This is, obviously, not recommended.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-12-02 17:02
    Are you going to invade a doctor's office to test his/her patients?...· tongue.gif

    Let's say you attached two 10k resistors to an I/O pin, one to Vdd, one to Vss -- what you've done is attached a voltage divider to that pin and you'll have about 2.5 volts on the input.· This will look like a "1" because the input threshold (for the BASIC Stamp)·is 1.4 volts.

    It's very easy to over-think these simple things and let them get in the way of actually doing a project.· Trust that engineers have been using pull-ups and pull-downs for a long time and that they do in fact serve their intended purpose.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • shawnpwilsonshawnpwilson Posts: 10
    edited 2005-12-02 17:21
    lol.gif·I knew got that spelling wrong!
    Well, good.· I learned a few things here.· I learned what "floating" is and how it can adversely affect an I/O pin; I've learned how to stablize an I/O pin to either a logic·level·of 1 or 0; and I learned how to divide a Voltage.

    Actually, I bought a WAM from radioshack·lastweek but haven't hooked it up just yet.· Thought I'd read through the manual and browse around the forums a little bit first.

    Parallax is a great starting place for any beginner as they have a great deal of supportive material and very responsive individuals who help others.

    Thanks all for your responses and I look forward to asking many more questions down the road.
    Jon Williams (Parallax) said...

    Are you going to invade a doctor's office to test his/her patients?...· tongue.gif

Sign In or Register to comment.