Pull up > pin/ground

Hello,

I think I've grasped the concept of pull down resistor, but not pull up resistor...
Why does current flows to ground, rather than input pin when the switch is closed?

Are potential differences between Vcc and input pin when switch is open; Vcc and ground when switch is closed the same?

PinMode() instruction activates built-in pull up resistor is there a link with that high impedance and the lazy current?

Thanks

If you think of the input pin as a very high value resistor, the pull-up resistor arrangement would look like this:

Think about what is happening in this circuit when the button is open or closed. What would the voltage at Vin be in both circuits, given Vin is 5V? Hint: use Ohms Law or the voltage divider rules, or just common sense.

btns.png

I'm afraid I don't understand your first question.

Anyway, a pull-up resistor puts an high-impedance input, at Vcc . As there is no current passing through, the voltage at the input is the same as Vcc. When the input is LOW, the voltage on this pin is 0V (GND), and there is now a current through the pull-up resistor ( i = Vcc/Rpull-up) . This current is low, because the resistor value is about 20k
So , you put a pull-up resistor if you want your input to be HIGH without input signal, and you put a pull-down resistor if you want it to be LOW without signal. Don't put both, you'll just make a voltage divider :wink:

Without pull-up or pull-down, the input is in an inderteminate state when no signal comes.

Yes, you could put a pull up resistor, OR a pull down resistor (not both). Just so happens the CPU has decided to provide pull up resistors, So unless you want to add external resistors, go with the flow, and allow the internal pull up resistors when needed.

So, if I understand Majenko the current flows to ground because of the built-in high resistor?

What matters with an input is not the current that flows (an input is so high impedance hardly any current flows into it), but the voltage at the input. In the two circuits the voltage at Vin is, when the button is closed: 0V (it is connected direct to ground, so it will always be 0v regardless of any resistors), and when the button is open: 4.95V. This can be proved a number of ways.

  1. Ohms law:

The current flowing through the circuit is the voltage (5v) divided by the total resistance (1010000?), which is 0.00000495A. The voltage drop across the top resistor is the resistance (10000) multiplied by the current flowing through it (0.00000495A), which is 0.04950495. Subtract that from the total voltage (5V) and you have 4.95049505V.

  1. Voltage divider:

Vout = R2/(R1+R2)*Vin = 1,000,000 / (1,000,000 + 10,000) * 5 = 1,000,000 / 1,010,000 * 5 = 4.95049505

So with the button open the voltage is above the threshold for a high input, and so a high is registered. With the button closed the voltage is below the threshold for a low input, and so a low is registered.

What is the pull up the 1 Mohms resistor?

Is it the built-in resistor? And what's the second 10Kohms?

No current at all flows through the pull up resistor, or a only small amount?

Please...

keyz01:
What is the pull up the 10 Mohms resistor?

Is it the built-in resistor? And what's the second 10Kohms?

Please...

there is no 10Mohm resistor, it's a 1Mohm , and it is not a pull-up resistor, it is the input resistance

There is no second 10Kohm , Majenko made 2 schematics, representing the same input in both states , OFF an ON

I see no 10 Mohm resistor.

The 10 kohm is the pull up resistor. See it is attached to VCC ?

There are several good web sites that explain basic electronics. If you don't yet have a grasp of basic electronics, maybe you would benefit from some of those sites.

1 Mohms sorry, so what's this 1Mohms?

I visited tons of sites, and I don't avance...

alnath already stated

it's a 1Mohm , and it is not a pull-up resistor, it is the input resistance

I am sorry, but this forum is not to teach basic electronics. It is for arduino related questions.

Vin is 0V ; and ground is 0V too.
They are both connected to ground, that's why I don't understand why the microcontroller sees a potential difference.

http://www.seattlerobotics.org/encoder/mar97/basics.html

When switch S1 is open (off), pin 1 is tied to Vcc through the resistor. Since pin1 is a high impedance input, a voltage meter or logic probe placed on pin 1 will show Vcc (+5v) if connected to pin 1.

When switch S1 is closed (on), pin 1 has a direct connection to GND, which takes it to the low state. The pin1 side of R1 also has a direct connection to ground. Current will flow from Vcc, through R1, and to ground. It isn't considered a short, however, because R1 will limit the amount of current that can flow to a very small amount.

Looks like you have it figured out now. Congratulations.

jackwp:
Looks like you have it figured out now. Congratulations.

Except that was just a quote from the page he linked to.

Vin is only 0V when the button is pressed. When it is not pressed it is 4.95V.

At 5:29, it exposes my problem; I figured out that arduino's internal resistance helps to push the current into ground.(Current takes the path of less impedance)

"The reason it decides to flows to ground as rather into the microcontroller."

(Current takes the path of less impedance)

No, that is a common misnomer.

The current is split between paths according to the ratio of two resistances. If one of those paths is a dead short then the ratio is 1:0. If the resistances are the same the ratio is 0.5:0.5

1 Like

actually, afaik, the impedance of an I/O atmega328 configured as input is about 100MOhm, no current actually goes through it . Which means that, without a pull-up or a pull-down resistor, Vin is at a floating value, depending on the environment... if you touch it etc.... that's why you need either a pull-up or a pull-down resistor.

alnath:
actually, afaik, the impedance of an I/O atmega328 configured as input is about 100MOhm, no current actually goes through it . Which means that, without a pull-up or a pull-down resistor, Vin is at a floating value, depending on the environment... if you touch it etc.... that's why you need either a pull-up or a pull-down resistor.

I'm not sure what it is, but it's certainly very high. I chose 1M? purely as an illustration and to keep the numbers reasonable.

But the reason why arduino's pin reads value 0 volt, rather than 5 volts when push button is closed, is because of this internal resistor.

If there wasn't this resistance it would read a 5 volts, 'cause the switch output and input pin are both connected to 0 volt(ground).