Shop OBEX P1 Docs P2 Docs Learn Events
AC constant current LED driver controlled by output pin — Parallax Forums

AC constant current LED driver controlled by output pin

PropRocksPropRocks Posts: 3
edited 2011-10-08 21:26 in General Discussion
Hi all!

I'm a newbie at building circuits and using the propeller so I'm wondering if the following circuit makes sense/would work. In a nutshell I want to, with a minimum of fuss, do PWM of a constant current LED driver (1watt LED) with a propeller chip. The added wrinkle is that I want to power it all from 12V AC low voltage lighting transformer. I've simulated it with Paul Falstad's on-line circuit simulator (a very cool tool) - the link to the simulation is below and I've attached a pic of the schematic. For the simulation I had to add ground (basically so that the 3.3V pin worked correctly), but in real life I plan to use a LM7805 to regulate the rectified/smoothed 12VAC output and power the propeller board. I realize its not the most efficient circuit, but neither is a current limiting resistor (my 2nd option ATM.)

The next question is how would I go about finding an appropriate NPN transistor?

Thanks,
Rob

Link (requires Java and I've only tested with IE):
http://tinyurl.com/6g5sof9
493 x 288 - 17K

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2011-09-30 08:48
    PropRocks,

    Welcome to the forum!!

    To sustain at least 1Watt over the 60Hz ripple you need to increase the 220uF to at least 2200uF... ideally 4700uF.

    The transistor you choose, depends on the PWM duty you plan on chopping the voltage. For example if your PWM is 50% duty cycle, your transistor is going to need to handle peak currents of 191mA, while a PWM duty cycle of 30%, the transistor would need to handle 249mA peak currents....80% ; 120mA

    The question is, what are the peak currents that the LED can withstand under PWM drive? ... because essentially, the LED's would see the same current.

    The better and more efficient way to do it would be to PWM the output similar to a switch mode voltage regulator in a way that you maintain a voltage/current in parallel with the LED... additionally, replace the transistor with a mosfet ... This leads to the question, what is the voltage of your LED(s)?
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2011-09-30 09:35
    It looks to me like that circuit depends on having a transistor with a current gain of exactly 100. No, not a good idea, because transistor gain is not well controlled and is also temperature and current dependent.

    To set a fixed maximum (100%) current, the transistor should be driven in the so-called common base configuration. The resistor goes between the emitter and ground, and the 3.3V PWM comes directly into the transistor base. For a maximum current of 300 mA, the emitter resistor would be about (3.3 - 0.6)/0.3 = 9 Ω. That sets the 100% current. The 0.6 volts is the transistor base-emitter voltage, and that will vary a bit from transistor to transistor and with temperature.
  • kwinnkwinn Posts: 8,697
    edited 2011-10-01 09:17
    If you use a bipolar transistor and a resistor to ground as Tracy Allen suggested you can drive the led directly from the rectified AC.

    The rectified AC voltage is input to a pin on the propeller through a 100K resistor to provide a timing reference (the AC 0V crossing), and the output pin to the transistor is turned on for the length of time required for the current brightness level/duty cycle.

    The down side to this circuit is that you can not get to a 100% duty cycle or reach the absolute maximum brightness a led can produce, but you can get very close to 100%.

    On the plus side the circuit reduces the need for a hefty power supply regulator and large capacitors, the zero crossing signal can be used for time of day/date generation, and as a power fail indicator.
  • alex123alex123 Posts: 102
    edited 2011-10-01 19:31
    This is how I would do that

    LEDDriver.png


    You could use this MOSFET - http://www.fairchildsemi.com/ds/RF/RFP12N10L.pdf.
    Any rail-to-rail signle voltage opamp would do. Power it from from the 5V (don't forget the decoupling cap). The cap on the 12V should be as big as possible (as someone mentioned it in the previous post) otherwise the LED will blink at 60Hz. Othwerwise synchronize with 60Hz as Kwinn suggested.
    Calculate the resistors so that at 3.3V from the Propeller output pin you'll get the max current on the LED.
    Hope this helps.
    562 x 482 - 10K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-01 19:40
    alex,

    Your circuit is a constant-voltage drive. LEDs should be current-regulated, not voltage-regulated. For current regulation, put a sense resistor where the LED is in your circuit, and put the LED in between the MOSFET's drain and the positive supply.

    -Phil
  • alex123alex123 Posts: 102
    edited 2011-10-01 20:22
    Phil,

    You're right. What I wanted to achieve was to regulate the voltage across the LED which will cause the constant current. For the high power diodes brightness veries with temperature hence controlling the voltage is not such a good idea as for the lower power LEDs.
    Changing this circuit to the constant current source requires a beefy sense resistor R. Its power depends on the average voltage across it and the LED current.
    Here's the circuit update:
    LEDDriver.png
    562 x 482 - 12K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-02 07:21
    Even with low-power LEDs, regulating voltage is risky business. The reason is that the forward voltage can vary from one LED to another. IOW, the I/V curve can shift left or right. Since the slope of that curve is so steep at the operating point near the forward voltage, as it is with any diode, regulating to 1.9V, say, may result in a 20 mA current for one LED, but 50 mA for another with the same part number. So it's always better to regulate the current, whether it be for a low- or high-power LED.

    -Phil
  • alex123alex123 Posts: 102
    edited 2011-10-02 17:19
    When I mentioned the lower power LEDs I meant those whose If < 25mA. I often use these small red LEDs in the 0805 package on my boards for different purposes. With IOs powered at 3.3V I usually use 150 ohm in series to give me about 10mA (typical Vf = 1.8V). To be honest with you I have never seen a difference in light intensity across the board.
    Well, maybe I am just lucky to choose the LEDs whose I/V curves don't differ so much for the same part number... :lol:
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-02 18:58
    Your series resistor is what provides a nearly-constant current across varying values of Vfwd, rather than a constant voltage.

    -Phil
  • lanternfishlanternfish Posts: 366
    edited 2011-10-02 19:13
    You could use an LM317 wired as a constant current source. These can be configured for PWM. A Google search will revel a large number of suitable circuits.
  • kwinnkwinn Posts: 8,697
    edited 2011-10-02 22:13
    There are many ways to drive an led but the method suggested by Tracy is one of the simplest, most reliable, cost effective, and stable methods going. With the current setting resistor between the emitter and ground the transistor provides a constant current and led intensity over a wide range of input voltages, allowing unregulated voltages to be used which reduces the load on the power supply regulators.

    I have used this method for several years and it generally works well and lasts a long time.
  • PropRocksPropRocks Posts: 3
    edited 2011-10-05 09:38
    Sorry for the late response...things got kinda busy. And thanks for all the great replies! Was up late last night looking into all the different suggestions. Definately learning a lot.

    The LEDs are 3 watt RGB leds (1 watt per color) from superbrightleds.com. For red forward current is 400ma @ 2.5V. Green and blue are 350ma @ 3.4V. They vary quite a bit with voltage, are plenty bright, and I'd actually prefer to run them around 250ma.

    I'm concerned about smoothing caps causing current spikes on the 12VAC power wire (and hence voltage drops.) I'm sorry I didn't describe better the application, but I want to control 6 RGB floods (so a total of 18 LEDs) by each propeller, and I'll have multiple propellers (probably around 3 propellers/18 floods/54LEDs total.) Everything will be powered by the same 12VAC/300 watt low-voltage lighting transformer, but the propeller boards will each have their own rectifiers, smoothing caps and regulators (ie. not the rectified output used by the LEDs.) Because of the # of LEDs I'm trying to keep it simple/parts count low for their PWM control. I'm OK if the LEDs have a 60Hz flicker, and I want to use a 12VAC low-voltage lighting transformer for safety reasons (don't like the idea of 110VAC or 12V/25A power running through the yard.)

    Tracy, if I understand your reply I would adjust the schematic as shown in the attachment? Running it in the simulator I get ~2.8ma current on the 3.3V output pin. Out of curiosity I deleted the 220uF smoothing cap (for the reason above - it lowered the 12VAC current spike from amps to 284ma), but the issue of the propeller output pin trying to source all 287ma when the rectified output goes to 0V comes up. I'm worried that even if I keep the smoothing cap what happens to the propeller if the cap goes bad? Is there anyway to protect against that and/or run without the smoothing cap, or would doing so not damage the propeller's output pin?

    Rob
    493 x 294 - 15K
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2011-10-05 22:48
    The propeller would not and could not supply all 280 mA when the supply voltage goes to zero. Even at that point in the cycle, the prop pin would still only be sourcing about 2.8 mA. (That assumes that the transistor gain is x100. A random transistor you pick out of a bin might have a gain anywhere from x30 to x300, or more or less depending on the type of transistor.) To be on the safe side, I would recommend putting a resistor of about 100 ohms in series between the prop pin and the base of the transistor. That will drop another 0.3 volts (assuming transistor gain=100).

    The circuit is not power efficient and you have to include power in your design considerations. Supposing that the emitter resistor is 10 ohms, and the LED current is steady 250 mA, the power in the resistor will be 0.625 W, so you'd want to use at least a 1W resistor. Then there is the power the transistor has to handle. It has to handle the same current as the LED and resistor, and it holds off the 12V power - 3V across the LED - 2.5 V across the 10Ω resistor. That is 6.5 volts. And the power is 6.5 V * 0.25A = 1.625 W. So, that calls for a good size transistor, maybe a metal plate heat sink. All this is back-of-envelope estimate, and the power will be less for PWM at lower duty cycles. It could be less demanding with a lower supply voltage, say 8V instead of 12V.
  • kwinnkwinn Posts: 8,697
    edited 2011-10-06 19:24
    PropRocks, the circuit Tracy has proposed with a 100 ohm resistor between the prop pin and the transistor base, and a 10 ohm resistor between the emitter of the transistor and ground should work well for your application.

    The worst case power dissipation for the resistors would be 0.58W for the red led and 0.56W for the blue or green led. For the transistors worst case power dissipation would be 1.53W for the red led and 1.35W for the green or blue led.

    One watt resistors and 3 watt transistors with a heatsink would be adequate for that. You might want to consider using a darlington transistor so as not to have any concerns regarding the transistor gains. Lots of choices in the 5-25W range and well under a dollar.
  • PropRocksPropRocks Posts: 3
    edited 2011-10-07 10:45
    I originally toyed with the idea of using buck switching regulators (for efficiency) but ruled them out due to cost. Plus, if I go this route, I could possibly add 1 or 2 more LEDs in series - they cost a bit but it is a future option JIC I want/need more brightness (vs spending more money to make a single LED more efficient.)

    Thanks again for all your help!
    Rob
  • Mark_TMark_T Posts: 1,981
    edited 2011-10-08 11:40
    Even with low-power LEDs, regulating voltage is risky business. The reason is that the forward voltage can vary from one LED to another. IOW, the I/V curve can shift left or right. Since the slope of that curve is so steep at the operating point near the forward voltage, as it is with any diode, regulating to 1.9V, say, may result in a 20 mA current for one LED, but 50 mA for another with the same part number. So it's always better to regulate the current, whether it be for a low- or high-power LED.

    -Phil

    More importantly with these LEDs is the issue of thermal run-away. Diode forward voltage drops with increasing temperature, so if you drive a constant voltage then increasing temp leads to rapidly increasing current, leading to increasing temp...

    I'm also worried about the heatsinking requirements of this whole thread - 250mA at 16Vdc or so is 4W in the transistor (12Vac rectifies to about 18V, less LED forward drop...) Why use 12Vac for a single LED when 5Vdc would do?
  • kwinnkwinn Posts: 8,697
    edited 2011-10-08 21:26
    Mark_T wrote: »
    More importantly with these LEDs is the issue of thermal run-away. Diode forward voltage drops with increasing temperature, so if you drive a constant voltage then increasing temp leads to rapidly increasing current, leading to increasing temp...

    I'm also worried about the heatsinking requirements of this whole thread - 250mA at 16Vdc or so is 4W in the transistor (12Vac rectifies to about 18V, less LED forward drop...) Why use 12Vac for a single LED when 5Vdc would do?

    The 4 Watts is the peak dissipation of the transistor. With a rectified AC waveform the worst case average dissipation is 1.53W and 1.35W - see post #15. Using 5V would work but it requires a more expensive power supply. Since he already has a 12VAC transformer for outdoor lighting it makes sense to do it this way. It also allows for putting more than one led in series.
Sign In or Register to comment.