AVR input with internal pull up

Go To Last Post
21 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am experimenting with AVR (ATMEGA 88PA) and wonder why a specific scenario occurs. I have a pin set as input and I have enabled internal pull up resistor. However, if I connect an led (anode to pin and cathode to ground), I see it is lit. So it seems internal pull up sinks current. Is it true?

This topic has a solution.
Last Edited: Tue. Jul 14, 2020 - 03:09 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

NO, it sources current to a load that is grounded (in this case an led ...must be a pretty weak led to get lit from a pullup).  Are you sure you didn't accidentally set the port as an output (in other words,if you were hoping to study pull up, maybe you are actually not doing so).

 

It could possibly sink current from a load that is above the supply rail, but that either:

  •  wouldn't actually work (because it is not really a resistor pullup)
  •  would damage the AVR (because pins should not try to be pulled above the supply rail) [except HV programming pins]

 

An overdriven led will be dim, once you burn it out from a lack of a series resistor!!

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Mon. Jul 13, 2020 - 12:56 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is this a connection?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

 

 

avrcandies wrote:
NO, it sources current

Indeed; eg:

 

 

 

https://startingelectronics.org/articles/current-sourcing-sinking/

 

 

avrcandies wrote:
must be a pretty weak led to get lit from a pullup

"sensitive" might  be a better word?

 

Modern LEDs can be pretty sensitive - it is certainty possible to get a (dim) glow from an LED via a microcontroller pullup ...

 

EDIT

 

picture

 

#SourceSink #SourcingSinking

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Mon. Jul 13, 2020 - 08:58 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Also note for the SINKING case (as previously mentioned)  the pullup can only sink if the load is connected to something higher than Vcc (here, +5V), for example 9 V.

However this is not recommended & in fact might not even work  (the pullup may actually be an "active resistor").

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

All the answers are correct and the circuit is exactly like in the replies. Even then, the voltage measured between the pin and ground was 2.9V (with the red multimeter probe connected to the input pin and black on the ground). Is that expected? I had a series of 10K resistor, is that an issue?

Last Edited: Mon. Jul 13, 2020 - 10:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I don't understand the situation in the text.
Please explain with a circuit diagram. Freehand drawings are also fine.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kabasan wrote:
Please explain with a circuit diagram. 

Yes - always!

 

Trying to explain circuit connections in words is never a great approach - especially when there's also a language barrier.

 

This is exactly why we have schematics!

 

For instructions on how to put a picture in your post, see Tip #1 in my signature, below:

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

babu.james@live.in wrote:
Even then, the voltage measured between the pin and ground was 2.9V (...). Is that expected?

 

Who knows? You didn't even tell us at what VDD the chip is running. If VDD is 2.5V and you measure 2.9V on a pin I would say, yeah that's very strange indeed cheeky

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

El Tangas wrote:

babu.james@live.in wrote:
Even then, the voltage measured between the pin and ground was 2.9V (...). Is that expected?

 

Who knows? You didn't even tell us at what VDD the chip is running. If VDD is 2.5V and you measure 2.9V on a pin I would say, yeah that's very strange indeed cheeky

 

VDD is 5V

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

We are still waiting for you to provide a schematic, please !

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

babu.james@live.in wrote:
VDD is 5V

babu.james@live.in wrote:
 I had a series of 10K resistor

Way too high!

 

More like 1k at 5V

 

See 'Calculating an LED resistor value' here:  https://electronicsclub.info/leds.htm

 

 

But we still need to see your schematic.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

We are still waiting for you to provide a schematic, please !

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

babu.james@live.in wrote:
VDD is 5V

babu.james@live.in wrote:
 I had a series of 10K resistor

Way too high!

 

More like 1k at 5V

 

See 'Calculating an LED resistor value' here:  https://electronicsclub.info/leds.htm

 

 

But we still need to see your schematic.

 

But the LED does glow enough to be seen. When you say too high, is it too high for the LED to glow or too high that causes it to glow?

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Thanks.

 

Note that, when drawing schematics, it is conventional to have the positive supply (VDD) at the top, and ground at the bottom:

 

 

I've shown the internal pullup, so you can see how this does provide a route for current to flow through the LED - and, therefore, the LED will glow.

 

EDIT

 

Just to emphasise, as avrcandies  points out in #20 below, that the microcontroller here is sourcing current; ie, the current is flowing out of the microcontroller and into the load (the LED).

And this was already shown in kabasan's diagram in #3.

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Jul 15, 2020 - 07:46 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

babu.james@live.in wrote:
the LED does glow enough to be seen

But not as brightly as it could glow!

 

Try it with 1k - see what you get!

 

babu.james@live.in wrote:
When you say too high

I mean that the value of the resistance is too high

 

Which means that the current through the LED will be much lower than it should be

 

Which, in turn, means that the LED is a lot dimmer than it could be.

 

Of course, if it's bright enough for your particular application - then that's fine.

 

 

When your issue is resolved, please mark the solution - see Tip #5.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Tue. Jul 14, 2020 - 03:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


babu.james@live.in wrote:
So it seems internal pull up sinks current. Is it true?

No, it sources current. I've been following this since it was posted, but thought avrcandies and kabasan nailed it in posts #2 an#3, based upon the description in post #1.

So it takes till post #13 to get OP to draw what he stated in #1...

It appears that the OP does not understand the flow path through internal pullup, external pullup and diode (anode to cathode) path to ground will cause the LED to turn on.

 

Edit: And so with this post, I become a "Raving Lunatic"

 

David

Last Edited: Tue. Jul 14, 2020 - 03:25 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

frog_jr wrote:
avrcandies and kabasan nailed it in posts #2 an#3

Agreed.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

frog_jr wrote:
And so with this post, I become a "Raving Lunatic"

Welcome to the club! wink

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've shown the internal pullup, so you can see how this does provide a route for current to flow through the LED - and, therefore, the LED will glow.

....as in SOURCING current, the current is flowing OUT of the pin 

 

However, if I connect an led (anode to pin and cathode to ground), I see it is lit. So it seems internal pull up sinks current. Is it true?

So hopefully OP knows now pullup is NOT sinking current, current is not flowing into the pin.   

Now we can debate electron flow vs conventional flow cheeky 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
SOURCING current, the current is flowing OUT of the pin

Indeed.

 

I've added that - and credit to  kabasan who did it first 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...