2

Please help me something that I don't understand:

Why is there a need for pull-down resistors in the circuit below with push button if the ground has already zero voltage? This is the only thing I find confusing in them.

enter image description here

Circuit fantasist
  • 16,664
  • 1
  • 19
  • 61
Voloo
  • 21
  • 2
  • 2
    it's unclear what you are asking. draw a circuit and add it to your question – Jasen Слава Україні Oct 19 '23 at 02:55
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 19 '23 at 04:58
  • @Voloo, Really, try to formulate your question more clearly because it is in danger of being closed. If you need it, we will help you. – Circuit fantasist Oct 19 '23 at 12:51
  • 1
    In the picture i dont understand the purpose of the resistor (what it does), because there is no current so gpio 14 should read always low. – Voloo Oct 19 '23 at 16:05
  • @Voloo, See the schematics (simulations) 4.2.1 and 4.2.2 in my answer below. Please, give me some feedback about the written. Explain what is still unclear. Oh, I forgot about that 50 reputation limit... how does that bother me... – Circuit fantasist Oct 19 '23 at 16:55
  • 1
    @Circuitfantasist - Hi, (a) While I support an OP giving relevant feedback on answers, there is no obligation for them to do so. Also, since the site disallows chitchat & empty "thank you"-type comments, any comments should comply with that linked explanation, or not be written at all. (b) "Oh, I forgot about that 50 reputation limit" That doesn't apply in this case - an OP can always write comments to posts on their question. See that page I linked where it says: "All users may comment on their own posts and any answers to their own questions." – SamGibson Oct 19 '23 at 17:18
  • @SamGibson, Thanks! That solves the problem. – Circuit fantasist Oct 19 '23 at 17:23
  • 1
    Does this answer your question? Pull Down Resistors – Maple Oct 19 '23 at 23:03

4 Answers4

4

You could think this analogy to understand the pull-up (or pull-down) function:

source: personal class notes + itecnotes.com

When you don't connect your input to "something" (i. e. you have a floating input), the voltage remains undefined. In order to ensure that there will be some voltage level defined you have to leave the input pin connected to something.

To avoid a short circuit, you make the connection through a pull-up or pull-down resistor. So, when you press the button, you are imposing the voltage level that does not come from the resistor and without producing a short circuit. And while you release the switch and leave the input pin node unconnected to it, you ensure that the other node will impose the other voltage level through the resistor.

The value of the resistor must be chosen wisely. A high value produces a low current comsumption but the slew rate and the transient between changes will be higher than the one that would be obtanied with a lower value. For typical applications, 10 kohms is ok; consider 1kohm for a high speed changing input and 100kohms for a low speed changing input.

coal
  • 81
  • 5
  • 4
    That first image is either confusing, or wrong, or talking about something different - possibly the effect of NC vs NO switches – MikeB Oct 19 '23 at 13:32
  • 1
    @MikeB No, it is not wrong. It's just an analogy between pull-up resistor and a spring that ensures the input will go up when switch is not pressed. Just an analogy, like every analogy it has its flaws – coal Oct 19 '23 at 15:40
  • 4
    @coal The picture implies that the input would always be read as low without a pull-up resistor. This is not true; most TTL chips will read unconnected inputs as high, and CMOS chips will read randomly (which is why you should never leave CMOS inputs floating). – Hearth Oct 19 '23 at 20:31
  • 1
    While the idea to make an analogy with mechanical pull force is interesting, it breaks down for the reasons @Hearth provided – Maple Oct 19 '23 at 20:44
  • 1
    Well, the picture does NOT exempt you from reading the whole answer. "When you don't connect your input to something, the voltage remains undefined". That's all, I've never said the input remains on a low level when the pull-up is absent. You use pull-down or pull-up to leave the voltage level defined, end of the story. If you don't like the analogy, you could downvote or propose a better one – coal Oct 19 '23 at 21:48
  • @coal Except it doesn't remain undefined either. It depends on the logic family you're using. – Hearth Oct 19 '23 at 23:45
  • @Hearth I wouldn't assume that the voltage will remain defined. Even if it was TTL I would use a pull-up or pull-down anyway. Assuming it will be defined is a bad practice; so for a simple explanation the word undefined is perfect – coal Oct 20 '23 at 03:02
  • 1
    @coal Even if you accept that, the picture you've used directly contradicts that with the wording "switch released: reads '0'" in the top left. – Hearth Oct 20 '23 at 04:02
3

To see the forest...

I will take this opportune moment to summarize the idea of ​​"pull-up" and "pull-down" resistors in a "philosophy". This will help us to make a connection between different (at first glance) specific circuit solutions and thus understand them better.

The problem

The point here is how to switch two voltages (eg 10 V and -10 V) to one input using a simple 2-terminal (SPST) switch. The usual solution is to use a 3-terminal (SPDT) switch, which first disconnects one voltage from the input and then connects the other voltage to the input.

V1 connected, V2 disconnected

schematic

simulate this circuit – Schematic created using CircuitLab

V1 disconnected, V2 connected

schematic

simulate this circuit

However, electronic switches (transistors) only have two terminals, and because of this, they long ago figured out how to make them switch two voltages. And here is what they came up with.

Basic idea

Instead of switching between two "strong" ("ideal") voltage sources with zero internal resistance, we can deliberately weaken one of them (by connecting a resistor in series) and simply connect the other to it. Thus the "strong" voltage source will dominate and impose its voltage so it will be applied to the input.

"Pull-up" resistor

If we connect the resistor to the positive voltage source V1, figuratively speaking, it will "pull up" the output (trying to increase its voltage), and if SWdown is open, it will succeed...

schematic

simulate this circuit

... but if SWdown is closed, the latter will "pull down" the GPIO to V2 (-10 V).

schematic

simulate this circuit

"Pull-down" resistor

If we connect the resistor to the negative voltage source V2, it "pulls down" the output (trying to decrease its voltage), and if SWup is open, it will succeed...

schematic

simulate this circuit

... but if SWup is closed, the latter will "pull up" the GPIO to V2 (10 V).

schematic

simulate this circuit

Analog applications

Resistor subtractor

Inverting op-amp amplifiers use a configuration of two real voltage sources "pulling" the output in different directions (something like a "tug of war"). As a result, a virtual ground appears at the output.

Vin1 > Vin2: V1 "pulls up", and V2 "pulls down" Vout.

schematic

simulate this circuit

Vin1 < Vin2: V1 "pulls down", and V2 "pulls up" Vout.

schematic

simulate this circuit

Diode limiter

The same idea of "dominating ideal voltage source" can be seen in diode limiters where diodes play the role of switches.

Vin > Vref: The "stronger" forward-biased diode D directly connects Vin to the output.

schematic

simulate this circuit

Vin < Vref: If backward-biased, the "weaker" diode disconnects Vin from the output, and the latter remains connected to Vref.

schematic

simulate this circuit

Vin = -10 V ÷ 10 V: As you can see in the graph below, in the region from -10 V to 1 V, the output voltage is limited to the value of the reference voltage (-2 V); after that, it follows the input voltage.

STEP 3.2

Digital applications

Let's finally consider the OP's digital application of this idea.

"Pull-up" resistor

The grounded switch (push button or open collector transistor) can be thought as an "ideal" voltage source...

schematic

simulate this circuit

... producing zero voltage when closed.

schematic

simulate this circuit

"Pull-down" resistor

Similarly, the grounded "pull-down" resistor (the OP's circuit) can be considered as a real voltage source...

schematic

simulate this circuit

... producing zero voltage, and applying it through a resistance to the output.

schematic

simulate this circuit

OP's wondering

In the picture i dont understand the purpose of the resistor (what it does), because there is no current so gpio 14 should read always low.

The OP's problem is now being clarified - it is about the role of the pull-down resistor and if it can be done without it. I prefer, instead of repeating the usual explanations, to demonstrate it with experiments (simulations).

Experiments

To see the benefit of the resistor, we need to examine the circuit in the presence of disturbance (leakage) - first, without a pull-down resistor, and then with the resistor. We can simulate the leak by means of a high (10 MΩ) resistor Rleak. Also, we can simulate the input resistance of the GRIO by setting such a high resistance (10 MΩ) in the CircuitLab parameters panel of the voltmeter.

No pull-down resistor: As you can see, in this case, Rleak and RGPIO form a voltage divider of two equal resistances of 10 MΩ with a ratio of 0.5. So, half of Vcc (2.5 V) is applied to GPIO, and not 0 V as you think.

schematic

simulate this circuit

Pull-down resistor: Now let's connect the 1 kΩ Rdown. The divider's ratio decreases 10,000 times so only 0.5 mV (practically zero) is applied to GPIO.

schematic

simulate this circuit

Circuit fantasist
  • 16,664
  • 1
  • 19
  • 61
  • 1
    17 pictures on six pages to explain so simple concept?! Hope OP will not hate electronics after all this. – Maple Oct 19 '23 at 20:43
  • 2
    @Maple, I would ask you this: Do you ever wonder why, with such a simple concept, such questions are constantly being asked? Schematics are many because these are "unfolded" step-by-step "live" experiments with visualized electrical quantities and numerous related applications. I don't see how you can hate something that opens your eyes; I would rather hate boring, formal and sterile textbook "explanations" that actually don't explain anything. But I'm not mad and thank you for your reaction; I prefer that to silence. – Circuit fantasist Oct 19 '23 at 21:21
  • 1
    ... I will use the occasion to further explain why many schematics are obtained. They are working simulations of a demonstrative nature that can be combined and thus reduced. But it seems to me that most OPs have no particular desire to experiment with device parameters, modify schematics, etc. Therefore, I break them into separate versions with different combinations of device parameters constantly experimenting and improving myself in this endeavour... – Circuit fantasist Oct 19 '23 at 21:34
2

The inputs of most microcontrollers and CMOS digital logic are extremely high impedance. They do not source or sink any significant current but sense the input voltage to decide the logic level.

If such an input is left unconnected it may acquire static charges causing its voltage to drift around between Ground and the positive supply. A pull-down resistor is used to ensure that an otherwise unconnected input is held at a valid Low logic level, but still allow it to be taken High when needed. Similarly, a pull-up resistor will hold an input High, but will allow it to be taken Low when desired.

It is important to realize that "no connection" does not necessarily mean "zero volts".

Peter Bennett
  • 59,212
  • 1
  • 49
  • 132
1

Contrary to what you say, the button has no ground except through the pull-down.

If you omit the pull-down, the GP14 will see 3.3V as logic high when button is pushed, but the problem is, when the button is not pushed, the GP14 will be connected to nowhere, so it is floating node and there is no well-defined potential.

And that is not allowed as the input can read it as pushed or not pushed, it is undefined and unreliable.

So the 3.3V voltage is provided to GP14 through button when it is pushed, and when button is not pushed, the resistor provides 0V ground to GP14.

Justme
  • 147,557
  • 4
  • 113
  • 291