Driving LEDs directly on an AtXMega

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

In my current layout I am driving some SMD-LEDs directly from GPIO-Pins of my AtXMega. Now I found out that that is damaging the IC by drawing too much current. Is there nevertheless a possibility to drive the LEDs, even if there are no resistors?

This topic has a solution.

Last Edited: Thu. Jul 30, 2015 - 07:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Only if you effectively PWM the signal to them - that is keep switching it on (for a short period) and off (for a long period) so fast that it actually looks like it is on all the time. If for example you only turn it on for 1/10th of the time and off for 9/10th of the time it will use 10% of the current.

 

But what on earth possessed you to design a circuit with LEDs but without current limiting resistors?

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

Short answer: No.

 

There are other methods for driving LEDs, particularly high power LEDs, with regulated current sources, or special LED driver chips.

But for small SMD LEDs on a PCB just include the resistor!

 

Most projects entail learning something new, accept the fact you learned about driving LEDs on your current project.

 

A LED is essentially a diode that emits light.

When it is on, forward biased, it is essentially a short circuit, (well, a short circuit with a voltage drop across it...).

Anyway, poor analogy, but it will attempt to draw way more current than the uC I/O pin can provide.

 

So give it a little resistor and life is good.

 

JC

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

Ok, that will be included in the next pcb I will fabricate, until then I have to use a PWM modulation for the LEDs.
Thanks!

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

Depending on the leds, you could possibly use the ports internal pull-up/down resistors. The leds will undoubtable be quite dim, but perhaps it is good enough?

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

Could you clarify on that, please?

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

Most LEDs have voltage drop of about 1.8V.

If your VCC does not exceed 2V it is possible to drive LED directly by GPIO pin.

Should you do it? No, never.

 

By the way: I experimented with XMEGA32A4U, VCC was 3.3V and pin load (resistor included!) was about 10mA. To my surprise measured pin voltage was only 2.0V instead of 3.1V, though datasheet says Voh = 0.95*VCC

 

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

To my surprise measured pin voltage was only 2.0V instead of 3.1V, though datasheet says Voh = 0.95*VCC

Yes.

 

When one thinks the pin is "high", and is going to be about 3 V, (or Vcc volts), that is not the case.

The output driver has its own internal transistors, and the output voltage for a High is always a bit below Vcc, and the Low is never 0 V, it is always a bit above Ground.

 

Most (All ?) of the uC data sheets have a graph, buried in the back somewhere, that shows typical Vout under various current loads.

 

Ok, that will be included in the next pcb I will fabricate, until then I have to use a PWM modulation for the LEDs.

 Since your are working with SMD you have another option:

Do some surgery on your PCB!

 

Cut one of the two traces going to or from the LED, (uC to LED, or LED to Ground).

Then solder a small SMD resistor over the gap in the trace.

It is now in series with the LED and life is good.

 

Learning how to modify a PCB on a Prototype is a good skill to develop.

 

JC

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

In this case it is unfortunately not possible, after there is either no space for additional parts or the vias are at the second or third level in my four-layer-pcb, and only emerging shortly before the LEDs

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

In which case you simply bin the pcb and start again.

 

I note that your Stepper schematic also omits resistors.

 

It might be possible to find some SMT leds with built-in resistors.

You can buy through-hole LEDs with built-in resistors.

 

David.

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

le_canard wrote:

Could you clarify on that, please?

If you reconfigure your port pins to use a pull resistor instead of totem-pole output (either pullup or -down depending on how your leds are connected), then the pull resistor will limit the current in the led. The only problem is that the pull resistors are quite large, so you end up with currents around 40-50 µA. If you use low current / high efficiency leds, and you only need them for debug purposes, then the little light they make perhaps could be good enough. At least until you have new boards produced.

 

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

I tried the following approach:

ioport_set_pin_dir(BLU_LED, IOPORT_DIR_OUTPUT);
ioport_set_pin_mode(BLU_LED, IOPORT_MODE_PULLUP);

resp.

ioport_set_pin_dir(BLU_LED, IOPORT_DIR_OUTPUT);
ioport_set_pin_mode(BLU_LED, IOPORT_MODE_PULLDOWN);

but the brightness did not change. Is that the correct approach?

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

No.   You will damage your Xmega.    The GPIO pins have a lower current than a Mega or Tiny.

 

Svuppe was suggesting that you leave the output driver in INPUT mode.   Just enable / disable the internal pull-up.   The LED current will be 30uA or so.   Instead of the 10000uA that you are using.

 

The alternative is to use WIRED-AND with pull-up.   But this will supply no more current than INPUT with pull-up.

 

Have you looked for SMT LEDs with built in resistors?  e.g. http://www.alibaba.com/product-detail/-Special-resistor-built-in-led_60147266849.html?spm=a2700.7724857.35.1.Nm6xV9

 

David.

Last Edited: Fri. Jul 31, 2015 - 02:42 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just tested the Input-Solution, it will work, and I will include resistors in my next layout, I think that is the easiest way to go at the moment. Thanks again!

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

 after there is either no space for additional parts or the vias are at the second or third level in my four-layer-pcb

 

 

 

Be creative!

 

If the traces are not long enough for you to cut a trace and place a single 330 ohm SMD resistor across the gap, then:

 

Mount the LED up off the PCB, standing up on two, 150 ohm resistors, on end, like legs on a table.

 

One resistor on each PCB pad, the LED sits across the tops of the resistors which are standing up on end.

 

You still have 300 ohms series resistance, and it takes up minimal space beyond the original room available.

 

JC 

 

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

Or perhaps you could use 1 resistor with the LED in an inverted 'V' arrangement ...

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

DocJC wrote:

To my surprise measured pin voltage was only 2.0V instead of 3.1V, though datasheet says Voh = 0.95*VCC

Yes.

 

When one thinks the pin is "high", and is going to be about 3 V, (or Vcc volts), that is not the case.

 

I am afraid you misunderstood me. I am aware of possible voltage drop on internal transistor. My surprise was that measurement violate datahseet.

In my case datasheet for XMEGA32A4U, table 36-7 says MINIMUM VOLTAGE @ 3.3VCC, 8mA is 2.6V, typical 2.9V

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

Most probably there is no surprise if one can understand table 36-7, because I can't. It looks like a mess. I personally can not predict Voh for any value different from those stated. Couple of plots would give much more information :(

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

mccrtay wrote:

Most probably there is no surprise if one can understand table 36-7, because I can't. It looks like a mess. I personally can not predict Voh for any value different from those stated. Couple of plots would give much more information :(

You mean something like figures 37-24 to 37-31 in the same datasheet (if I have guessed which datasheet you're referring to)?

 

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

Svuppe wrote:

You mean something like figures 37-24 to 37-31?

 

Yes, that's what I've meant, figure 37-26, I missed it, thank you for pointing.

By the way, this plot doesn't correlate with my measurement, but it doesn't matter. Let's assume that I measured current inaccurately.