help a noob understand PULLDOWN/PULLUP through the online forest of information

Hi all,

Background: this is my first post on this forum and I've just started playing with Arduino and circuitry over the past two weeks after I saw a colleague give a small demo. So I bought a starter kit and started doing tutorials in my evenings. Bottom line: I'm a Dutch 39 yo complete and utter n00b on anything related to electricity, or physics in general I guess, go easy on me please :slight_smile:

I've been hitting my head against the concept of Pullup and Pulldown resistors. So I know! Use the search function! Well, I did. I spent two evenings reading/watching dozens of pages/youtubes about them. But I'm still left with questions that I can't find good answers for. Not being a native English speaker (I'm Dutch) doesn't help in jargon searching either, although I'm not familiar with Dutch electrics jargon either so I'm going in blind one way or the other :slight_smile:

So I think now that I get what they do after trying to see the actual trees in the forest of the interwebs :slight_smile: Can anyone verify whether I'm getting this right with this summary?

  • PULLDOWN resistor is to connect pin with GND, so all fluctuations flow away to GND and it's always a 0. UNLESS there's current flowing "past" the resistor by connecting the pin to 5V as well, e.g. by pressing a connector switch, which makes the pin read 1.

  • PULLUP resistor is to connect pin with 5V, so there's always 5V on the pin, making it always a 1. UNLESS there's current flowing away "past" the pin towards GND, e.g. by pressing a connector switch, which makes the pin read 0.

(By "past" I mean that current "likes" to go through the path of least resistance and thus significantly less flows through the resistor (pulldown scenario) or through the pin (pullup scenario), making the alternative path created by the button press more attractive.)

I've attached a drawing of my understanding as a PNG picture. Hope I'm getting that right, more or less? Note: I'm also learning how to draw and read electric circuits from scratch, this is literally my first attempt. Constructive criticism is always welcome.

Now for my actual question! WHY in the first place is the Arduino pin randomly alternating between 1 or 0 when there's NO circuit? I keep finding pages that say that it's about something called high impedance circuitry fluctuations caused by things like EM interference, static electricity or even quantum fluctuations, but I can't find qualitative descriptions of what's ACTUALLY going on there. Not that I understand, anyway. Nor have I found a good noob-friendly explanation about what electrical impedance is or how it relates to digital 0/1 flappings on the Arduino. What is the apparent randomness that sometimes makes it 1, and how can there be a 1 without something connecting to the pin to flow current through?

Thanks for bearing with me and hopefully you can help me kickstart my second life as a microelectronics enthusiast \o/

Note: I know that the Arduino has a PULLUP resistor built-in for input pins. I'm just trying to know how it actually works.

โ€œThanks for bearing with meโ€ ???

When there are no components connected to an input, this is referred to as a floating input.
A floating input can be sitting at either a HIGH or LOW voltage due to the high input impedance of that input.

We prevent this condition by removing floating voltages with a pullup or a pulldown resistor.
A 10k resistor is usually a good value for these.
See the image below for examples.

Thanks!

However, that's what I keep reading: "due to the high input impedance of that input". I accept it, and it works, and I now have learned how to connect everything and I can make reliable digital readings if I just walk the line. but I don't understand why it's flapping.

Also I posed an explanation in my own (qualitatively stated) words, and I was hoping for someone to sanity check that.

Thanks again for your quick answer.

Maybe it helps to understand how CMOS logic inputs actually work.

The pin in input mode is connected to the gates of a complementary pair of small-signal MOSFETS,
and gates in MOSFETs sit on top of a thin insulating layer of silicon dioxide - the voltage affects
the channel between source and drain of such devices, but there is no path for any current to
flow from the gate - the input pin is basically isolated by an ultra-thin layer of quartz. Its voltage
affects the output circuit, but no current flows into or out of it.

Thus its effectively completely unconnected - hence "floating" - and the voltage depends on nearby
electric fields, static charges, interference, etc etc.

Typically there is a tiny current that can flow, but its on the scale of millionths of millionths of an amp.

In order to ensure the input is in a known state (voltage), it needs to be connected to a known voltage.

The is what the switch and resistor do - the switch has much lower resistance and will win over the
resistor when it is pressed, otherwise the resistor defines the voltage - so connect the switch to
one supply rail, and resistor to the other, and pressing the button then switches the input voltage
between these values.

As in the image offered, the input impedance/resistance on an input is >100mega ohms.
This is for all intents and purposes is infinity.
In the controller, there are very small leakage currents that can build up a voltage across this high input resistance.
The actual open circuit floating voltage may be a lower level which input see as a LOW.
It may be a higher level which the input may interpret as a HIGH.

When a 10k resistor is added from the input to GND, the floating voltage is discharged to GND giving 0v on the input pin.
When a 10k resistor is added from the input pin to 5v, the floating voltage goes to the power supply voltage i.e. 5v if this is a 5v controller.

However, that's what I keep reading: "due to the high input impedance of that input". I accept it, and it works, and I now have learned how to connect everything and I can make reliable digital readings if I just walk the line. but I don't understand why it's flapping.

There are electro-magnetic signals all around you. If you've ever touched an audio input and heard a "buzz", that's power-line hum picked-up by your body.

That same electro magnetic radiation (or electro-magnetic interference) is picked-up by the Arduino.

Now, you need to know about [u]Ohm's Law[/u] and electrical power. Ohm's Law describes the relationship between voltage, current, and resistance, and it's the first thing you learn when you study electronics. Power is calculated as Voltage x Current (and there are a couple of other derivations for calculating power).

Anyway... You can get fairly high voltage picked-up by your body, or by an unconnected Arduino input. BTW - A longer wire or your body makes a "better" antenna than the leads & traces on the Arduino board, so if you connect something it picks-up even more "noise".

But there isn't much power in that electromagnetic radiation so you can't get much current.

If you lower the impedance (or resistance) with a pull-up or pull-down resistor the "noise" voltage drops because of the limited available current (Ohm's Law).

That's a little different from how we normally use Ohm's Law... Typically (in properly designed & properly functioning circuits) the voltage is constant (technically independent of resistance). So when you apply 5V, it stays 5V with or without, a pull-up/pull down, and the current varies with resistance according to Ohm's Law.

...When you use a switch or transistor/opto-coupler, etc., with a pull-up the switch (or other device) "overpowers" the pull-up resistor, and current flows through the resistor.

I now have A LOT of stuff to Google! :slight_smile: Thanks for all of that. It's so much more helpful having people address your actual questions than reading through endless well-intended lectures that make me dizzy.

Still, two questions.

  1. How come those fluctuations can make the difference between 0 and 1 then?

Now, LarryD says: "The actual open circuit floating voltage may be a lower level which input see as a LOW. It may be a higher level which the input may interpret as a HIGH." Lower/higher than what?

If you'd asked me before, I'd have guessed that fluctuations to an unconnected pin would not be nearly significant enough to make it read "HIGH"? What am I still missing?

I don't know if this is even explainable to a noobish tech enthusiast with a background in customer service :slight_smile: But thanks for trying.

  1. If I understand right, in case of a PULLUP, the current has to come from/through the resistor first, and then "choose" between the pin or the GND. Why does the GND seem to win out? Does it just "suck harder" (for lack of a better term) or is there something else going on?

Read this page:

A direct connection to Vcc/5v or to GND/0v wins out over the 10k pullup/down resistor because the 5v/0v connections are made with a zero ohm resistor/wire.

You do need to read about ohms law.

Edit:
Note a voltage between 1.5v an 3v on a five volt controller is referred to as an undefined voltage level.
The controller circuits gives unreliable detection at these levels.
Floating voltages can make these detection circuits give a HIGH one time or a LOW another time.

Yes, that's where I came from. It says that it's LOW on voltages less than 1.0/1.5V (depending on 3.3/5V board voltage) and HIGH on voltages greater than 2.0/3.0V.

So what I'm not getting yet is how an unconnected pin can experience >2.0V out of "nothing". Now I know that our universe is not "nothing", not even in interstellar vacuum let alone in Earth's atmosphere in the middle of Amsterdam, but still :slight_smile:

I guess that's where I'm going to need to learn more about what DVDdoug meant with "You can get fairly high voltage picked-up by an unconnected Arduino input ... But there isn't much power in that electromagnetic radiation so you can't get much current."

Still not intuiting the current/voltage/power (etc.) basics - lots to study. This all is helping a lot.

larryd:
Note a voltage between 1.5v an 3v on a five volt controller is referred to as an undefined voltage level.
The controller circuits gives unreliable detection at these levels.
Floating voltages can make these detection circuits give a HIGH one time or a LOW another time.

Ah, now that makes sense. Somehow I assumed until now that it would always default to LOW unless it was high enough to be a HIGH.

Remember that in dry winter, you can get a spark from your hand to the car door when you slide out of the seat?

That corresponds to thousands of volts of static electricity generated simply by movement of two materials against each other.

So in less dry conditions, smaller voltages are generated by almost every movement, possibly even by wafts of air moving over things (remember how lightning is generated in the atmosphere)!

CMOS electronics is, as has been discussed, extremely sensitive to these voltages, so without a resistor "tying" an input to a specific voltage, usually your supply voltage or ground, an input will easily be affected by stray static electricity and may change from minor disturbances.

โ€œSo what I'm not getting yet is how an unconnected pin can experience >2.0V out of "nothing". โ€

There are leakage currents in our electronic circuits, there is static electricity in the air, your body has voltage gradients.

Hey, have you ever walked across a carpet and experienced a static discharge?

Paul__B:
That corresponds to thousands of volts of static electricity generated simply by movement of two materials against each other.

Yeah, I've often been told so, but it's always kinda wooshed over my head I'm afraid :slight_smile:

Now reading into electrics basics for the umpteenth time in my life, but for the first time with an actual urge to really understand what's going on, it's like popping zits of ignorance :slight_smile: Thanks for for noob-friendliness.

I'm also starting to understand why those anti-static wristband thingies aren't just superstition :slight_smile:

โ€œI'm also starting to understand why those anti-static wristband thingies aren't just superstition :)โ€

:art:

SadBunny There are a lot of good explanations here, I hope you understand now. Reading them was a sharp reminder that when you've known about a subject most of your life things that seem obvious are not at all obvious to someone without that specialist knowledge.

Something that seemed to be missing from any of the explanations, but which I suspect you don't realise, is that there is no such thing as 'no voltage' (as distinct from 0v). Everything has a voltage, even if it's not obvious. That floating pin has a voltage, it's just not very well defined. 0v, which is usually synonymous with ground (by which I really do mean the stuff under your feet) is a definite voltage, it is not 'no voltage'.

SadBunny :- You know when you have a TV antenna and you plug it into a TV. That picks up a signal from nothing? Well yes in a way. It picks up traveling electromagnetic waves from the TV transmitter and delvers a voltage signal into the TV receiver circuit.

It picks up all sorts of frequencies but the design of the antenna makes it pick up some frequencies stronger than others. However, if you are not too far from the TV transmitter you can pick up the TV signal in just a piece of wire. The TV receiver amplifies certain frequencies more than others. The frequencies it amplifies most is the frequency the TV is tuned to.

Any wire will pick up signals from the air just like a TV antenna. Any form of alternating current can launch an electromagnetic wave, like the AC in the mains electricity wiring in your home. High impedance means it does not take much energy to make the picked up signal go from the voltage corresponding from a logic zero to a voltage corresponding to a logic one. This is what an electronic input does when it is not connected to anything, or as we say when it is floating.

Another thing to take in is that in normal conditions +ve and -ve charges balance out extremely accurately,
it only takes a very small amount of free charge to generate large voltages (such as static charges on nylon
and such).

Most low voltage electronics involves -ve electrons flowing in conductors made of +ve ions (metals),
or in semiconductors both +ve and -ve charges flowing in conductors made of either polarity of ions,
carefully arranged for specific effects.

The static ions in the metal or semiconductor effectively hold on to the mobile charges (although they
bounce around with thermal energy). But mobile charges can of course move, which is a net current
(even though the charges balance at any instant in time).

Work is done to move the charges, and moving charges can do work (you push at one end, all the charges
have to move more-or-less in lockstep - or more accurately you push round a circuit, there is no end
(except for antennas))