mattius
Posts: 87
Joined: Thu Jun 14, 2012 9:55 am

Driving a single high power LED using PWM

Thu Jan 30, 2014 7:44 am

Right so i want to pulse a high power LED on for 1-2secs then off for a while programaticaly.

The GPIO pins can however only output 16mA at 3.3V, the LED requires 3A at max current over 3.3V

Given the power of this LED i want some way of controlling the brightness so was going to use PWM.

But its got me stumped as to how i could do it, usually i would use a relay with the GPIO as the trigger, but i don't think PWM will work over a relay nor can i find a relay which will work with the GPIO amperage and handle the 3A for the LED.

I know there are expensive driver boards but they are for multiple LEDs and i just want to drive one cheaply.

Any ideas?

User avatar
rpdom
Posts: 16972
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 8:10 am

Transistor? Probably a MOSFET to handle that load easily. It needs to be one that can switch on a little below 3.3v.

mattius
Posts: 87
Joined: Thu Jun 14, 2012 9:55 am

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 8:26 am

So something like this?

http://docs-europe.electrocomponents.co ... 04e58d.pdf

I believe i need to use additional protection to the circuit using a mosfet as opposed to a relay.

Is protection diodes enough on the gate and source?

User avatar
joan
Posts: 14876
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 9:03 am

Have a look at the ULN2003. You may be able to common up the inputs and outputs to get those sorts of currents. You'd have to check the specs for how much would be drawn from the 3.3V line to drive the inputs. You could apply PWM to the driving gpio(s).

They cost about 30p (excluding P&P).

mattius
Posts: 87
Joined: Thu Jun 14, 2012 9:55 am

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 11:29 am

Cheers i will have a look,

Is there anything wrong with the mosfet?

User avatar
joan
Posts: 14876
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 11:37 am

mattius wrote:Cheers i will have a look,

Is there anything wrong with the mosfet?
Not that I'm aware of. I'm not competent to judge. I mentioned the ULN2003 as I have some and they are easy to interface to the Pi.

https://www.youtube.com/watch?v=f1Y_fYtRZnI

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 11:50 am

Yeah I was going to suggest the ULN... chips too (there are several.) They're cheap, generally have seven or eight outputs so you can use several channels in one package, they're breadboard friendly, and they can drive small motors, relays and solenoids provided the current isn't too high.

mattius
Posts: 87
Joined: Thu Jun 14, 2012 9:55 am

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 12:09 pm

Ok cool, not got any use of transistor relays hence my doubt

Is this how i wire it up?
Attachments
Untitled Sketch_schem.jpg
Untitled Sketch_schem.jpg (19.89 KiB) Viewed 4321 times

User avatar
joan
Posts: 14876
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 12:15 pm

Not really as the Pi can only supply circa 50 mA on the 3.3v line. You really need a separate power supply for the LED.

Neither do you have to use the hardware PWM gpio. You can get PWM on any gpio you want (may be less flexible though).

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 12:25 pm

Also I think the chip needs its 0V connecting to the earth, and its "COM" needs connecting to the +V supply you're using. (These are needed internally for the chip itself for some reason.)

You also should probably have a resistor in series with the LED to limit the current, unless the LED can take the full voltage of the power supply. I'd just connect it all directly to the +5V supply of the raspi if possible, with the appropriate resistor on the LED to stop the full 5V burning it out.

(Calculating the appropriate resistor depends on the voltage & current it needs to dump - depends what the LED is rated at.)

EDIT: maybe have a look at the circuit on p7 of this:
http://www.picaxe.com/docs/picaxe_manual3.pdf
Last edited by Ravenous on Thu Jan 30, 2014 12:27 pm, edited 1 time in total.

mattius
Posts: 87
Joined: Thu Jun 14, 2012 9:55 am

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 12:26 pm

Then im confused as to how to wire it, how do i feed an external source into it?

Excuse my dum head, im off with the flu at the moment

Im not using the hardware PWM pin so i might as well use it.

The LED can take 3.3V at 3.2A so more than handle the full voltage im supplying it

User avatar
joan
Posts: 14876
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 12:34 pm

The line which goes to 3.3V would instead go to the positive of the power source. The negative (ground) of the power source would be connected to the ground of the Pi and the ground of the chip.

Can you drive the LED with more than 3.3V? A spec might be useful.

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 12:36 pm

Oh by the way, in the circuit I mentioned above, I have only just realised that the LED is pretty serious! Running it off 5V will mean the resistor has to dump a few watts of power I think - depends on the max voltage of the LED, as Joan just mentioned.

Definitely don't run it off any of the rapi's voltage outputs anyway.

I'm not sure the standard ULN chips can actually handle this sort of power, at least not for long without overheating! There is a limit for each channel, but also a combined total limit for all channels and it's far short of 3A. It might work provided you're using the PWM to keep it dimmed well below its full power at al times. I would start by experimenting with ordinary low power LEDs first to make sure your software and wiring is reliable!

Otherwise it might be back to separate transistors again...

mattius
Posts: 87
Joined: Thu Jun 14, 2012 9:55 am

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 12:44 pm

Ok thanks

So looking at that diagram i seem to have it almost right except i need the 0v and external source

Each of the pins of the 2003 give 0.5A so to achieve 3A i need six



Heres the data sheet of the LED
http://www.led-tech.de/produkt-pdf/cree/XLampXM-L.pdf

Im planning on running a 1Ohm 3 Watt resistor to it to lower the voltage to 3V
Attachments
Untitled Sketch_schem.jpg
Untitled Sketch_schem.jpg (23.92 KiB) Viewed 4283 times

User avatar
joan
Posts: 14876
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 12:50 pm

mattius wrote:Ok thanks

So looking at that diagram i seem to have it almost right except i need the 0v and external source

Each of the pins of the 2003 give 0.5A so to achieve 3A i need six



Heres the data sheet of the LED
http://www.led-tech.de/produkt-pdf/cree/XLampXM-L.pdf

Im planning on running a 1Ohm 3 Watt resistor to it to lower the voltage to 3V
We don't know how much the ULN will supply when all outputs are active. There may be a total for the chip which isn't shown on the specs I've seen. In fact you would only get about 2/3rds of the rated 500mA per driver as that's all the 3.3V logic input will supply (according to some note I read once).

Are you using this industrially? 3 amps will be fairly bright.

User avatar
joan
Posts: 14876
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 12:53 pm

At 3V it'll take an amp (according to my reading of the spec).

mattius
Posts: 87
Joined: Thu Jun 14, 2012 9:55 am

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 12:57 pm

I don't need to power this at 3amps, however i want to be able to control the brightness i.e. in different situations more brightness would be required, i estimate at max i probably only need 1.5amps but would like to be able to goto 2.

It will only flash for 1 second then off for 5 in a run of 3. Then off for 60seconds so it shouldn't overheat as its not going to be on for long.

Is the mosfet a better example then, as far as i understand it works the same as a relay using only the trigger to switch an external source on and off.

mattius
Posts: 87
Joined: Thu Jun 14, 2012 9:55 am

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 12:58 pm

Of course i could be going down the totally wrong track with PWM i just want to limit the current over the LED between 0.7A and 1.5A originaly i was thinking of running a POT

User avatar
joan
Posts: 14876
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 1:00 pm

PWM will let you vary the effective voltage and consequently the brightness.

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 1:04 pm

Here's a datasheet for the Texas version:
http://www.ti.com/lit/ds/symlink/uln2003a.pdf
It seems to be saying 2.5 Amps is the limit (or "a limit") for all outputs wired together - buried in a table on page 4 - and there's a further note below the table about calculating the max dissipation.

It should work (I'd certainly try it).

The biggest thing I ran on one of these was a 12V 10W lamp, so les than an amp, and didn't notice any heat there. I think it'll be OK overall, you can always check for excess heat by applying the standard digit diagnostic :)

mattius
Posts: 87
Joined: Thu Jun 14, 2012 9:55 am

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 1:44 pm

cool, so my last diagram should work?

should i put in any kind of protection for the pi, like a protection diode or the likes?

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 1:56 pm

Your last diagram is almost complete - the only thing I think we may have missed is that the power supplies for the raspi and for the LED (if separate) should both have their 0V connections wired together. So the voltage signals throughout the circuit are always relative to one earth/0V signal.

The protection diodes are built into the ULN chips. In this case they wouldn't matter anyway, they're really only for inductive loads like motors, relays, solenoids where the coil generates a spike of voltage wehn turned off. These can blow the transistors in the driver chip. LEDs aren't inductive much if at all.

EDIT: by the way if you're doing this on a breadboard or something, the quickest way to test without the pi is take the driver's input wire, and touch it to 0V or to the 3V-5V (whatever it is) supply. This should simulate the high/low signals coming from the raspi. (Don't have the pi connected at all when doing this, or you'll be shorting out its pin!)

mattius
Posts: 87
Joined: Thu Jun 14, 2012 9:55 am

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 2:26 pm

The raspberry pi will both be powered from the same source ( a 5V 3A UBEC ) to start with. Although i may up this to 4A should i need more brightness out the LED. With the connection just split between the two (the PI should always take its 1.5A yes? or is there a chance the LED will try and take all 3A)

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 2:27 pm

Personally using ULN2x03 chips for everything involving a bit of power is like "I have a hammer so everything is a nail"

This is much better suited to a FET like FND327N Id of 2A continuous 8A peak Rds of 50 to 80 mR at Vgs of 3V

Before you say but its surface mount I have mounted many surface mount devices of various sizes on stripboard and in one test using one of these for crude PWM control of an electric razor. Example of stripboard mounting of 0805 passives and SO-8, SOT-23 are easy to mount on stripboard
Attachments
SMDstripboard.jpg
Example of SMD mounting on stripboard on other side is a standard DIL chip
SMDstripboard.jpg (58.29 KiB) Viewed 4185 times
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

mattius
Posts: 87
Joined: Thu Jun 14, 2012 9:55 am

Re: Driving a single high power LED using PWM

Thu Jan 30, 2014 2:30 pm

Here is a more complete diagram, although i will probably power the pi through the microusb port to keep the fuse protection which powering through gpio doesnt give.

Edit:

Actually looking at it, i could just put the resistor on the line powering the 2003 couldn't i, that would keep that whole circuit 3V
Attachments
Untitled Sketch_schem.jpg
Untitled Sketch_schem.jpg (25.48 KiB) Viewed 4187 times

Return to “Other projects”