Maker Pro
Maker Pro

Beginner pull up resistor question

Jon Doe

Jul 7, 2014
6
Joined
Jul 7, 2014
Messages
6
Situation

http://imgur.com/DhMZwVa

Vs is 5V.
R1 is 10K ohms.

I've got this circuit hooked up to an Arduino Uno in an attempt to understand how pull up resistors work.
Pin 0 and Pin 1 are the analog inputs on the board which I'm using to measure voltage on the circuit.

Results

Pin 1 is always 0V.
Pin 0 is 5V when switch is open and 0V when switch is closed.

Problem
I don't understand why Pin 0 reports 5V when the switch is closed. I expected the resistor to eat up all of the voltage as it is the only active component.

I don't understand why Pin 0 reports 0V when the switch is open.

Putting the resistor on the other side of the switch gives me the expected results; 0V when switch is closed and 5V when it's open, but I don't understand why that works.

Edit: Flipped the pin reports like an idiot in the problem section, my bad.
 
Last edited:

davenn

Moderator
Sep 5, 2009
14,263
Joined
Sep 5, 2009
Messages
14,263
HI Jon
welcome to EP :)

am not an expert here ... OK

Pull up or pull down resistors are more commonly 1k or 4.7k
The purpose of the resistor is primarily to limit current going to the pin of the device ( logic gate, mpu etc)

Kris may chime in, it more his field than mine.
But in the mean time, I suggest you try a 1k and see if the results are what is expected :)


Dave
 

Jon Doe

Jul 7, 2014
6
Joined
Jul 7, 2014
Messages
6
Thanks for the welcome.

I switched the resistor for a 330 ohms one and got the same results. Not too sure what to think of this.
 

davenn

Moderator
Sep 5, 2009
14,263
Joined
Sep 5, 2009
Messages
14,263
pondering on this more .... I suspect there is interaction between the 2 inputs
in a real situation each input would have its own pull up or pull down resistor

Disconnect PIN1 from the arrangement and try again with a 1k to 4k7 resistor

with the switch open you should see near 5V on the input of pin0 and 0V when the switch is closed

The other thing I didn't really consider when originally reading your first post was that you said these were analog inputs
I'm not sure of the effects using resistors like that on analog rather than logic gate inputs ??

cheers
Dave
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
DhMZwVa.png
Pin 1 is always 0V.
Right, it will be, because it's connected to the 0V rail (represented by the earth symbol).
Pin 0 is 5V when switch is open and 0V when switch is closed.
That's also right.

I assume that's a battery at the left, and that its negative side is connected to 0V, correct?

When the switch is open, the resistor pulls pin 0 up to +5V. When the switch is closed, the switch overrides the pullup resistor, and pulls pin 0 down to 0V (GND).
I don't understand why Pin 0 reports 5V when the switch is closed.
According to your results, it doesn't. If it did, that would be wrong.
I expected the resistor to eat up all of the voltage as it is the only active component.
I'm not sure what you mean. Resistors are passive, not active. I think of resistors as being like springs - the tension type. If you connect a resistor to a positive voltage, it pulls its other end towards that voltage. You can pull its other end to a different voltage, which stretches it, but if you let it go, it will return to the higher voltage.
I don't understand why Pin 0 reports 0V when the switch is open.
According to your results, it doesn't.

It would help if you redrew the circuit diagram.

1. Keep the battery at the left side. Draw horizontal lines running along the top and bottom of the diagram, for +5V (or +3.3V or whatever it is) at the top, and 0V at the bottom.
2. Draw the Arduino as a box on the right. Show the connection from the 0V rail to the Arduino's 0V rail, and the connection from the 0V rail to pin 1.
3. Draw the resistor and the switch vertically, one above the other, across the +V and 0V rails, and draw the line from the junction of the resistor and the switch to pin 0 of the Arduino.
4. Label the battery voltage. Label the Arduino and the pin numbers. Label the resistor as R1. Label the switch as SW1.
 

Jon Doe

Jul 7, 2014
6
Joined
Jul 7, 2014
Messages
6
@kris: Sorry I accidentally flipped the values in the problem section. The problem is it all makes sense on paper and in theory but I can't make sense of why the voltage acts the way it does. My circuit is giving me the correct values that it should give but I don't understand why they are that way.

When the switch is open in my sketch, why does pin 0 report 5V and report 0V when the ground is introduced via closing the switch. It's as if the resistor doesn't exist when the 5V supply is connected straight to the micro-controller's analog input. From what I know the resistor should cause a voltage drop.

@Dave: I'm not sure what you mean by logic gate inputs but from what I can tell it's my circuit that's the problem because when I lay the circuit out as a YouTube video shows I get the values I should be getting.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
When the switch is open, it's as if it's not there at all. The resistor pulls up the voltage on pin 0 to 5V. It works like a spring or a rubber band. One end of it is connected to +5V and the other end goes to an input on the Arduino, which just "watches" the voltage without affecting it. So the resistor pulls that voltage up to +5V.

When you close the switch, the switch pulls pin 0 firmly down to 0V. This "stretches" the resistor (causes some current to flow in it) but this doesn't damage the resistor. That's what it's designed to do.
 

davenn

Moderator
Sep 5, 2009
14,263
Joined
Sep 5, 2009
Messages
14,263
Thanks for chiming in Kris :)

I'm afraid I wasn't reading all his comments correctly ( even with my new glasses haha)

Dave
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Here is what I think you are missing. There can only be a voltage across a resistor if there is current flowing through it, according to Ohm's law.

With a 10K resistor connected to 5V, the other end will read 5V as long as there is no current flowing. If there is current flowing it will read:

5 - 10000 * I

Where I is the current. A microprocessor input pulls around 1uA of current. So the voltage on it would be:

5 - 10000 * 1/1000000 = 4.99V.

Bob
 

Jon Doe

Jul 7, 2014
6
Joined
Jul 7, 2014
Messages
6
@BobK: You are definitely along the right track regarding what I'm confused about. In an analog circuit in which a 5V is connected to a resistor the resistor will have a Vdrop of 5V. In a digital circuit with a 5V connected to a resistor and then to a microcontroller the resistor hardly eats any voltage.

In a normal circuit we use V/R to determine the current of the circuit. Why do we instead use what the micro-controller pulls in the digital circuit rather than calculating V/R again?
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Think of the microcontroller input having a 5 Meg resistor connected to ground. This would cause 1 uA to flow when connected to a source of 5V. This is not actually the case, but it should help you visualize what is going on.

Let's look at it another way. Connect 1 end of a 10K resistor to 5V Connect the other end to the red lead of a multimeter set to read voltage. Connect the black lead to ground. What voltage to you expect the voltmeter to read? What does it actually read if you really do the experiment?

Bob
 

Jon Doe

Jul 7, 2014
6
Joined
Jul 7, 2014
Messages
6
Scenarios
A) 5V to 10K resistor. Simple analog circuit in which the resistor drops all the voltage; 5 - 5 = 0V remaining.
B) 5V to 10K resistor (resistor in parallel with voltmeter). Voltmeter will read 5V as that is the voltage drop from one end of resistor to the other.
C) 5V to 10K resistor to voltmeter. Voltmeter will read 0V. I think I've fallen for the trap here.

Experiment
A) 5V on one end of resistor 0V on the other. Drop is 5V as expected.
B) Voltmeter reads 4.75V, close enough. It's one of those old shitty meter types rather than digital.
C) Voltmeter reads 1.75V which I assume is supposed to be about 2V. This isn't what I expected but I guess it has to do with the VM having a resistor inside according to what you said.

Thoughts
I've had this window open for a very long time and wrote several calculations which I've deleted. At first I thought the resistor must be dropping 3V because the VM read 2V. Then I realized, that's not necessarily the case, but I'm not sure how to go about calculating anything.
 
Last edited by a moderator:

davenn

Moderator
Sep 5, 2009
14,263
Joined
Sep 5, 2009
Messages
14,263
C) 5V to 10K resistor to voltmeter. Voltmeter will read 0V. I think I've fallen for the trap here.

Yeah, voltmeters DONT go in series with a circuit ;)

Dave
 

Jon Doe

Jul 7, 2014
6
Joined
Jul 7, 2014
Messages
6
I think Bob was trying to show me how the voltage acts when it goes into a micro-controller by substituting a VM in its place.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Resistors don't "eat" voltage. They can (and usually do) have voltage across them, but only if current is flowing through them, as Bob explained.

If you connect one end of a resistor to +5V, and measure the other voltage with a multimeter (with its negative lead connected to 0V), you will measure almost the full 5V. The only drop across the resistor is caused by the small amount of current that flows into the multimeter.

If you disconnect the multimeter, the end of the resistor will be at exactly +5V, even though you won't be able to measure it.

You could say that a resistor converts current (being fed through the resistor) into a voltage (measured across the resistor), or that it converts a voltage (applied across the resistor) into a current (flowing through the resistor), with a constant ratio; this ratio is related to the resistance. This is shown by two arrangements of Ohm's Law:

I = V / R
V = I × R

In both cases, I (current through the resistor) and V (voltage across the resistor) are proportional to each other.

Voltages are always measured BETWEEN two points. Voltage is also called "potential difference". It is a difference between two points.

Current is always measured THROUGH a path. Current is a flow of electrons through a material. If you want to measure current with a multimeter, you need to break the path and connect the multimeter across the break, so that the current flows through the multimeter.


If you connect one end of a resistor to +5V and the other end to 0V, you are "forcing" 5V to appear across the resistor. As you would expect, you'll measure +5V on one end, and 0V on the other. (These measurements are made relative to the 0V rail.)

Applying 5V across a resistor causes current to flow in the resistor. Say it's a 1k resistor, i.e. R = 1000 ohms. Using Ohm's Law:
I = V / R
= 5 volts / 1000 ohms
= 0.005 amps
= 5 mA.

So you have 5 mA of current flowing through the resistor.

Re-read all of the explanations on this thread. I'm sure you will be able to get your head around it.
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
C) Voltmeter reads 1.75V which I assume is supposed to be about 2V. This isn't what I expected but I guess it has to do with the VM having a resistor inside according to what you said.
Ach! I wasn't expecting you to use an old analog voltmeter. If you had used a digital voltmeter, it would have read very close to 5V, probably 4.99. That is because the typical modern digital voltmeter has an input resistance of 1M. It looks like your analog VM had an input resistance of about 5K.

Bob
 
Top