Shop OBEX P1 Docs P2 Docs Learn Events
Pull-up/down resistors - Basic Question — Parallax Forums

Pull-up/down resistors - Basic Question

SeanBSeanB Posts: 4
edited 2006-04-10 19:44 in Learn with BlocklyProp
Hey folks, I have what I fear is a really basic question, so please forgive my ignorance...

I am having trouble understanding some of the details behind the pull-up and pull-down resistors.· I get that the idea is to have the input read a 0 (Vss) or 1 (Vdd) when, for example, a pushbutton is open, but I guess my question is how do the pins "sense" (What's a Microcontroller p. 76) Vss?· It makes sense that it can "sense" Vdd - that's a 5v source.· But how does it know when its connected to Vss (which is ground, right?).· This is more of a general circuit question than a BS2 one, I suppose...

I'm missing something fundamental.· Please smarten me up [noparse]:)[/noparse]

Comments

  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-04-08 20:07
    When set to an input, it is not connected to any voltage source (floating), so noise and other conditions can cause it to 'feel' a HIGH on second, and LOW another. Now, we take that input to a switch then to VDD. When the button is pressed, the input if firmly committed to 5V and a HIGH. But when released, it senses nothing again, so it is not committed.

    Adding a pull-down resistor to VSS, we commit that input low. When the button is pressed, the input goes to 5V.

    The resistor is needed so when the button is pressed the Vdd and VSS do not cause a short circuit and draw excessive current.

    Thus, a pull-down resistor with an Active-high switch.

    The converse would be an active-low switch with a pull-up resistor (more common).

    Many device inputs have pull-up resistors internal. The BASIC Stamp does not.

    Hope this helps?
    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    Southern Illinois University Carbondale - Electronic Systems Technologies

    Personal Links with plenty of BASIC Stamp info
    StampPlot - Graphical Data Acquisition and Control
  • SeanBSeanB Posts: 4
    edited 2006-04-08 20:12
    Martin,

    Thanks for the reply.

    Yes, it does help, its just hard to wrap my head around.· Is current actually flowing when an input pin is connected to Vss?· From the pin to Vss or vice versa?· Or am I thinking about this totally wrong?

    Thanks again,
    Sean

    Edit: "output pin" -> "input pin" (I type faster than I think [noparse]:)[/noparse])


    Post Edited (SeanB) : 4/8/2006 8:15:08 PM GMT
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-04-08 20:20
    As an output, the BASIC Stamp controls the voltage - not floating. Internally it will commit it high or low.

    As an input, it IS floating, therefore the state is not assured, therefore what you read may not be accurate. Pull-ups and pull-down force it to a state, and then the switch brings it to the opposite state.

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    Southern Illinois University Carbondale - Electronic Systems Technologies

    Personal Links with plenty of BASIC Stamp info
    StampPlot - Graphical Data Acquisition and Control
  • SeanBSeanB Posts: 4
    edited 2006-04-08 20:31
    Right.· I understand the reasons for having the pull-up/down resistor, I just don't understand how it "senses" Vss.· Is it simply reading the lack of 5v because all interference is sucked down to ground via the pull-down resistor?· Or is there still current flowing somewhere in the circuit?

    If I sound like I don't know what I'm talking about... its because I don't [noparse];)[/noparse]

    Sean
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-08 21:29
    Martin Hebel said...(trimmed)
    Many device inputs have pull-up resistors internal. The BASIC Stamp does not.
    Martin,

    ·· The BS2px does have internal weak (20K) pull-up resistors that can be enabled.·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-04-08 22:50
    Floating simply means it is not committed to any voltage source. When connected to either VDD or VSS, the potential (5V or 0V - Ground, not nothing) biases internal transistors to allow the input to detect if that digital state is high or low. In all actuality, any voltage above 1.4V is considered HIGH, anything less is LOW.

    Without getting deeper into the electronics theory, this is about all I can say to clarify what goes on.
    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    Southern Illinois University Carbondale - Electronic Systems Technologies

    Personal Links with plenty of BASIC Stamp info
    StampPlot - Graphical Data Acquisition and Control
  • SeanBSeanB Posts: 4
    edited 2006-04-08 23:09
    Martin,

    I appreciate the info.· As I said in my first post, this is all pretty new to me and its hard for me to wrap my head around some of the concepts...· You should see me try to reconcile the fact that a resistor's placement within a circuit is irrelevant (its scary, trust me wink.gif).

    I think I understand well enough to continue moving forward.

    If you or anyone else who happen upon this post again have recommendations for on or offline reading materials relating to basic electronics - electronics 101, as it were - that'd be great.· Either way, thanks for all your help.

    Sean
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-04-10 19:44
    The BS2 has inside it a PIC16C57 chip. The PIC I/O pins can be in three different states -- namely Output HIGH, Output LOW, and INPUT.

    When in OUTPUT HIGH, a driver transistor inside the PIC connects the pin to VDD. When in OUTPUT LOW, the first transistor is biased 'off' and a second transistor connects the pin to VSS. When in INPUT, both transistors are biased 'off', and the pin is routed to an input reciever.

    Now, the input reciever has very high input impedance -- a meg-ohm to 10 meg-ohms between the pin and Vss. So, if you select a pin for INPUT, and have nothing connecting it high or low, it 'floats' -- meaning any stray RF signal, across that meg-ohm, will generate enough voltage to trigger a high one moment, and a low the next. Your typically strongest RF signal is 60 Hz, coming from flourescent lights, by the way.

    Now, if you tie that pin to ground with a 10 Kohm resistor, you have a 'soft' zero. Any stray RF gets 'grounded' through that resistor, and the pin stays at ground potential. If you put a 'normally open' pushbutton between that resistor and +5, the signal will stay low until you push the button.··When the button is pushed the signal will go high.

    Now, if you merely tied the pin to ground with a wire, when you pushed the pushbutton you'd connect +5 directly to ground. This is commonly known as a 'short-circuit', and so much current would flow (briefly) that it might weld your switch shut. So that resistor is really needed in there.
Sign In or Register to comment.