How to drive Infrared LED off PIC

Discussion in 'Embedded Systems and Microcontrollers' started by JDR04, Jan 15, 2014.

  1. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    Hi Folks, hoping some one can help me out here and tell me if my circuit is correct.

    The objective is to drive an IR LED at 38Khz off a 12F683 PIC. This will eventually be used in a infrared breakbeam circuit. I'm aiming at achieving a range of about 10m so I need the IR LED to be flashed as efficiently as possible. I'm just not sure if my circuit is the best way and if my component values are correct.

    I'm also not sure if the 2N2222 transistor is the best to use for this application? I've attached my circuit and the two datasheets for you to look at but I'm pretty sure some of you will know the answers before looking at them.

    Output voltage of PIC is 4.02V

    Infrared LED requires 130mA (I will use up to 125mA)

    2N2222 hFE or Beta is 75?

    My calculations are;

    R2 = 5V/125mA = 40. 39 Ohms resistor to be used.

    R1 = 4.02V-0.7V =3.32V.

    Beta for 2N2222 is 75.

    125mA/75=1.66mA.
    (So base of tansistor needs 2mA to switch on properly)

    3.32V/0.002mA = 2010 Ohms. (Use 2K resistor)

    I'd really appreciate somebodies comments and help on this one.

    Thanks a lot - John
     
  2. ericgibbs

    Senior Member

    Jan 29, 2010
    2,499
    380
    hi,
    If you are driving the 2N2222 into saturation, assume a Beta of 10 to 20.
    I usually consider it as 20.

    E.
    This d/s has the graphs. Fig #11

    EDIT:
    Re-looking at your calc's you should deduct the Vfwd drop of the IR diode from the 5V supply when working out the series
    resistor, typical Vfwd for IR is ~ 1.5V.
     
    Last edited: Jan 15, 2014
    killivolt likes this.
  3. pwdixon

    Member

    Oct 11, 2012
    488
    56
    I would use a logic switching MOSFET it would be much more efficient than a standard NPN transistor and you could forget all the worries about transistor gain.
     
    JDR04 likes this.
  4. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    You can move R2 to between the emitter and ground and then size the R1 to just big enough to protect the PIC if the LED fails. That way you can run the PIC from a voltage regulator and power the diode from unregulated power, the current in the LED will stay the same. R1 current will only be about 1mA with a 2n2222
    If you are using unregulated power for the LED then the transistor may need to be bigger, maybe heatsinked, but doing it the original way with a regulator feeding the LED and PIC then you need a bigger, heatsinked regulator.
    [​IMG]
     
    JDR04 likes this.
  5. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    Thanks, so my theory is correct except for the 1.5V forward drop on LED?
    Thanks a lot for your help
     
  6. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    I'll look into the Logic switching MOSFET.Never worked with them before but always keen to learn. Thanks for that
     
  7. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    OK, I think for this excercise I'm going to stick to a simple NPN Transistor to act as a switch. I think I need to learn and master this techniquw first.

    So, a suggestion was made that I would need something bigger than a 2N2222. Could somebody make a few suggestions.

    The other thing I was wondering about was....... would a transistor be able to handle switching at 38Khz. I mean are they that fast!!!

    Thanks for your help guys - JDR04
     
  8. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    The transistor used in remote controls to drive the LED is usually better than a 2N2222, maybe a BC337 or equivalent rated for 1A.

    Most remote controls pulse the LED at about 500mA to 1A range, with a very short duty cycle. That keeps the average power consumption down and average LED power (and heat) down, while giving a long range due to the high instantaneous pulse power.
     
  9. John P

    AAC Fanatic!

    Oct 14, 2008
    1,632
    224
    You can also run the LED in bursts of 38KHz rather than a continuous output. In fact that's what you should do, because a TV remote receiver (which I assume you'll use) has an automatic gain circuit, and if it's constantly stimulated, it'll turn the gain down until it starts to lose pulses. But anyway, if you run the IRLED intermittently, say 16 cycles on and then 112 off, you're running on 1/8 of the power you'd use if the output were continuous. The only drawback would be that if you have some small fast object that breaks the beam, it could pass through while the IR signal is off. But at something like 300 bursts per second, it's not too likely.

    If the transmitter side of this system runs off a battery, it would be better to use an inductive current-control circuit than just a dumb resistor. Again, the reason is to save power.
     
  10. ericgibbs

    Senior Member

    Jan 29, 2010
    2,499
    380
    hi jd,

    If you decide to go to the MOSFET driver option, as you have a 5V supply rail, choose a FET suitable for 5V Gate operation.

    As mentioned, if using a TSOP receiver, note the pulse burst specification required. [ I have highlighted the section]
    E.
     
    killivolt likes this.
  11. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    While the 800 mA rating of a 2N2222 has enough capability to handle the LED current what I have found is the saturation voltage is unspecified.

    One company I worked for used these to control some rather large relays. I have seen the sat voltage vary from <0.1V to .5V or more... and these were military grade JAN (JANTX?) devices. We had to control which manufacturer we used and additionally test each one before using it on the board.

    SO... the device size is fine, just pick something rated for it's saturation characteristic.

    (Note: just found the sat spec for Microsemi's device: 0.3V max. Not too shabby.)
    (I do remember the mil device having no spec at all for saturation, so we were stuck with all the ones we bought that didn't work in our circuit.)

    Mark77's idea is very good. It is essentially a current sink where the current is decently controlled. It is great when there is alot of voltage to burn off, it wastes at least the VCC of the PIC before leaving anything for the LED. However, if the LED voltage is >> then the PIC voltage it will drop the extra across the transistor and emitter resistor.

    Works nice in PWM circuits. That's where I used it.
     
    Last edited: Jan 16, 2014
    JDR04 likes this.
  12. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    Hi Ericgibbs, thanks for the info. Really appreciate it. I do plan to use the bursts as your info recommends but first I just want to make sure I'm getting the basics righ.

    I think I'm going to go the transistor route first just so I get to understand that method. Then I'm going to try the MOSFET method as you suggested. Hopefully by then you will be around to help me out! Thanks again - JDR04
     
  13. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    Appreciate your info The RB. Thanks a lot.

    So, just to see I undertsand this correctly.

    The IR LED I'm usinf gives a maximum current rating of 130mA. At the moment my PWM program is set to 90% duty cycle. Before these postings I only understood that the longer my duty cycle is the "brighter" the IR LED is hence I would gain more distance?

    From what I gather from your posting, I can actually reduce the duty cycle substantially but increase the mA. This would save on power and reduce heat?? Just want to make sure I got this right before I move onto the burst durations etc.

    Really would appreciate your guys comments Thanks again John
     
  14. ericgibbs

    Senior Member

    Jan 29, 2010
    2,499
    380
    hi jd.
    I have modified an old IR TX diagram to show the 135mA LED current, using a 2N2222 or a 2N7000

    The 2N7000 is not 'ideal but works well enough at Vgs = 5V for your App.
    E.
     
    absf, killivolt and JDR04 like this.
  15. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    If you want a higher power transistor (you only really need one if you are going for a higher current or using it to drop from a higher voltage) you can get a TIP31C from Maplin. My picture seems to have vanished, I did something wrong with the attachment. Here it is again.
    [​IMG]
     
  16. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    Thanks Markd77. Appreciate the drawing to help me out.

    Going by your drawing the IR LED would be connected straight up to the voltage rail of 5V ?? Am I reading it right?

    Sorry to be a pain, but, I would really appreciate you explaining how you calculated it out.

    Thanks so much for your time - John
     
  17. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    I do not believe Mark's left side drawing using the 5V rail and an emitter resistor will work. Even as illustrated it only has .4V across the LED, probably way too little.

    Moving the emitter resistor into the collector path would be better for a 5V rail.
     
    JDR04 likes this.
  18. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    You are right, I chose too low a forward voltage for the IR diode. The 39 ohm resistor has to drop 39 X 0.107 = 4.1 V so for this current it won't work for a LED with a 1.5V forward voltage, sorry.
    It is only going to work for about 0.8V or less if the base is supplied with 5V.
     
  19. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    90% duty is about the worst choice. The longest duty would be 50%, allowing you to use more mA during the ON period.

    Commercial remotes run 10-20% duty, and peak currents can be high.

    An example would be 1A peak current, at 10% duty, giving an average 100mA though the LED.

    However I suggest you start with a much lower peak current until you test the distance then slowly increase the peak current by substituting lower value resistors. You might still blow an LED or two. ;)

    Another option for improving distance is to use multiple emitters (more than one LED) as this increases light output and area for the same consumed current.
     
    JDR04 likes this.
  20. ericgibbs

    Senior Member

    Jan 29, 2010
    2,499
    380
    hi Mark,
    I thought you may like to see what LTSpice shows for your circuit.
    I have adjusted the 0.4Vfwd to 1.5Vfwd for the IR LED, also tweaked the emitter resistors to give the 135mA the OP was asking.

    jd,
    The values shown on the circuit are for 'worst case' DC analysis only, using PWM the values will be lower.
    E.
     
    killivolt and JDR04 like this.
Loading...