Reply by Arlet December 3, 20062006-12-03
Mike Warren wrote:
> artswan wrote: > > > Oh, one final note that I forgot to mention (silly me!), I connected > > the LED, both with a series 220 ohm resistor and without, from Vdd to > > the output pin, so as to have the AVR chip sink current rather than > > source it, and there was no longer any visible blinking of the LED. > > You are risking damage to the LED and/or the chip by connecting it > without a resistor. > > Anyway, it looks like your problem is that you haven't set the pin to > output mode. > > for example if it was pin 0 on port C you would use: > > sbi DDRC,0 > > When the data direction bit is low the port bit just switches on or off > a pull-up resistor. That would explain the symptoms you are getting.
I agree, that's exactly what it looks like. Note that the PIC uses '0' in the direction register to turn a pin into an output, while the AVR uses '1'.
Reply by steve December 2, 20062006-12-02
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?
Yes there is, all PIC output pins have high current capability and can drive a LED directly, the ATmega's have high and low current ports, usually port B is the high current port and should be able to drive an LED directly like the PIC (at 5 volts anyway). So move the LED to a high current pin and you should work the same as the PIC. In general the AVR's are lower power devices, optimized for battery power (more delicate), so they make sacrifices like this.
Reply by Mike Warren December 2, 20062006-12-02
artswan wrote:

> Oh, one final note that I forgot to mention (silly me!), I connected > the LED, both with a series 220 ohm resistor and without, from Vdd to > the output pin, so as to have the AVR chip sink current rather than > source it, and there was no longer any visible blinking of the LED.
You are risking damage to the LED and/or the chip by connecting it without a resistor. Anyway, it looks like your problem is that you haven't set the pin to output mode. for example if it was pin 0 on port C you would use: sbi DDRC,0 When the data direction bit is low the port bit just switches on or off a pull-up resistor. That would explain the symptoms you are getting. -- Mike
Reply by artswan December 2, 20062006-12-02
Oh, one final note that I forgot to mention (silly me!), I connected
the LED, both with a series 220 ohm resistor and without, from Vdd to
the output pin, so as to have the AVR chip sink current rather than
source it, and there was no longer any visible blinking of the LED.

Art

Reply by artswan December 2, 20062006-12-02
I used the same LED that I was using in a breadboarded PIC circuit, a
pretty standard red LED I had bought in bulk from All Electronics a
year or two ago. I also switched out with other red LEDs that I knew
worked well. Same result, dim flashing LED. And, since I was using a
short flash time (0.250 seconds) for both on and off states, and was
running the circuit for only a few seconds to test it, I even took the
220 ohm resistor I was using in series with the LED and connected the
LED directly from the output pin to ground. Same dim flashing LED.

Art

Reply by CBFalconer December 2, 20062006-12-02
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>
Reply by Spehro Pefhany December 2, 20062006-12-02
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
Reply by Vladimir Vassilevsky December 2, 20062006-12-02

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
Reply by Arlet December 2, 20062006-12-02
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.
Reply by Uwe Bonnes December 2, 20062006-12-02
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 ----------