Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 15 of 15

Thread: LEDs without external resistors

  1. #1
    Senior Member pictographer's Avatar
    Join Date
    May 2013
    Location
    San Jose, CA
    Posts
    654

    LEDs without external resistors

    On the back of a Teensy 3, I soldered one blue and one yellow-green extremely small surface mount LED between pins 27 and 28, and pins 29 and 30 respectively. I did not add external resistors. The T3 is clocked at 24Mhz and will be powered from an external 3.3v voltage regulator (an LP2950ACZ−3.3G), ideally sleeping most of the time.

    By driving one pin of a pair high and the other pin low, the LEDs light up just fine with no apparent heating, tested while powered from my laptop's USB.

    So far, I haven't tried leaving the LEDs on continuously. I'm guessing that by keeping the duty cycle of the LEDs low, I can avoid damage. Does anyone know if this is correct and how to calculate the maximum safe duty cycle?

    I'm also wondering if the internal pullup/pulldown resistors could be used instead of external resistors to make a simpler safe approach?

    By the way, in the intended application the T3 will be mounted directly against the project box with holes for the indicator lights, but based on my tests, it's tempting to make an ornament out of a T3 and a bunch of surface mount LEDs.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,928
    The trouble with connecting a LED without any series resistor is the actual current flowing through the LED, wires and transistors can be rather unpredictable. It's likely the current could be too much for long-term reliable operation.

    The short answer is to use a series resistor. When the voltage output is substantially more than the LED's (approx) voltage, the resistor will have predictable voltage, which results in a predictable current. This is considered good engineering practice, because the specific properties of the LED and transistors inside the chip can change with temperature, aging, and can vary quite a bit from one part to another due to manufacturing tolerances. With a resistor, even pretty major changes in those other parts results in only a small change to the current.

    But you're asking about what happens without the resistor. That's a long answer, which I'll continue in another message. I'm guessing other people will likely chime in on this too. It's rather involved.......

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,928
    There's generally 2 ways to think about these things: physics and datasheet specs. In this message, I'll talk about the physics....

    Most chips with digital outputs have a pair of transistors that connect the pin to either ground or the positive power line. Usually the transistors are mosfets, where the transistor basically is a low-value resistor when it's on. The value of the resistance can change with temperature. It's also different in each chip, because the manufacturing process varies a bit, especially for chips from different wafers or different production runs.

    Inside the chip, there's also a very thin "bond wire" between the silicon and the metal frame that is the pins visible from the outside. Those little wires are extremely thin, because they have to bond to tiny pads on the top of the chip. They're also sometimes a metal that doesn't conduct as well as copper, because it makes a better connection to the material on the chip. With excessive current, bond wires can heat up because the thinness and less-ideal metal increases the resistance and they're surrounded by plastic that doesn't dissipate heat very well. Too much heating can make them fail.

    Most LEDs have one side mounted to a metal frame and the other side connected by a bond wire to the other side of the frame.

    When a LED is connected without a resistor, the current that flows depends on the LED properties, the resistance of the mosfet transistors inside the chip, and the resistance of those tiny bond wires.

    The difficult part is all of these things can vary quite a lot. They're also not usually specified in terms of their actual physical properties (I'll mention specs in another message). So the current you'll actually get through the LED is pretty difficult to predict.

    With a red LED, which is usually about 1.7 to 2.0 volts, at least about 1.3 volts will be across the transistors and bond wires (assuming the current isn't so high that the voltage power source and voltage regulator start dropping the voltage). With a blue LED that has a much higher forward voltage, much less will be across those parts. The current will be dramatically different.

    Unfortunately, the only way to really get a good idea of the currents is to carefully measure. I believe this thread may be interesting for people (hopefully they'll be able to find it somehow), so in a moment I'll do some quick measurements and post some real numbers.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,928
    Ok, I just tested several random LEDs, and the RGB LED PJRC sells, using pins 9 and 12 and a 0.961 ohm resistor.

    Here are the results:

    Code:
            1ohm     current  led     vcc     pin9    pin12
            ----     -------  ---     ---     ----    -----
    blue    0.432mv  0.449mA  3.263V  3.281V  0.007V  3.272V
    green*  8.09mV   8.418mA  2.938V  3.280V  0.128V  3.101V
    blue*   12.56mv  13.07mA  2.743V  3.279V  0.207V  2.990V
    green   23.23mV  24.17mA  2.187V  3.279V  0.384V  2.693V
    red*    24.82mV  25.83mA  2.061V  3.277V  0.430V  2.744V
    yellow  27.06mV  28.16mA  2.083V  3.278V  0.466V  2.607V
    red     28.39mV  29.54mA  1.984V  3.278V  0.515V  2.545V
    ir      39.05mV  40.63mA  1.246V  3.277V  0.751V  2.170V
    With one blue LED, it barely even lights up because that LED needs about 3.3 volts, so the current is under half a milliamp. The blue part of the RGB LED needs much less, so it has 13 mA. As the LEDs need less voltage, the currents go up much higher.

    I'd like to stress again these currents can vary quite a lot from one LED to another, from one Teensy3 to another, and they can also fluctuate with temperature.

    I tried to make good measurements, but I also did this quickly. The voltages may not perfectly add up, because I measured at different points for each, so whatever tiny voltage drops occurred along the wires and in the solderless breadboard were not measured. These measurements were taken with a 1 ohm resistor in series, which actually measured 0.961 ohms with an accurate 4-wire measurement using an Agilent 34410A meter. The resistor did lower the current somewhat, but as you can see it was only a tiny fraction of the total voltage.
    Last edited by PaulStoffregen; 06-14-2013 at 11:01 PM.

  5. #5
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    458
    While Freescale likely designs these parts quire conservatively, the spec. for the I/O pins is 25 mA max. This is likely not a problem if the application is not a high reliability one, or doesn't operate at high temperatures continuously, but exceeding it significantly (maybe 2x ?) would probably overstress the chip.

    Secondly, the resistance of the MOSFETs in the I/O pins also changes very significantly with the supply voltage of the chip (probably more than 2:1 from min to max.). It also probably changes 2:1 from max. to min. temperature. The spec. for the pin drive strength allows you to calculate the maximim pin internal resistance -- it is 0.5 V @ 9 mA, or 55 ohm. Since this is worst case, the other extreme is likely as low as 55/4, or 13 ohm, or possibly even lower. You can see why it is not a good idea to depend on this to regulate the LED current.

  6. #6
    Senior Member pictographer's Avatar
    Join Date
    May 2013
    Location
    San Jose, CA
    Posts
    654
    Wow. I really appreciate the education here. Let's see if I understand a bit.

    All the LEDs except the blue and green ones in Paul's experiment exceeded the current spec for the I/O pins. Without doing the sort of testing manufacturers do, the best I can hope for is an educated guess as to the effect on longevity.

    Is anyone willing to offer an opinion about using PWM to reduce the stresses on the pins? If power is applied for less time, then there should be less heating, however, this might be offset somewhat by thermal cycling if the pulse width is too large. If the heat is getting generated by a single transistor within the T3, that's a tiny mass surrounded by mostly silicon (a poor conductor) and some metal. Maybe it's not possible for the T3 to make pulses short enough to prevent that I/O pin MOSET from overheating?

    Why is it worse to attaching two outputs together with a LED than with just a wire? Or is it?

    Does the physical size of the LEDs matter? The LEDs I used are incredibly small, just barely spanning the gaps between the pads on the bottom of the Teensy3.

    I only have a cheap multimeter. Is it reasonable to try to measure the current across my LEDs this way? If so, I could try the experiment of driving the LEDs by setting both pins to inputs, one with a pullup and one with a pulldown.

    I'm still curious about this, but you've convinced me to add resistors!

  7. #7
    Senior Member pictographer's Avatar
    Join Date
    May 2013
    Location
    San Jose, CA
    Posts
    654
    I tried the experiment of driving the LEDs using the one input pullup and another input pulldown. Also tried one output and one input with pullup/pulldown. Wasn't able to turn on the LEDs. Maybe there was a combination I missed. If anyone thinks this is promising, I'll try again more carefully.

    BTW the code for turning on the input pulldown courtesy of cmason is here:
    http://forum.pjrc.com/threads/7531-I...rs-on-teensy-3

  8. #8
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    458
    PWM will help, but in fact the pins are not generally guaranteed this way (because wearout is nonlinear -- depends on current squared or more) -- so 50 % PWM at 50 mA (== 25 mA average) is worse than 25 mA DC. The wearout is usually metal migration inside the IC (the momentum of the electrons actually can move the aluminium metal !), not thermal cycling on this scale -- http://en.wikipedia.org/wiki/Electromigration

    I don't want to scare you -- for a home project, you're likely OK for a factor of 2x or more exceeding the spec. Remember you can also parallel two (or more) outputs to improve drive strength -- and then use a R to define the current more predictably.

    I guess you really want to save components and space -- is that why you don't want to use resistors ?

    Even with a cheap DVM, you can measure the current by measuring the input current to the T3 -- power it from a 5 V supply, and insert the DMM in series with that supply to measure the current; have a program that turns the LED on for (say) 4 s and off for 4 (and does nothing significant else) -- the deltas in currents will be the LED current.... If you just put the DMM in series with the LED, the internal resistance of the current meter would have affected these types of measurements somewhat.

    Another approach that gives good predictability is to use one resistor to the 5 V supply, then connect the individual LEDs from that node to individual T3 output pins (or to sets of 2 or more in parallel). PWM the LEDs so that only one is on at a time; perhaps set the R so that even with the shared duty cycle you get enough brightness.

    There is a slight risk that this will leave some small residual leakage current in a LED (especially the red ones) when all PWMs are off -- you might see this in a dark room. If this is an issue, you could use one other output connected to the junction of the LEDs and R via another R and turn it on when the (rest of ) the PWM is off -- that will pull the V at the top of the LEDs low enough that they won't leak.

  9. #9
    Senior Member pictographer's Avatar
    Join Date
    May 2013
    Location
    San Jose, CA
    Posts
    654
    Learning is my primary goal and I'm very appreciative of all the help I'm receiving. I was curious if I could save components by doing more in software, and if not, to understand at a deeper level why not. I'm new enough at DIY electronics that I haven't smoked any components yet, though I've abused my Teensy 3 and ATmega 168. I was scratching my head about why all the cautions about LEDs since I hadn't seen any problems in my fumbling around. I'm feeling more comfortable that I've got a better understanding of what can go wrong, why it might not be obvious, and why my proposed fixes aren't reliable.

    With the explanations here, I'm now better able to understand some of the resources on the web that assume more of a EE background. I found an application note from 2004 that goes into some detail about why an abused MCU can appear to work, but actually be accumulating damage, consistent with the good explanations here.

    http://www.freescale.com/files/micro...ote/AN2434.pdf

    I'll try the measurement techniques you described. They'll be super helpful in extending the battery life of my Morse code PDA.

    I'll also pick up a few more surface mount resistors so I can redo my LEDs and stay within the data sheet.

  10. #10
    Member
    Join Date
    Jan 2014
    Location
    Austin, Texas
    Posts
    57
    I was gonna write a quickie how to, but there's stuff already out there.

    A short explanation and a calculator.
    http://www.daycounter.com/Calculator...lculator.phtml

    A more detailed explanation.
    http://learn.adafruit.com/all-about-...oltage-and-kvl

  11. #11
    Junior Member
    Join Date
    Feb 2014
    Posts
    2
    @pictographer, Using PWM in software is the easiest way to avoid using external pull-ups for any low impedance load. The frequency and duty cycle need to be carefully set in this case. The required PWM waveform is not always just ON and OFF type. It can have multiple ON and OFF cycles in one period. The percentage of duty cycle that could be set as a maximum should be calculated based on the internal resistance of your LEDs. For that you’ll need to take the LEDs out of the circuit and use a multi-meter.

    pcb assembly
    Last edited by pilav; 07-21-2014 at 09:20 PM.

  12. #12
    Senior Member
    Join Date
    Jun 2013
    Location
    So. Calif
    Posts
    2,828
    Many MCUs spec the max current on I/O pins as the sum of the worst case for all pins. But a conservative design wouldn't use too much current on any one pin.

  13. #13
    Senior Member
    Join Date
    Jan 2013
    Posts
    966
    Quote Originally Posted by pilav View Post
    @pictographer, Using PWM in software is the easiest way to avoid using external pull-ups for any low impedance load. The frequency and duty cycle need to be carefully set in this case. The required PWM waveform is not always just ON and OFF type. It can have multiple ON and OFF cycles in one period. The percentage of duty cycle that could be set as a maximum should be calculated based on the internal resistance of your LEDs. For that you’ll need to take the LEDs out of the circuit and use a multi-meter.
    I'd really like to see that calculated. Care to share an example ?

  14. #14
    Senior Member
    Join Date
    Mar 2013
    Posts
    122
    I wanted to mention that this thread was useful for me, as I was searching for more practical applications of the teensy pin output limit.

    I have a bunch of tiny SSRs ($1.5 parts), and I was originally trying to run them with a proper NPN transistor. They have a 7.5mA min-current for turn on (maximum min, so the most that they would require to at least turn on).

    When I got to making my board, I realized that with 16 of these relays, I was increasing my part count by 48 to have transistors running them, and I couldn't quite deal with all those extra parts. The board routing was a mess. The "typical" usage on current is 12.5mA, and 15mA is what I spec'ed when I had the transistors in the circuit.

    So I'm trying to run the part now with 8-12mA coming direct from the I/O, and I only need 2-3 relays open at a time (so I'm not exceeding the max total pin output specs.) Because I'm running so close to the spec limit I found this thread useful for the part about what sort of internal resistance I might expect from the pins. It looks like 13-53Ohms. I guess I'm going to assume the pins have 20Ohms resistance when calculating what resistor I still need for the SSR, which is I think conservative enough. I realize going above 9mA is not good for the pins, but I'm going to shoot for 11mA or whatever it takes to assure 9mA going to the SSR in the case that the pin has 53 ohm internal resistance.

    3.3V --> 1.15V led --> 2.15V working with. 2.15V / 0.011A = 195.45 Ohms, minus 20 ohms = 175.45ohms. I can find 174 ohm resistors easily, and 175 ohms with a little more difficulty. Even 175.84ohms exist it seems, but I don't want the hassle of odd-ball parts that I assume are less frequently stocked.

    So case (A) mininum internal resistance 13 ohms = 12mA from the pin. with 174 ohm resistor.
    Case (B) Max internal resistance 53 ohms = 9.5mA

    Ok, I went overboard explaining my particular case, but my point is just..this thread is useful. Thanks!

  15. #15
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,928
    I wouldn't worry about only a few ohms difference.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •