Switch LED on negative input

Thread Starter

Man_in_UK

Joined May 13, 2008
192
First let me say sorry for not being clever enough to have any confidence in this circuit.

I want to use a 3.3v logic input to trigger an LED while it is at logic 0. Is this the right way to do it?


http://i195.photobucket.com/albums/z278/man_in_uk/neg sw_zpsazw39dzf.jpg

R1 = 3.3k giving 1ma across opto output
R2 = 100 to 200 ohm
R3 = 5k to 10k

I will not be using a MX6 LED but it was the first symbol I found.

Please let me know if I have made any obvious errors
 

MikeML

Joined Oct 2, 2009
5,444
The LED is backwards

Must you use the opto-isolator? or can the LED be powered from the 3.3V power supply that is driving the the upsteam logic that drives the input LED on the opto-isolator?

How much current can the upsteam logic source and sink at 3.3V?
 

Thread Starter

Man_in_UK

Joined May 13, 2008
192
The LED is backwards

Must you use the opto-isolator? or can the LED be powered from the 3.3V power supply that is driving the the upsteam logic that drives the input LED on the opto-isolator?

How much current can the upsteam logic source and sink at 3.3V?
Yes, I always draw LEDs the wrong way, but not intentionally.

The opto has to be there. It is triggered from a nasty AC source and its output is connected directly to a logic input of a processor. I had first put an LED directly on the logic line to ground via a resistor but the pull up resistor was not allowing enough current. I had thought about lowering the value of the pull up resistor but I do not want to put more strain on the opto.

The upstream source is an input pin on a Arduino. The opto does all the sink and R1 does all the pulling up.
 

Thread Starter

Man_in_UK

Joined May 13, 2008
192
Simpler...
The questionable resistor depends on what color of LED you are using.
I think that 100 ohm will give around 5ma on the LED. It only has to be a visual indicator of the input state for fault diagnosing.

I am more worried about getting R3 correct but I realise that is going to depend on the PNP that I chose!
 

#12

Joined Nov 30, 2010
18,224
I am more worried about getting R3 correct but I realise that is going to depend on the PNP that I chose!
Two reasons why R3 seems difficult:
1) You aren't paying attention to what anybody here tells you.
2) You put your LED on the emitter side of the transistor.
 

MikeML

Joined Oct 2, 2009
5,444
Scratch the earlier circuit I posted and replace it with this:

7.gif

The opto-coupler only needs to sink 700uA. Since its CTR is ~ 100%, that makes it pretty foolproof.
 
Last edited:

Thread Starter

Man_in_UK

Joined May 13, 2008
192
Two reasons why R3 seems difficult:
1) You aren't paying attention to what anybody here tells you.
Not intentionally.
I did not fully understand your first diagram, I focused on the 82? and thought that it was not answering my problem. Finding the right current to drive the LED is not my problem but finding the right way to switch it .....is.
After thinking about it, your circuit is exactly the same as mine, only fixed and working correctly.

Cheers
 

Thread Starter

Man_in_UK

Joined May 13, 2008
192
Scratch the earlier circuit I posted and replace it with this:

The opto-coupler only needs to sink 700uA. Since its CTR is ~ 100%, that makes it pretty foolproof.
Thanks for such an in depth answer. Can I ask a few questions ?
I have 'Everycircuit' simulator (crap but free) and if I switch the LED in the same way as your circuit, it does not work. Even without a resistor feeding the transistor gate, I lose current across the transistor.
Is this a limitation of my rubbish circuit sim?
Is it OK to not have a current limit resistor on the gate?

Cheers
 

MikeML

Joined Oct 2, 2009
5,444
Thanks for such an in depth answer. Can I ask a few questions ?
I have 'Everycircuit' simulator (crap but free) and if I switch the LED in the same way as your circuit, it does not work. Even without a resistor feeding the transistor gate, I lose current across the transistor.
I'm not sure what you mean by that. Note that in this forward biased PNP transistor, the current into the emitter (same as the LED current) is ~= to the current outof the collector, which flows to ground. The current out of the base is the collector current (~5mA)/Hfe, so is only about 50uA. The current through the 4.7K pull-up is much higher than that: ~600uA.

Is this a limitation of my rubbish circuit sim?
Is it OK to not have a current limit resistor on the gate?
Don't know about your sim. LTSpice, which is what I use, is a free download at Linear.com.

As mentioned above, the base current out of the transistor is tiny, and since the transistor is acting as an emitter follower, its base must be driven as close to ground as possible, so a resistor would prevent that. To turn the LED off, the base of the transistor is pulled all the way to 3.3V, which is also the logic high input to the port pin.
 
Top