Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Pwm on other port
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> AVR
View previous topic :: View next topic  
Author Message
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Fri Dec 30, 2011 9:51 pm    Post subject: Reply with quote

At 5V the current flowing through a LED with a 220 ohm or a 470 ohm
series resistor is below the current ratings of the I/O of an AVR chip.
We are driving one or two LEDs so the current will never exceed the
total current that an AVR chip can drive.

Not knowing the used type of LED, it's impossible to calculate
the real current flowing through the I/O pins. 22.72 mA is the
current flowing through a 220 ohm resistor at 5V. The current
flowing through the real circuit will depend from the supply
voltage, the voltage drop of the I/O pins, the resistance of
the resistor and wires and the voltage drop of the LED. In any
case, if the voltage of the supply is 5V and the resistance of
the resistor is 220 ohm, the current will never exceed 22.72 mA.
With a supply of 5V and a 220 ohm series resistor, the real value
of the current flowing through the circuit will be less than 20 mA
regardless of the used type of LED.

Best regards,

Luciano
Back to top
View user's profile
MAK3

Bascom Member



Joined: 24 Sep 2010
Posts: 450
Location: Germany

germany.gif
PostPosted: Fri Dec 30, 2011 11:05 pm    Post subject: Reply with quote

Hi All,

the data sheet of PCA9685 say:

"..The LED output driver is programmed to be either open-drain with a 25 mA current
sink capability at 5 V or totem pole with a 25 mA sink, 10 mA source capability at 5 V...."

So the PCA9685 can not source more than an ATTINY or ATXMEGA !

But the PCA9685 can sink overall up to 400mA (16 x 25mA) which is 100% more then an ATTINY or ATXEMGA can source.
But with 2 LED's at a time this doesn't matter.

So after all I'm still questioning why a second chip is needed.
And imagine if we source 8 LED's with ATTINY/ATXMEGA and sink the other 8 LED's with this ATTINY/ATXMEGA.

But not everything needs an explanation when you want to have fun.

MAK3
Back to top
View user's profile
hgrueneis

Bascom Member



Joined: 04 Apr 2009
Posts: 863
Location: A-4786 Brunnenthal

austria.gif
PostPosted: Sat Dec 31, 2011 2:59 am    Post subject: LED mA and ports of AVR again Reply with quote

@Luciano
LED mA again....
concerning mA, I have to disagree with your theory.
As mentioned also by MWS, the forward voltage drop of the LED is the most important factor to consider.
Most standard indicator low power LEDs have a FV of about 1.6 V. The lowest ones I know are around 1.3 V.
So do the math and the highest mA on 1.3 V FV is 16.8 mA with 5V , RESISTOR 220 OHM). With FV 1.6 V it's 15 to 16 mA.
High power LEDs mostly have a FV of 3 to 4 V. Then you only have a drop over your 220 ohm resistor of 1 to 2 V.
Then you have a max. current of 4.5 to 9 mA.
As previous members commented the jump from the tower, the direct connection of an LED with a FV of 3.4 or 3.5 V
would mean certain death to the port pin and/or MCU!!!
Mostly high power leds have a high FV like that and it means....THE END.
HAVE A NICE BURN. The industry likes it when they can sell plenty of chips.
Good luck with electronic devices.
BTW, if somebody tries to rectify your mistake, it is not a reason to get testy.
Hubert
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Sat Dec 31, 2011 10:47 am    Post subject: Reply with quote

@hgrueneis:

My theory is just that at 5V with the recommended 220 ohm
series resistor the I/O will be OK. Even if you replace
the LED with a jumper, the current flowing through the I/O
will never exceed 22.72 mA.

* * *

(Here we are driving two LEDs for a toy or some kind of gadget).

In the datasheet of an ATmega48 for example, listed in the
"absolute maximum ratings" you will see 40mA per I/O pin but
the total current of the chip is limited to 200mA. You can also
read "Exposure to absolute maximum rating conditions for extended
periods may affect device reliability". Can we have more than 20mA
on an I/O pin at 5V? If we are driving logic gates it is not
recommended because Vout-L or Vout-H might be out of specifications.
If we are driving something else, like a LED, it depends not only
from the current but also if the LED is permanently on or if we are
driving the LED via PWM or not. These factors will have an influence
on the thermal stress of the buffer.

We are building a toy here, so have some fun and experiment a little
bit. Some people do that with brand new Intel chips. ($$$).

Best regards,

Luciano
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1827

blank.gif
PostPosted: Sat Dec 31, 2011 12:27 pm    Post subject: Reply with quote

Luciano wrote:
My theory is just that at 5V with the recommended 220 ohm series resistor the I/O will be OK. Even if you replace
the LED with a jumper, the current flowing through the I/O will never exceed 22.72 mA.

Not directed to me, but yes, it's possible this way to estimate the worst case.
But if you do the calculation, do it right from the begin, as if somebody else reads it, he has to guess what you want to say.
Quote:
Here we are driving two LEDs for a toy or some kind of gadget

Not that I need to take more care than the TO does, it's his project anyway, but if I notice that someone looks for a cheaper solution in a range of about 5 Eur/piece, at least the idea he wants to reduce costs for a series and this way commercial production comes into mind.
If such is the case, it is advisable not to create five hundred or a thousand pieces out of specs, which may behave to a certain part in an unpredictable way.
Quote:
Can we have more than 20mA on an I/O pin at 5V? If we are driving logic gates it is not recommended because Vout-L or Vout-H might be out of specifications.

If you mention the datasheet, you can see from the diagrams, that even at 40mA/5V and related to the ÁC's own inputs it still would be within specs.
VIL_max = 0.3VCC = 1.5V
VIH_min = 0.6VCC = 3.0V
From the following diagrams you get that at current 40mA/5V, high (sourced) pin-voltage drops to ~3.9V, low (sinked) it raises to ~0.8V, @25░. Tells you it's within specs. But not recommended, as 40mA are max ratings.
Chinese would say: that's good, together with leds at a certain forward voltage this behavior is self-regulating, let's eliminate the resistors.
Quote:
We are building a toy here, so have some fun and experiment a little bit.

As said, if it is a single piece, no problem, Atmels is happy to sell another one.
If it is a series, think differently, and then I would agree with Mak, use the tiniest reasonable solution, which could be single chip. If the thing has nothing more to do than pwm a few leds, then as Hubert suggested a simple mainloop pwm basic-syntax may do. If it has to have more functions, an asm-isr would be the way to go.
To consider the best solution, more info would be required, it would be the TO's job to provide them.
But as we don't hear from him, maybe he made already the magic white smoke escape Very Happy
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Sat Dec 31, 2011 1:36 pm    Post subject: Reply with quote

Can we have more than 20mA on an I/O pin at 5V? If we are driving logic gates it is
not recommended because Vout-L or Vout-H might be out of specifications.


@MWS:

See the attached picture and read again the above sentence.

Best regards,

Luciano
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1827

blank.gif
PostPosted: Sat Dec 31, 2011 2:32 pm    Post subject: Reply with quote

Luciano wrote:
...we are driving logic gates...
...and read again...

Yes, I can read, first it may depend what source you ask, for example:
http://en.wikipedia.org/wiki/Logic_level
There's for sure some IEEE or whatever standard, where TTL is exactly defined, but allaboutcircuits looks second source, as well as Wiki.
And if you like to prove something, think more clever and don't post a graphic about "acceptable output levels". We were talking about an Atmel with a high pin-load driving logic gates, so the diagram to look for would be "acceptable input levels", which surly differ and may as well be 0.8V for TTL as Wiki states. Then 0.5V according your diagram would be ok.
Secondly it depends on the type of logic gate technology, as you surly know there are several different types.
I might have missed the word TTL in your first message, wait, I try again...
Nope, no TTL.
Is it your intention to make people guess about your thoughts ?
Got this impression already from your earlier posts, in case the answer is "YES", I'll do my best to guess your replies from now on.
My first guess will be: 42 Very Happy
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Sat Dec 31, 2011 3:28 pm    Post subject: Reply with quote

@MWS:

The difference between the tolerable output and input ranges is called
the noise margin of the gate. If you need information about TTL gates
open a book or read here: LINK

* * *

In this thread we are driving LEDs with an AVR.

Best regards,

Luciano
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1827

blank.gif
PostPosted: Sat Dec 31, 2011 3:58 pm    Post subject: Reply with quote

Luciano wrote:
open a book or read here: LINK

Good. Your own reference proves you're wrong.
Normally it should be perfectly clear to you: if according your own crafted diagram, for an ATMega48 the output logic level low is at or below 0.5V, while the acceptable TTL gate signal level is up to 0.5V, this condition is perfectly acceptable.
Quote:
In this thread we are driving LEDs with an AVR.

Yes, I know, do you know too ? You did start with logic gates, I didn't.
However I don't even have to prove you wrong, you do the job yourself.

Beside, my statements were:
- Don't take the absolute maximum ratings as reference how far up you can go
- Do your current calculation for leds right
It's not my fault if your self confidence got offended, if I tell the obvious.
We're talking tech-stuff, tech-stuff will simply ignore you if you do it wrong, doesn't matter if you're in a huff Very Happy
Back to top
View user's profile
hgrueneis

Bascom Member



Joined: 04 Apr 2009
Posts: 863
Location: A-4786 Brunnenthal

austria.gif
PostPosted: Sat Dec 31, 2011 4:38 pm    Post subject: Reply with quote

Maybe this would be a good time to end this discussion because it is not really in the scope of this forum.
Otherwise Mark Alberts might have to rename it Electronics Forum instead of Bascom.
A HAPPY NEW YEAR TO ALL.
Hubert
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1827

blank.gif
PostPosted: Sat Dec 31, 2011 5:16 pm    Post subject: Reply with quote

Hubert,
hgrueneis wrote:
...it is not really in the scope of this forum.

you're right, a look at the thread and I'd say it was borderline from the start and ended being Bascom-specific with the third post, the rest "developed".
I won't mind if a mod moves it.

HAPPY NEW YEAR

Ludwig
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5093
Location: Holland

blank.gif
PostPosted: Sat Dec 31, 2011 7:22 pm    Post subject: Reply with quote

This topic became very off topic. The main idea is to see (pseudo) code here. A discussion about the (inner) electronics can best be done in the another forum.
I will move this topic to a more general forum.

_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> AVR All times are GMT + 1 Hour
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum