Why the LED is too dim?

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

Hi,

This is embarrassing to ask, but...

I have an ATMEGA8's GPIO pin as an output. The output is connected to a 360 ohm resistor that is in series with a 3mm LED, whose GND pin is terminated to GND. The system is powered by a 5V DC source.

The led VERY dim for some reason. The GPIO pin's output voltage is 4.89V. The voltage across the resistor is 1.68V. Same for the LED.

So, as a test instead of the GPIO source the power to the LED, I have the resistor connected directly to the 5V. The voltage across the resistor is 2.9V. And the voltage across the LED is 1.94V. This time the LED is bright.

The GPIO pin is sourcing enough voltage to me. But why the LED is so dim????

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

Quote:
The GPIO pin's output voltage is 4.89V. The voltage across the resistor is 1.68V. Same for the LED.
so where is the missing 1.53 Volts ?
( 4.89V (GPIO) - 1.68V (Resistor)- 1.68V (Led) = 1.53 V )

Is your program pulsing that GPIO ?

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

mikech wrote:
Quote:
The GPIO pin's output voltage is 4.89V. The voltage across the resistor is 1.68V. Same for the LED.
so where is the missing 1.53 Volts ?
( 4.89V (GPIO) - 1.68V (Resistor)- 1.68V (Led) = 1.53 V )

Is your program pulsing that GPIO ?

No pulsing at all. Very basic example. I simply do a output via the PORT and turn on the bit. That's what puzzles me.

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

Maybe... that GPIO pin is damaged from a previous life. I agree with Mike that your measurements do not "add up". :lol: Keep the black lead on ground and then measure across the led and then at the GPIO pin and then the resistor.

Ross McKenzie ValuSoft Melbourne Australia

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

valusoft wrote:
Maybe... that GPIO pin is damaged from a previous life. I agree with Mike that your measurements do not "add up". :lol: Keep the black lead on ground and then measure across the led and then at the GPIO pin and then the resistor.

I even change the GPIO pin. Doing what you suggested with the resistor and the LED on, I get:

1) 1.66V with GND and GPIO pin
2) 1.67V with GND and the anode of the LED
3) 1.66V with GND and the resistor

That does at up to 4.98V (almost 5V), which is the voltage of the GPIO pin when there is NO LED or resistor connected.

But still dim, the LED.

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

How many bypass caps do you have across the supply pins?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

I am very confused. Why is the GPIO voltage now 1.66V when it was 4.89V in the first post ?

Is your circuit
GPIO --> 360 ohms --> Anode (LED) Cathode --> GND

Is the VCC on the micro still 5V ?

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

Without wishing to insult you, but do you have it connected like this?

Measurement 1 should be about 1.8volts for a red LED and measurement 2 should be the GPIO's output (4.xx volts). VCC is 5 volts. Sorry I have shown R1 as 1K, I know it should be your value (360 ohms?).

I am thinking that you have forgotten to set your GPIO pin as an output. Show us your code.

Cheers,

Ross

Attachment(s): 

Ross McKenzie ValuSoft Melbourne Australia

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

Is your controller in a reboot loop?

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

Too many ohms. Your LED is only getting 4ma. Try more like 84 ohms. I typically use 100.

See http://barefootelectronics.com/l...

The largest known prime number: 282589933-1

It's easy to stop breaking the 10th commandment! Break the 8th instead. 

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

Tom, the OP is using 360 ohms. I (ab)used an old schematic that had 1K that I forgot to change to 360 ohms. OP's value is fine. (and I do actually use 1K in lots of my applications... they work/shine fine. They are never outdoors like yours.

Cheers,

Ross

Ross McKenzie ValuSoft Melbourne Australia

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

Quote:
I am thinking that you have forgotten to set your GPIO pin as an output. Show us your code.

+1

Quote:
1) 1.66V with GND and GPIO pin
2) 1.67V with GND and the anode of the LED
3) 1.66V with GND and the resistor

This makes less sense than your first stated measurements. In fact it defies Ohm's law and/or simple arithmetic.

Four legs good, two legs bad, three legs stable.

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

LED brightness is a function of current, not voltage (as long as the voltage is higher than the LED's forward voltage spec).

Did you measure the current through the LED circuit when it's being driven by the GPIO?

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

Quote:

+1

+1

Why isn't every voting for this pin==input not output theory? It seems obvious. I didn't like to post earlier as I'm just a bit mangler not a sparkie but to a bit mangler anyway it seems like the obvious explanation. If Ross and John think the same I'm willing to come out from under the rock too ;-)

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

Torby wrote:
Too many ohms. Your LED is only getting 4ma. Try more like 84 ohms. I typically use 100.

Depends on the LED. I have LEDs that glow brightly when driven with 4 mA.

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

Quote:
How many bypass caps do you have across the supply pins?

I am using an ATMEGA328, PDIP format, as mentioned earlier in the post.

I have two 0.1uF decouple caps for GND-Vcc pins and the AVCC-GND pins.

Quote:
I am very confused. Why is the GPIO voltage now 1.66V when it was 4.89V in the first post ?

Yes, IF I do not connect the LED and the resistor, I see that the GPIO voltage output is 4.89V. However, when connecting the resistor and the LED, the voltage measured is 1.66V, which is exactly the voltage that goes across the LED.

Quote:
I am thinking that you have forgotten to set your GPIO pin as an output. Show us your code.

Here is my init code:

void ioInit() {
  // Very simple.  One LED output pin. PC0
  DDRC = 0b00000001;
}

From there on I use PORTC |= 0b00000001 to turn on the LED.

Quote:
Too many ohms. Your LED is only getting 4ma. Try more like 84 ohms. I typically use 100.

360ohm should be fine. I've always used it. Also, I mentioned of test this out with the source connected directly to the 5V rather than from the GPIO, and it works nicely.

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

Quote:
Yes, IF I do not connect the LED and the resistor, I see that the GPIO voltage output is 4.89V. However, when connecting the resistor and the LED, the voltage measured is 1.66V, which is exactly the voltage that goes across the LED.

Which indicates either:
a) Your GPIO pin is broken
b) You are mistaken about the pin being set as a GPIO output - maybe some other code is screwing with DDRC.

Honestly, it's hard to think of any any other cause.
I take it you have reduced the entire code to a couple of lines that set the DDRC and the PORTC and nothing else?

Four legs good, two legs bad, three legs stable.

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

Quote:

Why isn't every voting for this pin==input not output theory? It seems obvious. I didn't like to post earlier as I'm just a bit mangler not a sparkie but to a bit mangler anyway it seems like the obvious explanation.

Because OP said:
Quote:

The GPIO pin's output voltage is 4.89V.

Only later did we learn that
Quote:

1) 1.66V with GND and GPIO pin

But OP seems reluctant to make the specific measurements suggested, or precisely spell out the schematic, or to post a full, complete test program rather than a line here and there.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

John_A_Brown wrote:
Quote:
Yes, IF I do not connect the LED and the resistor, I see that the GPIO voltage output is 4.89V. However, when connecting the resistor and the LED, the voltage measured is 1.66V, which is exactly the voltage that goes across the LED.

Which indicates either:
a) Your GPIO pin is broken
b) You are mistaken about the pin being set as a GPIO output - maybe some other code is screwing with DDRC.

Honestly, it's hard to think of any any other cause.
I take it you have reduced the entire code to a couple of lines that set the DDRC and the PORTC and nothing else?

Code is reduced bare bone of ioInit() with 'DDRC = 0xb00000001;' mentioned previously and with the below:

int main(void) {
  PORTC |= 0b00000001;

  while (1);
}

Ordering new ATMEGA328...

I have done this LED stuff a thousand times but only this time that is such a nightmare!

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

Ok since the OP is using PORTC on a M328 I'll start a betting session that AVCC is not connected! :wink:

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Sounds very probable. He does have a decoupling cap on AVCC though...

Four legs good, two legs bad, three legs stable.