Using a Picaxe and Mosfet to current limit a high power LED

JPU

Senior Member
Hi All

I have read a few articles about using a PIC to limit the current to an LED by measuring the voltage drop across an LED using the ADC input pin. The current to the LED is controlled using the pwm command.

The PWM output to the LED is adjusted to control the length of time the LED is on by measuring the voltage drop across the LED and comparing it to a set value. By using this method apparently the brightness can also be controlled?

I was wondering if any one has tried this and may have a link to the project or if someone has any ideas as to how I can get this to work.

Thankyou

JPU
 

inglewoodpete

Senior Member
While a software solution may offer some benefits for a mass-produced controller, the concept is risky due to what can happen during code development. It is also very difficult to use ADC to measure the voltage drop across an LED driven by PWM, since the current is instantaneous during the PWM 'on' periods.

I have made several high-power RGB LED controllers driven by PICAXEs. The simplest solution for controlling the LED current is to use a hardware current limiter alongside the PWM drive for the MOSFET. The attached circuit diagram is snipped from one of my controllers. Current limiting for the MOSFET (and LEDs) is provided by T24 while T23 provides the PWM drive from the PICAXE (via T21/T22). The P-channel power MOSFET is actually an IRF9540, and operates with a (limited) drain current up to 1 amp.
CurrentLimitedLEDDimmer.JPG

My controllers were used for lighting wall-mounted artworks on the sides of multi-storey buildings. Due to the lighting being outdoors and needing to operate in all weather conditions, I developed this "high side" controller. This allowed the positive power feed for the lighting to be current-limited, should it come in contact with grounded framework.
 

mikeyBoo

Senior Member
hi JPU,
Nice design from Pete!
The easy route is to use a pre-made driver board. They come in various wattages & all you need is a (e.g. 60Hz) variable duty-cycled PWM from a Picaxe to do the current control. The following project has links to get the raw boards or if you’re into making circuit boards, the lil’ project holds designs for host boards for easier connections.
Good luck with your endeavor!
https://picaxeforum.co.uk/threads/host-board-for-constant-current-hi-intensity-led-drivers.30705/
 

JPU

Senior Member
Hi all.

Thanks for your help.

I initially had the idea after buying a cheap led bike light of eBay. The Pcb Is so simple and has a pic, a mosfet, a micro switch, a few small caps and a few resistors. The light worked perfectly and worked well. I stripped the pcb out and utilised it for a little caravan light module running it off a single cell lithium battery. Some friends in the caravan group asked me to make some up so I did.

However I just ordered another batch in and they have arrived but unfortunately the pic on these has been coded in a different way and the light comes on, has three levels of brightness but also the last level in the sequence is too flash. The flash feature didn’t exist on the first batch I bought in. So I thought I’d make some PCBs up todo the job, this would also mean I’d have full control of the pic software and would be a good project to learn on.

I’ve done some research and read about using an CREE LED and n channel Fet in series with a resistor. The voltage is taken across the led using the ADC input and effects the pwm output which Controls the FET.

My question are : how difficult might the code be? And what should I beware of? From what I’ve read the fet is limited to 1amp but I’m not sure what exactly that means or even if I’ve understood this correctly. Can they be limited internally?

Thanks.

JPU
 

techElder

Well-known member
You don't really need a PICAXE to control an LED to three levels of brightness for a camper. Remember when we just used to have an ON/OFF switch and that was OK? :D

PS. You could probably rig up a potentiometer to a MOSFET and get greater control, too.
 

inglewoodpete

Senior Member
Aha! Some more information! Please post a link to the circuit you refer to.

I'm flying blind here but I suspect that your second batch of lights might have a switch-mode regulator, which would change the whole picture. Is there a small inductor on the board?
 

inglewoodpete

Senior Member
Hi All

Here is a pic of the front and back of the PCB.

Any help?

JPU
Yes, it is a more basic circuit, with a microcontroller and an N-channel MOSFET. Are you able to determine which pin on the micro is outputting the PWM and flashes? Also, which pin has the +ve battery connected to it? ...and the push button. You should be able to find those pins with a multimeter. With a bit of luck, you may be able to wire in an 08M2 (after removing the existing microcontroller - preferably with a hot-air gun).

I presume the LED is on the other end of one of those pairs of wires.

Peter
 
Top