Forums

AVR and dim LEDs.

Started by artswan December 2, 2006
Hello all. I have been working with PIC microcontrollers for over 2
years now and I am familiar with and like them. However, recently I
have started dabbling with Atmel AVR microcontrollers to see what they
have to offer. Especially, since they seem quite popular these days and
are showing up in more open-source products. I have done some simple
flashing LED circuits with the ATmega8 and 48, and the ATtiny2313. I
have been using the demo version of BASCOM and have just been doing
simple one and two LED flashing circuits with very simple programs. The
programs all seem to work fine on each of the chips. I have noticed,
though, that the LEDs do not flash nearly as brightly with the AVR
chips as they do with the PIC chips. Is that something unique to AVR
chips, or is there some sort of pull-up resistor or other switch that
needs to be set to allow for more current to pass throught the LED?

In article <1165071152.857024.231710@f1g2000cwa.googlegroups.com> you
wrote:

> I have noticed, though, that the LEDs do not flash nearly as brightly > with the AVR chips as they do with the PIC chips. Is that something > unique to AVR chips, or is there some sort of pull-up resistor or > other switch that needs to be set to allow for more current to pass > throught the LED?
Check if you have configured the DDRx port direction registers properly. -- :wq ^X^Cy^K^X^C^C^C^C

artswan wrote:

> chips as they do with the PIC chips. Is that something unique to AVR > chips, or is there some sort of pull-up resistor or other switch that > needs to be set to allow for more current to pass throught the LED? >
You are probably trying to lit up the LEDs with the logic 1. This is not a good practice which originates from PIC appnotes. You should connect the LEDs to Vdd and lit them up with logic 0. Why: the majority of the logic ICs (including PICs!) have the logic 1 much weaker then the logic 0. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
On 2 Dec 2006 06:52:32 -0800, "artswan" <artswan@gmail.com> wrote:

>Hello all. I have been working with PIC microcontrollers for over 2 >years now and I am familiar with and like them. However, recently I >have started dabbling with Atmel AVR microcontrollers to see what they >have to offer. Especially, since they seem quite popular these days and >are showing up in more open-source products. I have done some simple >flashing LED circuits with the ATmega8 and 48, and the ATtiny2313. I >have been using the demo version of BASCOM and have just been doing >simple one and two LED flashing circuits with very simple programs. The >programs all seem to work fine on each of the chips. I have noticed, >though, that the LEDs do not flash nearly as brightly with the AVR >chips as they do with the PIC chips. Is that something unique to AVR >chips, or is there some sort of pull-up resistor or other switch that >needs to be set to allow for more current to pass throught the LED?
There are limitations on the maximum that each I/O pin can sink or source, as well as limitations on aggregate sinking and sourcing; e.g., there is a limit on the combined I[OL] for Port C in addition to the limit on the total I[OL]. Although I will occasionally hang a "heartbeat" LED directly off of a port (and set it to sink the LED + limiting resistor), in general, and particularly when multiple LEDs are involved, I'll move the LEDs off to a transistor or an array (e.g., ULN2803) where they can be fed all of the current that they need. -- Rich Webb Norfolk, VA
Thank all of you for your assistance. I will try out your suggestions.
As always, the Devil's in the details. LOL

Thanks again.
:)

Art

artswan <artswan@gmail.com> wrote:
> Hello all. I have been working with PIC microcontrollers for over 2 > years now and I am familiar with and like them. However, recently I > have started dabbling with Atmel AVR microcontrollers to see what they > have to offer. Especially, since they seem quite popular these days and > are showing up in more open-source products. I have done some simple > flashing LED circuits with the ATmega8 and 48, and the ATtiny2313. I > have been using the demo version of BASCOM and have just been doing > simple one and two LED flashing circuits with very simple programs. The > programs all seem to work fine on each of the chips. I have noticed, > though, that the LEDs do not flash nearly as brightly with the AVR > chips as they do with the PIC chips. Is that something unique to AVR > chips, or is there some sort of pull-up resistor or other switch that > needs to be set to allow for more current to pass throught the LED?
As already proposed, use the port to sink the LED curent. Use low current leds and do the calculations for a sensible current. Use the difference between the supply voltage and the LED voltage drop at the selected current and divide the difference by the selected current to get the required resistor. Bye -- Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt --------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
artswan wrote:
> Hello all. I have been working with PIC microcontrollers for over 2 > years now and I am familiar with and like them. However, recently I > have started dabbling with Atmel AVR microcontrollers to see what they > have to offer. Especially, since they seem quite popular these days and > are showing up in more open-source products. I have done some simple > flashing LED circuits with the ATmega8 and 48, and the ATtiny2313. I > have been using the demo version of BASCOM and have just been doing > simple one and two LED flashing circuits with very simple programs. The > programs all seem to work fine on each of the chips. I have noticed, > though, that the LEDs do not flash nearly as brightly with the AVR > chips as they do with the PIC chips. Is that something unique to AVR > chips, or is there some sort of pull-up resistor or other switch that > needs to be set to allow for more current to pass throught the LED?
Are you using the same brand and type of LEDs ? There are huge difference in brightness between various types, as well as different current requirements. Some LEDs are brighter at 2 mA than others at 20 mA. Also, compare the value of your current limiting resistor. While it is true that most chips can sink more current than they source, the AVR source current should be enough to drive some LEDs. I'm doing it all the time on ATmega128. Check your LED datasheet for the recommended forward current, and check the AVR datasheets for max source/sink current. If you have a voltmeter, you can measure the voltage directly at the output pin of the AVR chip (before the resistor). If it's close to the supply voltage, the max source current is not the problem.

Spehro Pefhany wrote:

>>Why: the majority of the logic ICs (including PICs!) have the logic 1 >>much weaker then the logic 0. > > > N-channel MOSFETs are better (i.e. lower Rds(on)) than p-channel parts > of the same silicon acreage. IIRC, it's something to do with a large > (2:1?) difference in carrier mobility, check your solid-state physics > textbooks if you're curious.
AFAIK, this has to do with the technology rather then with the physics. The conventional silicon process does not allow making PNP and P-channel devices as good as NPN and N-channel. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
On Sat, 02 Dec 2006 15:50:18 GMT, the renowned Vladimir Vassilevsky
<antispam_bogus@hotmail.com> wrote:

> > >artswan wrote: > >> chips as they do with the PIC chips. Is that something unique to AVR >> chips, or is there some sort of pull-up resistor or other switch that >> needs to be set to allow for more current to pass throught the LED? >> > >You are probably trying to lit up the LEDs with the logic 1. This is not >a good practice which originates from PIC appnotes. You should connect >the LEDs to Vdd and lit them up with logic 0. > >Why: the majority of the logic ICs (including PICs!) have the logic 1 >much weaker then the logic 0.
N-channel MOSFETs are better (i.e. lower Rds(on)) than p-channel parts of the same silicon acreage. IIRC, it's something to do with a large (2:1?) difference in carrier mobility, check your solid-state physics textbooks if you're curious. Best regards, Spehro Pefhany -- "it's the network..." "The Journey is the reward" speff@interlog.com Info for manufacturers: http://www.trexon.com Embedded software/hardware/analog Info for designers: http://www.speff.com
Vladimir Vassilevsky wrote:
> Spehro Pefhany wrote: >
... snip ...
>> >> N-channel MOSFETs are better (i.e. lower Rds(on)) than p-channel >> parts of the same silicon acreage. IIRC, it's something to do with >> a large (2:1?) difference in carrier mobility, check your solid- >> state physics textbooks if you're curious. > > AFAIK, this has to do with the technology rather then with the > physics. The conventional silicon process does not allow making PNP > and P-channel devices as good as NPN and N-channel.
In the days of germanium it was easier to make PNPs than NPNs. Once things switched to silicon, NPNs became the principal medium. -- Chuck F (cbfalconer at maineline dot net) Available for consulting/temporary embedded and systems. <http://cbfalconer.home.att.net>