Switch LED on negative input

Discussion in 'The Projects Forum' started by Man_in_UK, Feb 16, 2015.

  1. Man_in_UK

    Thread Starter Senior Member

    May 13, 2008
    132
    0
    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
     
  2. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    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?
     
  3. #12

    Expert

    Nov 30, 2010
    16,292
    6,804
    Simpler...
    The questionable resistor depends on what color of LED you are using.
     
  4. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Many LEDs are sufficiently bright to be used as a visual indicator at 5mA.
     
    Last edited: Feb 16, 2015
  5. Man_in_UK

    Thread Starter Senior Member

    May 13, 2008
    132
    0
    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.
     
  6. Man_in_UK

    Thread Starter Senior Member

    May 13, 2008
    132
    0
    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!
     
  7. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Is not the Arduino running on 5V?
     
  8. Man_in_UK

    Thread Starter Senior Member

    May 13, 2008
    132
    0
    There is 5 v on the PCB but the ARM7 chip does not use any, just 3.3
     
  9. Dodgydave

    Distinguished Member

    Jun 22, 2012
    4,986
    745
    Make R3 1k,
     
  10. #12

    Expert

    Nov 30, 2010
    16,292
    6,804
    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.
     
  11. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    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: Feb 16, 2015
  12. Man_in_UK

    Thread Starter Senior Member

    May 13, 2008
    132
    0
    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
     
  13. Man_in_UK

    Thread Starter Senior Member

    May 13, 2008
    132
    0
    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
     
  14. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    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.

    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.
     
Loading...