+ Reply to Thread
Page 1 of 3
1 2 3 Last
Results 1 to 15 of 31

Thread: PIC Transistor LED

  1. #1
    PeterDove Newbie
    Join Date
    Nov 2006
    Posts
    115

    Default PIC Transistor LED

    Hi All,

    I have seen the diagrams showing a pic pin to a transistor with a LED above the transistor getting power from its own rail. When the PIC pin goes high on the base of the transistor the LED turns on.

    There is always a resistor for the LED which I understand. But coming from the PIC pin to the transistor base is always a resistor. Now I have seen many different values for this Resistor. Can someone tell me how I work out what value to use? Is it related to the transistor itself?

    Thanks

    Peter Dove


  2. #2
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,759

    Default

    It's VERY, VERY non-critical - it has to provide enough current to switch the transistor on fully, but not enough to overload the PIC (or damage the BE junction of the transistor). So it's basically realted to the gain of the transistor - which itself varies over a huge range.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  3. #3
    Oznog Excellent Oznog Excellent Oznog Excellent Oznog Excellent Oznog Excellent
    Join Date
    Apr 2004
    Location
    Austin, Tx
    Posts
    2,765

    Default

    Yes it's related to the transistor.
    You want (Vdd-Vbe)*(transistor gain)/R > LED current.

    BE junction is a diode, so 0.7v for Vbe is generally reasonable. At higher currents it will be larger and will be somewhat lower for very small currents.
    Transistor gain varies significantly with temp, part variations, and age. Vce(sat), the voltage loss on the transistor when acting as an on/off switch, is lower when the left hand side of that eq is much larger than (like twice) the right hand side.
    I thought what I'd do was I'd pretend I was one of those deaf-mutes.

  4. #4
    PeterDove Newbie
    Join Date
    Nov 2006
    Posts
    115

    Default

    Quote Originally Posted by Oznog
    Yes it's related to the transistor.
    You want (Vdd-Vbe)*(transistor gain)/R > LED current.

    BE junction is a diode, so 0.7v for Vbe is generally reasonable. At higher currents it will be larger and will be somewhat lower for very small currents.
    Transistor gain varies significantly with temp, part variations, and age. Vce(sat), the voltage loss on the transistor when acting as an on/off switch, is lower when the left hand side of that eq is much larger than (like twice) the right hand side.
    So in this case VDD is referring to the 5V coming from PIC, or are you reffering to whatever voltage I am providing to the LED? I would assume you mean from the PIC pin.

    Thanks

    Peter

  5. #5
    Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent
    Join Date
    Oct 2006
    Location
    Rochester, NY U.S.
    Posts
    9,821
    Blog Entries
    1

    Default

    Ideally you want to chose a resistor value that will just barely cause the transistor to saturate, that will allow you the least amount of delay during turn off, using too much drive current is just going to slow turn off times and stress the controller's I/O driver. Too little current and the transistor will stay in an ohmic state and waste power.
    "Because I be what I be. I would tell you what you want to know if I
    could, mum, but I be a cat, and no cat anywhere ever gave anyone a
    straight answer, har har."

  6. #6
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,759

    Default

    Quote Originally Posted by Sceadwian
    Ideally you want to chose a resistor value that will just barely cause the transistor to saturate.
    I would suggest otherwise, certainly calculate that value - THEN increase the current substantially, to guarantee the transistor is hard on. A lot though depends on what you're trying to switch? - if it's a high current load, use more than one transistor - or a darlington.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  7. #7
    PeterDove Newbie
    Join Date
    Nov 2006
    Posts
    115

    Default

    Quote Originally Posted by Nigel Goodwin
    I would suggest otherwise, certainly calculate that value - THEN increase the current substantially, to guarantee the transistor is hard on. A lot though depends on what you're trying to switch? - if it's a high current load, use more than one transistor - or a darlington.
    Hi Nigel,

    Its just a LED, a very bright one, but about 40mA.

    Thanks for the help.

    Peter

  8. #8
    ljcox Good ljcox Good
    Join Date
    Dec 2003
    Location
    Melbourne Australia
    Posts
    2,446

    Default

    If you use an emitter follower, you only need one resistor.

    And this arrangement reduces the load on the PIC i/o compared to a common emitter circuit.

    See attachment.
    Attached Images
    Len

  9. #9
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,759

    Default

    Quote Originally Posted by ljcox
    If you use an emitter follower, you only need one resistor.
    But it's less efficient, and less useful, than the other way, which is why it's rarely seen - and usually it's a sign of poor design.


    And this arrangement reduces the load on the PIC i/o compared to a common emitter circuit.
    In what way?.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  10. #10
    ljcox Good ljcox Good
    Join Date
    Dec 2003
    Location
    Melbourne Australia
    Posts
    2,446

    Default

    Why is it less efficient? I know that Ve is about 0.7V less that Vcc, but there is still enough voltage for the LED unless it is one that needs 3V or more. But the normal LEDs only need about 1.8V.

    It reduces the load since the common emitter config needs Ib to be large enough to cope with the minimum beta in order to ensure saturation. In fact, the rule of thumb is that Ib should be one tenth Ic.

    Whereas, in the emitter follower case, Ib = Ic/beta.

    eg. if Ic = 10 mA and Beta = 200, Ib = 50 uA.

    Otherwise, using the rule of thumb. Ib = 1 mA.
    Last edited by ljcox; 22nd January 2007 at 01:24 AM.
    Len

  11. #11
    Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent
    Join Date
    Mar 2005
    Location
    Brisbane Australia
    Posts
    6,784

    Default

    Quote Originally Posted by Nigel Goodwin
    But it's less efficient, and less useful, than the other way, which is why it's rarely seen.
    Surely, all the current flows through the LED and therefore this must be the most efficient circuit?

    Mike.

  12. #12
    PeterDove Newbie
    Join Date
    Nov 2006
    Posts
    115

    Default

    Quote Originally Posted by ljcox
    Why is it less efficient? I know that Ve is about 0.7V less that Vcc, but there is still enough voltage for the LED unless it is one that needs 3V or more. But the normal LEDs only need about 1.8V.

    Otherwise, using the rule of thumb. Ib = 1 mA.
    My LED needs 3.6V.

    Peter

  13. #13
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,759

    Default

    Quote Originally Posted by Pommie
    Surely, all the current flows through the LED and therefore this must be the most efficient circuit?
    Because of the greatly increased voltage drop across the transistor, admittedly the base current will also flow in the load - but that's likely to only be tiny percentage of the load current, particularly in the case of driving a 40mA LED.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  14. #14
    ljcox Good ljcox Good
    Join Date
    Dec 2003
    Location
    Melbourne Australia
    Posts
    2,446

    Default

    Quote Originally Posted by PeterDove
    My LED needs 3.6V.

    Peter
    In that case, you need either an NPN transistor or an N channel MOSFET.

    What current do you need through the LED?

    For example, if it requires 10 mA then the base current needs to be about 1 mA. So the base resistor should be (5 - 0.7)/10 = 430 Ohm.

    If you use a MOSFET such as the 2N7000, the gate resistor is not critical.

    Use 100 Ohm.
    Len

  15. #15
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,759

    Default

    Quote Originally Posted by ljcox
    For example, if it requires 10 mA then the base current needs to be about 1 mA. So the base resistor should be (5 - 0.7)/10 = 430 Ohm.
    I'm all for making sure the transistor is 'hard on', but for driving an LED at 40mA it's hardly of any importance - anything between 1K and 10K would be fine.

    BTW, why did you calculate the base current as 10mA above? - a little slip perhaps?
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

+ Reply to Thread
Page 1 of 3
1 2 3 Last

Similar Threads

  1. RF projects with PIC...
    By raedbenz in forum General Electronics Chat
    Replies: 7
    Latest: 26th October 2007, 05:40 PM
  2. 10x10 LED array.. PIC
    By PeterDove in forum General Electronics Chat
    Replies: 8
    Latest: 25th January 2007, 05:29 PM
  3. Transistor and a PIC
    By CoTang in forum Micro Controllers
    Replies: 19
    Latest: 23rd January 2007, 02:17 AM
  4. Stupid PIC problems
    By ArtemisGoldfish in forum Micro Controllers
    Replies: 2
    Latest: 21st January 2007, 01:17 PM
  5. pic 16fxxx(HELP)
    By deansmith in forum Micro Controllers
    Replies: 5
    Latest: 17th January 2007, 09:22 AM

Tags for this Thread