Shop OBEX P1 Docs P2 Docs Learn Events
Playing with fire (LEDs with no resistors): Cool Update — Parallax Forums

Playing with fire (LEDs with no resistors): Cool Update

RaymanRayman Posts: 14,838
edited 2012-04-21 15:39 in Propeller 1
Just did a quick test of Tubular's output pin resistance measurments:
http://forums.parallax.com/showthread.php?135845

His graph shows a resistance of ~27 or 30 Ohms at 3.3 Vdd.

I happened to have a Red/Green LED with a forward drop of 2.1 V and a current rating of 25 mA...

So, my math shows I can hook it up without resistors...
Anyway, I gave it a try and it seems to work fine:
NoResistors.jpg



Update: Look below and you'll see it's perfectly safe doing this with normal green LEDs (or any LED with threshold voltage >2.2 V and 20 mA rating).

Cool Update: Use a regular green LED as photodetector this way too! (see reply #22 on page 2)
1024 x 768 - 101K
«1

Comments

  • RaymanRayman Posts: 14,838
    edited 2012-01-23 06:32
    Made some measurements with multimeter:

    Red Led: Voltage drop = 1.96 V, current =21.3 mA

    Green Led: Voltage drop = 2.17 V, current = 18.5 mA

    So the common cathode current is just under the 40 mA spec for a Prop pin.
    I think most regular red leds are rated for 20 mA, so this might burn them out...
    But, green leds look like a great fit. The current is safely below the 20 mA typical rating due to the higher voltage drop.
    Blue or yellow would probably draw less current, but maybe too much less, making them not as bright.


    So, using 2 prop pins (to double source impedance) with a green LED looks safe.
  • SONIC the HedgehogSONIC the Hedgehog Posts: 321
    edited 2012-01-23 07:40
    Reminds me of the time I decided to give a diode access to 9v current. I believe diodes(not LEDs) just regular diodes shuld not turn orange under regular use and melt......it burnt my hand......but it was awesome.
  • RaymanRayman Posts: 14,838
    edited 2012-01-27 07:44
    Think I've decided doing this with green LEDs is perfectly safe...

    Here's a shot with 4 of them on steady.
    LedFire.jpg

    Each draws 18 mA, just under the 20 mA rating...
    1024 x 768 - 119K
  • SONIC the HedgehogSONIC the Hedgehog Posts: 321
    edited 2012-01-27 10:45
    So you would say that putting the LEDs in seris would remove the need for resistors?
  • RaymanRayman Posts: 14,838
    edited 2012-01-27 10:53
    I don't need resistors because the Prop pins essentially all have ~40 Ohm internal resistors.
    If I apply Vdd with one pin and Gnd with a second pin, that puts ~80 Ohms in series with the LED,
    which is enough to limit the current below the 20 mA max.

    Putting two LEDs in series wouldn't work because 3.3 V isn't enough to forward bias two LEDs in series...
  • SONIC the HedgehogSONIC the Hedgehog Posts: 321
    edited 2012-01-27 11:01
    I did not know that. Well, that's interesting and thanks for sharing. I have learned something new!
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2012-01-27 11:05
    The way I was taught is that if the LED forward voltage was the same as the supply voltage, that was the only time you could power an LED without a resistor. The current flowing in an LED is an exponential function of voltage across the LED. A small change in voltage can result in a large change in current flow. Unlike the resistor, the LED current vs voltage is not linear. Even when the supply voltage is exactly what the LED needs, I tend to use a 1 ohm resistor, minimum to prevent current from rising/spiking due to voltage fluctuations.
  • Heater.Heater. Posts: 21,230
    edited 2012-01-27 11:10
    Except using two pins to drive a LED may be more of a loss than adding a resistor. Unless perhaps you have another led in parallel, reversed. Then you get two indicators on two pins resistor free.
  • RaymanRayman Posts: 14,838
    edited 2012-01-27 11:52
    Yeah, I think adding a 1 Ohm resistor will make an insignificant change...
    Tubular's measurements show the Prop's pins all have an internal resistance of ~40 Ohms...

    Heater, I wonder if they sell LEDs that are back to back in the same 2-pin package...
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-27 11:59
    Rayman wrote: »
    I wonder if they sell LEDs that are back to back in the same 2-pin package...

    Do you mean something like this?
  • RaymanRayman Posts: 14,838
    edited 2012-01-27 12:20
    Yes, except that red is dangerous because it only has a ~2.0 V threshold... It could draw more than the usual 20mA rating...
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-27 12:36
    Rayman wrote: »
    Yes, except that red is dangerous because it only has a ~2.0 V threshold... It could draw more than the usual 20mA rating...

    Then I don't think I understand this question:
    I wonder if they sell LEDs that are back to back in the same 2-pin package...

    A bi-color blue and green LED would be kind of boring. Red and green making yellow, is a lot better than blue and green making bluish green (or maybe greenish blue).

    Could use use a relatively high frequency, low duty cycle, PWM to keep the red LED's current in a safe range? I agree with others who are going to say this is dangerous.
  • TubularTubular Posts: 4,706
    edited 2012-01-27 12:46
    Rayman, welcome to the dark side :)

    From what I've tried blue and white leds are always safe, and charliplexing (driving both the anode and cathode of led arrays) from two or more prop pins, is safe with red and green leds.

    It's worth checking the absolute maximum values of forward current, and also power dissipation for a led, just to make sure there is plenty of headroom. But many LEDs are capable of going well beyond 20mA without complaint (worth checking the maximum power dissipation rating for continuous use)

    I'm not sure where your 40 ohm figure is coming from - did you measure that? Just curious as that's a fair bit more than what I found (27 ohms at 3v3).
  • TubularTubular Posts: 4,706
    edited 2012-01-27 12:59
    Duane Degn wrote: »
    Then I don't think I understand this question:
    Could use use a relatively high frequency, low duty cycle, PWM to keep the red LED's current in a safe range? I agree with others who are going to say this is dangerous.

    If you use a back-to-back LED, there is no point unless you can reverse the polarity to get the second color, so this necessitates using two prop pins to drive it.

    If you have two prop pins, you have ~ 54 ohms of series resistance, so even for a 2v Red LED this is a maximum continuous current of 24mA ( (3v3-2.0)/54 )and really unlikely to do any damage to the Prop or LED.
  • HughHugh Posts: 362
    edited 2012-01-27 13:02
    Tubular wrote: »
    ...unless you can reverse the polarity...

    You've no idea how long I have being wanting to get that in a thread / conversation / report / document - I guess I watched too much sci-fi in the 1970s!
  • TubularTubular Posts: 4,706
    edited 2012-01-27 13:36
    Hugh wrote: »
    You've no idea how long I have being wanting to get that in a thread / conversation / report / document - I guess I watched too much sci-fi in the 1970s!

    Lol, yeah its not the same since the advent of the microprocessor (that doesn't handle reverse polarity quite so well). Here's a mighty satisfactory list of "reverse polarity" shows and episodes.
    http://tvtropes.org/pmwiki/pmwiki.php/Main/ReversePolarity

    and I like the line about "if you want to put a modern MP3-compatible stereo in your '59 Morris Minor, a car polarity swap is a must" :)
  • RaymanRayman Posts: 14,838
    edited 2012-01-27 13:51
    Tubular, You're right... It's more like 30 Ohms per pin as per the top post...

    Duane, I'm sure PWM at even 90% would be perfectly safe with a red LED.

    But, the green is 100% safe, no matter what you do (as long as it's between 2 prop pins).

    I don't have that red/green led, but it'd be fun to get one and see if it survives.
    The one in the Parallax store don't seem to have an specifications....
  • RaymanRayman Posts: 14,838
    edited 2012-01-27 14:46
    Duane, I did just find a green-red one on Digikey that has a 2.0 V drop for both red and green.

    160-1058-ND

    I think it's because the "red" is actually "red-orange" according to the datasheet.
    Datasheet also says it may take up to 30 mA, so it should be safe.
  • Mark_TMark_T Posts: 1,981
    edited 2012-01-27 20:10
    Be aware that forward voltage of any semiconductor diode drops with increasing temperature - a small LED might be subject to thermal-runaway if powered from what is effectively a constant voltage source (or put another way get warm enough to pull more than the rated current from the Prop pin). There is also variation between batches to be considered.

    Perhaps just avoid red and orange LEDs if skimping on resistors.
  • RaymanRayman Posts: 14,838
    edited 2012-01-28 05:03
    Mark, it's been a while, but I don't remember the forward voltage of a diode being a function of temperature...
    Also, I just took a look at the datasheet for the 160-1058-ND and it shows the current going down with temperature...
  • RaymanRayman Posts: 14,838
    edited 2012-01-28 05:39
    Ok, check this out!

    Not only can you drive green LEDs with no resistors, but you can use them as ambient light sensors too!
    Go grab your Quickstart and some green LEDs because this is cool :smile:

    By just putting Vdd on the cathode and using the anode as an input, I can detect light and
    use the blue leds on the Quickstart as status.
    What's more, I think I could detect the intensity of the light by how long it takes to change state.
    What's even more, is I think I could tell the color of the light with different color LEDs...

    GreenLedPhotodector.jpg

    CON
      _clkmode = xtal1+pll16x
      _clkfreq = 80_000_000
    PUB Main
      'Light up all four green LEDs
      dira[0..1]~~
      dira[4..5]~~
      dira[8..9]~~
      dira[12..13]~~
      outa[0..1]~
      outa[4..5]~
      outa[8..9]~
      outa[12..13]~
      outa[0]~~
      outa[4]~~
      outa[8]~~
      outa[12]~~
    
      'Turn all off and then use all as ambient light detector
      'with output on blue leds on P23..p20
      outa[0..1]~
      outa[4..5]~
      outa[8..9]~
      outa[12..13]~
      outa[1]~~
      outa[5]~~
      outa[9]~~
      outa[13]~~
      dira[0]~
      dira[4]~
      dira[8]~
      dira[12]~
      
      dira[23..20]~~
      repeat
        outa[23]:=ina[0]
        outa[22]:=ina[4]
        outa[21]:=ina[8]
        outa[20]:=ina[12]
    
    1024 x 768 - 126K
  • Mark_TMark_T Posts: 1,981
    edited 2012-01-28 05:48
    Rayman wrote: »
    Mark, it's been a while, but I don't remember the forward voltage of a diode being a function of temperature...
    Also, I just took a look at the datasheet for the 160-1058-ND and it shows the current going down with temperature...

    Ah, I think I've confused the transistor temperature dependence with diodes... In the transistor charge carriers get swept away to the collector if they mount the potential barrier (and higher temperature means more charge carriers have higher kinetic energy).

    In a diode there isn't the same mechanism to grab every charge carrier. http://en.wikipedia.org/wiki/Diode#Temperature_measurements suggests the tempco can be either positive or negative for a diode and depends on the process and doping.

    However I know photovoltaic cell voltages drop with increasing temperature similar to the Ebers Moll transistor model... I think that must have confused me since the naive model of a photovoltaic junction is of a light-dependent current-source in parallel with a forward biased PN junction.
  • Mark_TMark_T Posts: 1,981
    edited 2012-01-28 06:02
    Although a bit of investigation shows that Vf does decrease for 1N4148's. for a random white LED that I found, and the Schockley diode equation implies the same basic temperature dependence for diodes as transistors...
  • HumanoidoHumanoido Posts: 5,770
    edited 2012-01-28 19:45
    For a Penguin robot, a simple PWM program drives a red LED using one pin and no resistor. The project goal was met by reducing the number of parts, the number of pins, and the voltage supplied to the LED.
  • TubularTubular Posts: 4,706
    edited 2012-01-29 04:38
    Here's a test with 7 bi-color leds (2 lead) connected across P7..P0.

    I am alternating the output such that P7..P0 is HLHLHLHL (all red), then LHLHLHLH (all green).

    I don't have a part number on these leds unfortunately, but they are milky diffused, 2 pin, and then red is much dimmer than the green at the same current (on a LED tester box). Green is about 2.1v drop and red about 1.65v.

    It's been running for a couple of hours so far, we'll see whether it dies before the tennis ends. I don't have any 1 ohm resistors handy here to check the current but will do so tomorrow. I think its about 34mA peak.
    458 x 384 - 31K
    384 x 491 - 34K
  • RaymanRayman Posts: 14,838
    edited 2012-01-29 07:19
    Humanoido, of course one can PWM with no resistors to keep average current under 20 mA, but if your code goes haywire,
    you could blow up the LED. But this way, (green LED and using 2 Prop pins) it's perfectly safe and you can't hurt anything if you
    make a mistake...

    Tubular, I'd be surprised if it lasted very long at 34 mA...
  • TubularTubular Posts: 4,706
    edited 2012-01-29 10:52
    Rayman wrote: »
    Tubular, I'd be surprised if it lasted very long at 34 mA...

    Well, 40ma is the abs max current limit per pin, according to the datasheet. So it is well within that limit. And remember each pin is connected to 2 LEDs, so the effective current through each led is about half, or 17mA. So it should run for a while, but lets find out.
  • RaymanRayman Posts: 14,838
    edited 2012-01-29 12:53
    Oh, I thought 34 mA was for one LED... A multimeter with a current function is an easy way to measure LED current BTW, in case you have one of those around...
  • TubularTubular Posts: 4,706
    edited 2012-01-29 13:21
    Yep but I think the resistance of the current shunt may distort the measurement. I'll measure with a dmm and 1 ohm resistor (which will only drop 34mv or so) and compare. So far I've just measured the pin to rail voltage and divided by 27 ohms to get a rough estimate
  • HumanoidoHumanoido Posts: 5,770
    edited 2012-01-30 06:29
    Raymond, that sounds like a logical safety factor to incorporate with hardware. Though PWM is used in software to drive LEDs with one pin and no resistors for several years now with code on projects ranging from BASIC Stamps with PBASIC to Propeller chips with SPIN - all has remained reliable. Safety checks can also go into SW. The Big Brain Propeller array currently uses a single resistor and pin for LEDs but it's possible to decommission over a hundred resistors depending on software and when adding the next array. When printed circuit board brains are designed, holes for resistors could be omitted or have a bypass depending on the tightness of code. It will soon run on mostly air, bypass capacitors and LEDs..
Sign In or Register to comment.