Re: LED & Resistor befuddlement
From: Peter Jakacki (peterjak_at_tpg.com.au)
Date: 06/03/04
- Next message: Ben Bradley: "Re: Bit width?"
- Previous message: RM: "Re: Any volunteer projects for embedded software?"
- In reply to: Spehro Pefhany: "Re: LED & Resistor befuddlement"
- Next in thread: CBFalconer: "Re: LED & Resistor befuddlement"
- Reply: CBFalconer: "Re: LED & Resistor befuddlement"
- Reply: Mike Turco: "Re: LED & Resistor befuddlement"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Ben Bradley: "Re: Bit width?"
- Previous message: RM: "Re: Any volunteer projects for embedded software?"
- In reply to: Spehro Pefhany: "Re: LED & Resistor befuddlement"
- Next in thread: CBFalconer: "Re: LED & Resistor befuddlement"
- Reply: CBFalconer: "Re: LED & Resistor befuddlement"
- Reply: Mike Turco: "Re: LED & Resistor befuddlement"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|