Go Down

Topic: What if I use 230 ohm resistor with 5V input to Ground? (Read 5478 times) previous topic - next topic

jack wp

"If you are sensing a push button, the pin MUST be configured as an INPUT, therefore
you can short it directly to 5V or GND "


I beg to differ:
If your switch will short it directly to 5V, then the other side of the coin is,
" short it to GND, leave it floating, or use a small pull down resistor".

The default being shorted to ground, nor leave it floating will not be a functional option.
So, use a small pull down resistor is the only viable option.
I could be mistaken tho.

bsld

Arduino GPIO pins have two modes (INPUT or OUTPUT).
When configured as an INPUT, the pin becomes a high impedance (100 Mohms) input)
If you are sensing a push button, the pin MUST be configured as an INPUT, therefore
you can short it directly to 5V or GND  without using any power to speak of . What you CAN'T do is connect the push button IN BETWEEN 5V and GND and then push the button because you will short your 5V power supply. Thus, ANY DISCUSSION OF POWER CONSUMPTION OF AN I/O PIN CONFIGURED AS AN INPUT is completely irrelevant and non valid. Such a discussion would only  be appropriate for a pin configured as an OUTPUT .

Do you understand the significance of a input impedance of 100 Mohms ?

If you are discussing the power consumption of a 10k ohm pullup resistor, it depends on WHAT you connect that input pin to. By itself , an INPUT pin with a 10k pullup is part of a voltage divider with 10k in the upper position and 100 Mohms in the lower position. Any discussion of input pin power consumption would have to be based on the circuit that you connect to that input pin.
So what are you saying is that I can directly connect the 5V through switch into the Input pin because it have high resistance?

But why is the example linked here so complicated then?

Also what will happen if I press the button before the 'setup' function executes or if I mistakenly don't configure the pin as INPUT?

ApexM0Eng

#17
Aug 05, 2015, 09:25 pm Last Edit: Aug 05, 2015, 09:30 pm by ApexM0Eng
Also what will happen if I press the button before the 'setup' function executes or if I mistakenly don't configure the pin as INPUT?
Arduino pins are defaulted to inputs, which is a safe state.

Consider wiring two inputs to each other. Nothing happens as both expect but don't receive.
Consider wiring two outputs to each other. The pins are now trying to source current into each other which is bad.

Default inputs is safe.

Also if your pushing the button prior to the setup function, the pin will sink current, but nothing will happen. The MCU is safe and will wait for your code to tell it to do something with it's current pin state.

https://www.arduino.cc/en/Tutorial/DigitalPins

This explains further on pins and why pull-ups/pull-downs are necessary.

raschemmel

#18
Aug 05, 2015, 09:31 pm Last Edit: Aug 05, 2015, 09:35 pm by raschemmel
Quote
The default being shorted to ground, nor leave it floating will not be a functional option.
So, use a small pull down resistor is the only viable option.
I could be mistaken tho.
Think about it.
The input pin represents a 100 Mohm resistor to ground.
The pullup /pulldown resistor is out of the circuit UNLESS the button is pressed.
This means the pullup/pulldown resistors are not conducting any current unless you press the button.

CASE -A (230 ohm pullUP resistor)
button open => no current
button pressed => (230 ohm resistor across 5V and GND => 21mA/0.1W consumed


Quote
or use a small pull down resistor".
I think you mean use a LARGE pulldown resistor. (230 ohm is already way too SMALL)
A pullup/pulldown resistor should be  10k >= optimum <= 50k

230 is a value NO ONE with any electronics experience would ever consider using unless it was LITERALLY the ONLY OTHER resistor they had available. PERIOD

CASE-B(230 pullDOWN resistor)
button open => no current
button pressed => (230 ohm resistor across 5V and GND => 21mA/0.1W consumed

Quote
Consider wiring two outputs to each other. The pins are now trying to source current into each other which is bad.  
This topic is about an INPUT pin. The above comment is not relevant to this topic.


Quote
Also what will happen if I press the button before the 'setup' function executes or if I mistakenly don't configure the pin as INPUT?
That's EXACTLY WHY no one would ever consider using such a low value as a pullup/pulldown resistor.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

bsld

Think about it.
The input pin represents a 100 Mohm resistor to ground.
The pullup /pulldown resistor is out of the circuit UNLESS the button is pressed.
This means the pullup/pulldown resistors are not conducting any current unless you press the button.

CASE -A (230 ohm pullUP resistor)
button open => no current
button pressed => (230 ohm resistor across 5V and GND => 21mA/0.1W consumed


I think you mean use a LARGE pulldown resistor. (230 ohm is already way too SMALL)
A pullup/pulldown resistor should be  10k >= optimum <= 50k

230 is a value NO ONE with any electronics experience would ever consider using unless it was LITERALLY the ONLY OTHER resistor they had available. PERIOD

CASE-B(230 pullDOWN resistor)
button open => no current
button pressed => (230 ohm resistor across 5V and GND => 21mA/0.1W consumed

This topic is about an INPUT pin. The above comment is not relevant to this topic.


That's EXACTLY WHY no one would ever consider using such a low value as a pullup/pulldown resistor.
What about my first question - can I directly connect the 5V through switch into the Input pin and will it work that way?

Because you've said that the input pin have it's own resistors.

ApexM0Eng

Assuming you haven't enabled the internal pull-up resistors? It will work, but not well. They have very high impedance as inputs but that also means they are very sensitive. So if you leave a pin "floating" (not connected to anything when the button isn't pressed) it will give off random values. Often messing with your program.

raschemmel

#21
Aug 05, 2015, 09:44 pm Last Edit: Aug 05, 2015, 09:47 pm by raschemmel
Quote
Because you've said that the input pin have it's own resistors.  
That isn't exactly what I said. I said the input has an equivilent input impedance of 100 Mohms. If you use internal pullups they are 50k ohms.
With an input impedance of 100 Mohms, 5V connected directly to the pin would draw

I= V/R = 5V/100 Mohms = 0.00000005 A (50 nA)

Can you handle that ?

Quote
Assuming you haven't enabled the internal pull-up resistors? It will work, but not well. They have very high impedance as inputs but that also means they are very sensitive. So if you leave a pin "floating" (not connected to anything when the button isn't pressed) it will give off random values. Often messing with your program.  
A floating pin will be read as a "0" (LOW).
An input should never be left floating. A pullup or pulldown resistor (10k or larger) should be used.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

jack wp

I beg to differ:
"Think about it.
The input pin represents a 100 Mohm resistor to ground.
The pullup /pulldown resistor is out of the circuit UNLESS the button is pressed.
This means the pullup/pulldown resistors are not conducting any current unless you press the button.
"


The input pin represents a 100 Mohm resistance, not necessarily to ground, but to input signals. If this ls left floating, there can be triggers above and below the threshold to represent a high, and a low signal.

The pullup/pull down resistor is only out of the circuit when the button is pressed.

The pullup/pulldown resistors  are providing the voltage level only while the button is not pressed. Then the button overrides them once pressed.
As I see it.

raschemmel

Quote
The input pin represents a 100 Mohm resistance, not necessarily to ground, but to input signals.
You're misinformed.

The definition of input impedance is the resistance seen to GND . The resistance seen from the input pin to ground is about 100 Mohms.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

jack wp

@raschemmel, then that would mean that a digital input that is not connected to anything would always read a low?   Not what I had understood before.  Is that right?

Grumpy_Mike

Quote
then that would mean that a digital input that is not connected to anything would always read a low? 
No that is not right. You have misunderstood what raschemmel said.  A floating input can read anything due to pickup.

raschemmel

Quote
@raschemmel, then that would mean that a digital input that is not connected to anything would always read a low? 
There was a discussion about this in another thread about a year ago so out of curiousity
so I wrote a loop to read some floating inputs and print the values to the serial port and it was always low . That doesn't mean that would always be the case but that's what I saw. I think you have to keep in mind that 100 Mohms is not your typical pulldown resistor.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

jack wp

There seems to be a lot of misunderstanding going on here. I am going to back away for now, and check back when the smoke clears. Good luck.

raschemmel

#28
Aug 05, 2015, 11:30 pm Last Edit: Aug 05, 2015, 11:31 pm by raschemmel
There is no misunderstanding.
I have been working in electronics for over 30 yrs and Mike has over 40 yrs experience. The definition of input impedance hasn't changed  and it's still a bad idea to leave uC inputs floating. If there is any misunderstanding it is at your end.

Quote
To calculate the input impedance, short the input terminals together and reduce the circuit by determining the equivalent circuit with only one component.
In this case, the one component is a 100 Mohm resistor.  (ZL (from the pin to GND))

Input Impedance


Is it a bad idea to leave micro-controller inputs floating ?
Quote
Problem:
Leaving a pin configured as an input floating is dangerous simply because you cannot be sure of the state of the pin. Like you mentioned, because of your circuit, your pin was sometimes LOW or sometimes in no-man's land or could sometimes go to HIGH.

Result:
Essentially, the floating input WILL definitely cause erratic chip operation or unpredictable behaviour. I have noticed some chips froze by simply moving my hand closer to the board (I wasn't wearing a ESD wrist band) or some would have different startup behaviour each time the board would powerup.

Why:
This happens simply because if there is external noise on that pin, the pin would oscillate, which would drain power as CMOS logic gates drain power when they switch states.

Solution:
Most micros nowdays have internal pullups as well, so that could prevent this behaviour from occuring. Another option would be to configure the pin as an output so it does not affect the internals.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

runaway_pancake

bsld,

1) in setup() you need:
  pinMode (X, INPUT_PULLUP);  // X is your input pin of choice
2) place your switch between that input pin and Ground.
3) Done

Assuming you have a Normally Open switch, you will look for a LOW when the switch is closed/activated.
That's how it works.
"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!

Go Up