Go Down

Topic: Pull-up or Pull-down? (Read 4708 times) previous topic - next topic

brianeo

I am experimenting with Example 02.DIGITAL - DigitalInputPullup. The subject of the example is using the pull-up resistor on the Arduino board to light the built-in LED. The only thing missing from the tutorial is lighting a LED not on the Arduino board. I mean, can I take your word for it that there really is a 10k resistor on the board, between the current, the LED, and the ground? It's kinda small.
I burned out several LEDs before it was explained to me that the current had to be reduced with a resistor. Accordingly, I always look for the resistor in any circuit using a LED. Now then, if the built-in resistor on the Arduino board diminishes the current, why not build a breadboard layout with a LED and no external resistor, for use with the DigitalInputPullup Example?
I rigged it and the breadboard LED lights when the button is pressed. My question is about my layout. Is it correct? See attached schematic. It shows the Example layout (with no external LED or resistor), and next to it is my layout, using an external LED, but no external resistor.
And one more thing: About the terms "pull up" and "pull down," I have a notion they refer to whichever side of the LED the resistor is on, the VCC or the GND. Which is my layout?

larryd

#1
May 30, 2017, 04:02 am Last Edit: May 30, 2017, 04:03 am by larryd



.
No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

larryd

#2
May 30, 2017, 04:05 am Last Edit: May 30, 2017, 04:06 am by larryd
Wire your LEDs/switches similar to one of these:



You need a resistor with pin 13 ~ 220 ohms.
.
No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

tinman13kup

You need to include a current limiting resistor for any external led you use. The uno has a 1k resistor right next to the led. If you look with a magnifying lens, you will see the number 102 on the black block next to it. The internal pullups are good for putting the pin in a known state (5v, HIGH) with no outside intervention. That switch in drawing 2 will place ground potential at the pin, dropping it to 0v(LOW). At the same time, the led is going to try and source it's current from pin 13. If pin 13 is just set as a high output, it will not be able to handle the current the unlimited led will pass, resulting in a burnt led or pin. If the pin was set to input pullup, it uses a 20kOhm resistor eq, so using ohms law, that comes out to 250uA.
Tom
It's not a hobby if you're not having fun doing it. Step back and breathe

Smajdalf

Pull-up resistor is resistor connected to supply voltage on one end and to "something" on the other. Pull-down resistor is connected to GND and "something".
It is possible to activate internal pull-up resistors on Arduino. It is as if you connected 20-50k resistor between 5V and the pin. This way you may drive LEDs without other resistor. But depending on your expectations and LED you use it may be too dim. Also it is a bit dangerous - if you configure the pin as OUTPUT HIGH by mistake, you may damage the LED and/or Arduino.
How to insert images: https://forum.arduino.cc/index.php?topic=519037.0

ElCaron

You are mixing up pull-up/down resistors (which ARE on the board) with current limiting resistors. (which are NOT on the board). They are in different position in the circuit. Also, the pull-up/downs are rather associated with a pin as an input, while current-limiting resistors are rather associated with a pin as an output.*
They are both explained here: http://forum.arduino.cc/index.php?topic=480358.0


* Current-limiting does not make sense for an input alone, since it is already very high impedance. The resistor will not matter. It might still be used e.g. with a clamping diode to protect the input.
Pull-up/down resistors do not make sense with an output, since they are overridden by the output. It might still be used set the pin to a defined state while the MCU is e.g. starting or being flashed. A good example for this is the CS pin of an SPI connection. While it is common in the Arduino community to just put a wire between the two pins, this practice might totally ruin your day when you plan a PCB without the pullup and you intend to flash via ICSP, which might not work if the SPI device thinks it is enabled due to a floating CS pin. Practical example (where I learned this): ATMEGA328P + RFM69 radio.

MarkT

You are mixing up pull-up/down resistors (which ARE on the board) with current limiting resistors. (which are NOT on the board).
That doesn't make any sense to me:

There are pullups on the _chip_ for each pin, and there is a current limiting resistor on the board (ie the PCB)
for the LED driven from pin 13.

There are also pull-ups on RX and TX on the pcb I believe.  These prevent noise on those pins confusing
the bootloader at power up.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

ElCaron

#7
May 30, 2017, 04:48 pm Last Edit: May 30, 2017, 04:48 pm by ElCaron
Ok, correction:
You are mixing up pullup/down resistors (pullups ARE on the chip, which is on the board) with current limiting resistors. (which are NOT on the board, except in the circuits that contain LEDs of course).

Quote
There are also pull-ups on RX and TX on the pcb I believe.  These prevent noise on those pins confusing
the bootloader at power up.
I did mention that use case in the footnote, with the example of an SPI connection.

Smajdalf

Ok, correction:
You are mixing up pullup/down resistors (pullups ARE on the chip, which is on the board) with current limiting resistors. (which are NOT on the board, except in the circuits that contain LEDs of course).
Strictly speaking you are right. But resistor is still resistor: internal "pull-up resistors" may be used as current limiting resistors to power LEDs/transistor bases or any other light load.
How to insert images: https://forum.arduino.cc/index.php?topic=519037.0

ElCaron

Strictly speaking you are right. But resistor is still resistor: internal "pull-up resistors" may be used as current limiting resistors to power LEDs/transistor bases or any other light load.
Ok, I see that you could do that. I actually had to dim the power LED of my media center with a 10k resistor to avoid lighting the living room with it. So I guess the 20kΩ and 50kΩ of an Arduino pullup could be used to run an LED. So strictly speaking YOU are right, but is that a hack/usecase common enough to confuse a newbie with it here, or should we stay to the basic overview (which I even amended with some exceptions)?

CrossRoads

There is an internal to the '328P pullup resistor for each pin.
There are No pulldown resistors.
There are No current limit resistors between any pin and the IO connectors.
There is No current limit resistor between D13 and the L LED. D13 drives a comparator, the comparator output has a current limit resistor for driving the L LED.

The Rx and Tx LEDs are driven by the USB/Serial adapter chip, not by any of the '328P outputs.

The Rx and Tx pins are pulled high by the output of the USB/Serial adapter chip; there are not pullups to the 5V supply.  There are 1K series resistors between the USB/Serial adapter and the D0/D1 pins, thus when then 328P wants to drive those lines as outputs it needs to sink 5mA to overcome the high level of the USB/Serial adapter (5V/1000 = 5mA), and any external devices driving D0/D1 must similarly be able to overcome the 5mA pullup to pull the lines low. Going high, the 1K pullup helps the line go high.

This is wrong: "internal "pull-up resistors" may be used as current limiting resistors to power LEDs/transistor bases or any other light load." All the internal pullups will do is very weakly light an LED if the pin is set to an input and the LED Anode is connected to the pin and the cathode to Gnd. If the pin is set to an Output and there is no external current limit resistor, the IO pin or the LED will be damaged eventually. And maybe sooner rather than later.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Smajdalf

This is wrong: "internal "pull-up resistors" may be used as current limiting resistors to power LEDs/transistor bases or any other light load." All the internal pullups will do is very weakly light an LED if the pin is set to an input and the LED Anode is connected to the pin and the cathode to Gnd. If the pin is set to an Output and there is no external current limit resistor, the IO pin or the LED will be damaged eventually. And maybe sooner rather than later.
It is possible to activate internal pull-up resistors on Arduino. It is as if you connected 20-50k resistor between 5V and the pin. This way you may drive LEDs without other resistor. But depending on your expectations and LED you use it may be too dim. Also it is a bit dangerous - if you configure the pin as OUTPUT HIGH by mistake, you may damage the LED and/or Arduino.
It greatly depends on the LED driven and circumstances. For example I have some blue LEDs that are too bright when driven with 5V and 1k resistor. Driven by internal pull-up they look just fine. They may be hardly visible in direct noon sunlight but in room I never had problems. The same is true for my red LEDs. But I have green and yellow LEDs and they are hardly visible when driven by internal pull-up.
How to insert images: https://forum.arduino.cc/index.php?topic=519037.0

brianeo

Fascinating thread. I expected no less. Looks like back to the lab for me, but there are two points I take with me.
1. Use a resistor with a LED, that is, don't depend on the internal pullup resistor.
2. The point of the tutorial Example 02.DIGITAL - DigitalInputPullup is how to use the internal resistor to prevent the switch from floating.
I am trying my best to leave it at that, although I have as many questions revolving around the topic for several posts.

tinman13kup

1. Use a resistor with a LED, that is, don't depend on the internal pullup resistor.
2. The point of the tutorial Example 02.DIGITAL - DigitalInputPullup is how to use the internal resistor to prevent the switch from floating.
I am trying my best to leave it at that, although I have as many questions revolving around the topic for several posts.
That sounds like good practice to me. Maybe down the road after you are up to speed on sinking/sourcing current and the limitations of both (component dependant items), you might find a viable reason to use the input pullup as a source, but you might be hard pressed to find a good reason to, as setting the pin as an output can source 20mA instead of >250uA. Most things that need current limiting require more specific resistances to meet the application.
Tom
It's not a hobby if you're not having fun doing it. Step back and breathe

INTP

#14
May 31, 2017, 06:10 am Last Edit: May 31, 2017, 06:11 am by INTP
Maybe the confusion is coming from overlooking the distinction that the pullup resistors are not in series while a resistor used to limit current is in series with the LED in question.

Go Up