Re: LED & Resistor befuddlement

From: Peter Jakacki (peterjak_at_tpg.com.au)
Date: 06/03/04


Date: Thu, 03 Jun 2004 11:44:28 +1000

BPing :)

Spehro Pefhany wrote:
> On Wed, 02 Jun 2004 13:06:46 -0400, the renowned rickman
> <spamgoeshere4@yahoo.com> wrote:
>
>
>>Mike Turco wrote:
>>
>>>I thought this was going to be simple. I have a controller, an LED, a
>>>resistor and a socket. Its a five volt circuit.
>>>
>>>I want to plug the LED into the socket in a board. The controller needs to
>>>know whether or not the LED is plugged in, and if the LED is plugged in, it
>>>needs to be able to turn it on and off.
>>>
>>>One issue is that the forward voltage of just about any LED puts all the
>>>voltages out in the middle of no-mans land in terms of logic levels.
>>>
>>>Anyway, I came up with a solution, but it seems a little too complex and I
>>>get the feeling I'm missing something. My solution is here:
>>>http://miketurco.com/123/ledbef.gif .
>>>
>>>Basically, if you put a low on the input and there's an LED in the socket,
>>>the LED will turn on and you'll get a low on the output. If there's no LED,
>>>then you'll see a high on the output.
>>>
>>>Is there a way to accomplish this with one i/o pin? Any way to save a part?
>>
>>Seems to me you guys are all over thinking the problem... or I am
>>missing something important.
>>
>>How about just adding one resistor and using the IO pin as an input when
>>you want to check for the presence of the LED and as an output when you
>>want to drive it?
>>
>> ___
>> |
>> |
>> -
>> | | R1
>> | | current
>> - limiter
>> | ~330 ohms
>> |
>> ---
>> \ / LED
>> _V_
>> |
>> +----------> To MCU IO pin
>> |
>> -
>> | | R2
>> | | Light
>> - Pulldown
>> | ~10 kohms
>> |
>> _|_
>> \ /
>> V
>>
>>With this circuit the IO pin will be high if the MCU is not pulling it
>>down and the LED is installed. If the IO pin is not driving it low and
>>no LED is plugged in, the IO pin will be low by R2. The IO pin can
>>drive low to turn on the LED.
>
>
> This will work with good margin for some LEDs and some input buffers,
> and not at all or marginally with other choices. For example, a
> super-bright green LED will yield about 2.2-2.3V typically at the
> input with the above circuit and 5V Vdd. Some input buffers need Vdd *
> 0.8 worst-case, others are okay at around 1.9-2.0V (the "TTL" type).
>
> Since this circuit is "measuring" the LED presence with 250uA rather
> than 10-20mA, it has less drop and will work with more LEDs than the
> circuit I showed, however it has one more component.
>
> Best regards,
> Spehro Pefhany

I would skip the pulldown resistor altogether and simply drive the
output low for a few cycles then switch it back to an input.
The CMOS inputs have more than enough capacitance and a low enough
leakage to hold the charge from the last driven state.

After driving the pin low and floating with no led connected you should
indeed find a logic low on the input even for 100's of microseconds
afterwards.

Normally I use this method for reading dip switches etc where the lead
length is very short. If you want to run it a bit longer you should
shield it somehow.

After driving the pin low and floating it when a led is connected you
should see the input charging up to within Vdd in a very short period.

Method:
1. Drive pin low and switch to output mode
2. Hold for a few cycles
3. Switch pin to input mode
4. Wait for a few cycles
5. Read the input - low = (no led)

This way you can still drive the LED with a high current and you don't
need any additional components.

--
Peter Jakacki


Relevant Pages

  • Re: LM3914 --help :/
    ... The output current for the LEDs is a 10x current mirror of the output ... of the REF OUT pin. ... voltage of 1.25, ...
    (sci.electronics.design)
  • TECH: Stern or Sega Whitestar board info
    ... There are 2 leds on the CPU/Sound board. ... trying to run CPU version 1.03 with .90 sound roms. ... it comes from pin 19 on U6 of the driver board ... you can verify the signals on the DS1232 chip. ...
    (rec.games.pinball)
  • Re: Front panel headers
    ... red & white hdd led 2 pin Can I assume that red is positive? ... purple & white reset switch 2 pin Can I assume that white is gnd? ... so the wire and crimp pin can be pulled out. ... The LEDs are polarized, and can be installed the wrong way without ...
    (alt.comp.hardware.pc-homebuilt)
  • Re: Calculating resistors required
    ... > PIC output pin circuitry. ... LEDs as: ... is that a switch would then give logic 0. ... You stick your load (motor, lights, electric-chair or whatever ...
    (sci.electronics.basics)
  • Re: Calculating resistors required
    ... voltage to the output level and how much margin the regulator has to ... >> a time) LEDs are not voltage controled devices, ... >> switch so that it shorts the pin directly to ground when pressed. ...
    (sci.electronics.basics)