5

Ever since I connected a button to an Arduino for the first time, I've wondered how does the resistor prevent floating input from happening? I've read several answers to similar questions, seen videos and read forum posts:

https://www.quora.com/What-is-a-floating-input-gate
"We say it's left to float, which means it's in an indeterminate state: maybe high, maybe low, maybe somewhere in the middle. Worse, it may even change depending on other conditions in the environment." This just explains what it is. Which is fair, since that is what the person asking, asked for.

https://forum.arduino.cc/index.php?topic=378402.0
Same as above.

https://www.youtube.com/watch?v=wxjerCHCEMg This video goes into a decent amount of detail about what causes floating input, i.e. outside electrical sources, and how to solve it, but does not address why adding a resistor eliminates this noise.

Everything I read on the internet just answers the same questions over and over again. I already know why you use a pull-down resistor ( or a pull-up resistor), to eliminate floating input and to prevent a short (in the case of a button). I already know that floating input is a result of electrical noise. But if someone asked me "so why does adding a resistor make the floating input go away?", I don't know how I would explain it to them, other than "it just does".

I wasn't sure whether I should post this question here, or in physics.stackexchange. I feel like this question is well within the domain of both sites, so I just picked one.

Edit: I do not feel this is a duplicate of What is a pull up and pull down? Because even though the information I am after is within the scope of that question, it does not provide it. I am not asking what a pull up or pull down is. What I'm asking is why does a resistor in a pull up / pull down eliminate floating input.

  • 1
    If you exchanged the resistor for a wire, would that make it easier to understand? You can think of a wire as a near-zero ohm resistor. – Dampmaskin Aug 23 '19 at 07:56
  • 1
    Possible duplicate of [What is a pull up and pull down?](https://electronics.stackexchange.com/questions/7423/what-is-a-pull-up-and-pull-down) – JYelton Aug 23 '19 at 16:08
  • Dont think this was a duplicate ques. – Mitu Raj Aug 26 '19 at 10:58

3 Answers3

3

It's very simple.

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 1. A CMOS input and one with a pull-down resistor.

  • The typical input is very high impedance - so high that we can usually assume that no current flows into it in the steady state. The input has some very small capacitance, however, and this needs to be taken into account at high frequencies.
  • The input impedance is so high that the input can be affected by stray or induced voltages.
  • Adding the pull-down resistor discharges any voltage on the input capacitor and the input is held low.
Transistor
  • 168,990
  • 12
  • 186
  • 385
  • For beginners, you will want to make it explicit that no current through a resistor means ZERO voltage drop across the resistor which is the same as shorting it to ground with a piece of wire... Except for the difference that if you do apply a voltage to the input it can override the pull-down resistor *unlike if you just shorted the input to ground with a piece of wire rather than a resistor). – DKNguyen Aug 23 '19 at 08:00
  • 1
    Just adding for clarification: The noise, simplified, is a product of the current x impedance. So a very small current flows, but a very high impedance still equals a large induced noise. When adding a resistor in parallel, not only do you give the parasitic capacitive effects a better discharge (R*C) but you also reduce the total impedance by the reciprocal value of (R1^-1+InputImp^-1)^-1, thereby reducing the induced noise. – Sorenp Aug 23 '19 at 08:05
  • Let's see if I understood this correctly: V = IR. So because the resistance of the input pin is very high, just a tiny amount of current is enough to flip it over the threshold and count as a 1. (Not really sure what the difference between "stray voltages" or "induced voltages" is. Stray electrical current vs current induced by a magnetic field?) How does the pull-down resistor discharge any voltage on the input capacitor? What happens to the current if it doesn't go back out into the air or into the input pin? Is it stored in the electrical circuit or the resistor itself? – Magnar Kleppe Aug 23 '19 at 10:01
  • See those little triangles pointing down? These mark "GND" ("ground") as the (sic!) ground potential and connect all terminals on which they are set. So the charge on the capacitor (or the voltage coming "over the air" which means the same for our view here) will create a current through the resistor. Currents always flow "in circles", so this one gets back to the capacitor. Your question is likely more "Where does the energy go?" Well, it is lost as heat through the resistor; this is where all energy will go in the end. – the busybee Aug 23 '19 at 10:54
  • This answer and the discussion here has cleared things up for me, so for that reason I will accept this answer. Thanks everyone! – Magnar Kleppe Aug 26 '19 at 06:48
  • The capacitor causes charges to build up, while the resistor discharges it to ground, keeping the voltage from build up and switching MOSFET – Mitu Raj Aug 26 '19 at 10:57
3

Input pins often have a huge input impedance, in the range of mega-ohms. So only very miniscule current can and will flow into or out of them.

This means that only miniscule electrical noise is sufficient to change the voltage on the pin. This electrical noise can come from e.g. RF interference picked up from the environment. The pin and connected lines then act like antennas, and the very minute electrical power picked up by these antennas can be enough to affect the pin's state.

That's because whatever electrical noise gets picked up has almost nowhere to go, because the pin is so high impedance that it hardly does conduct away the noise at all.

Then, in every real circuitry, we have parasitic capacitances and resistances, both internal to the chip and external. This can cause minute charges to flow to the pin and also change it's voltage.

The function of a pull-up or pull-down resistor is to conduct away any undesired electrical charge so that it cannot affect the input pin's state.

For this, the resistance of the pull-up or pull-down must be significantly lower than the pin's input impedance, which isn't hard to achieve since the input impedance is quite large, see above.

In more technical terms, we have a very high impedance source of noise and other parasitic signals, coupled to a very high impedance input. The pull-up/-down resistor basically gets connected in parallel to the input pin (and in series with the noise source) and reduces its effective input impedance which proportionally reduces the voltage the high impedance noise can induce.

JimmyB
  • 3,823
  • 2
  • 18
  • 21
  • Best answer. I thought it was in series with the input impedance so I didnt know how the noise at 0V would be reduced to be inside the margin, but of course from the perspective of the noise it's in parallel – Lewis Kelsey May 01 '21 at 11:05
2

The input is floating because it does not have a logic voltage driving it with a valid logic low or logic high.

The resistor provides that connection to a logic voltage. It can connect it to a logic high voltage (pull-up resistor) or a logic low voltage (pull-down resistor).

If it's the only connection to the input then the resistor does the same job as a piece of wire going to the logic voltage. You will find mountains of text about 'logic signalling voltages' and logic signalling on the internet.

TonyM
  • 21,742
  • 4
  • 39
  • 62