MCU based constant current LED boost converter - Page 1
Forum section: electronics / projects

author: void_error
author_rank: Frequent Contributor
timestamp: November 20, 2014, 10:06:58 am
content: I recently bought one of these (because it was cheap - about $16) and I intend to turn it into a workbench lamp with adjustable brightness.The first idea I had was to use a cheap 8-pin PIC like the12F1571which has hardware PWM and an ADC/comparator and two buttons to increase/decrease brightness.It currently runs on a 230V input with its own converter and I measured about 31V across the LED. The goal here is to make it as simple and flexible as possible without using specialized LED driver chips. Input voltage will be 12V which implies a boost topology with an N-channel MOSFET probably driven directly by the MCU, an inductor, a diode and a filter cap, with a current sense resistor from negative LED pin to ground. A 78L05 will provide the MCU supply voltage.More ideas are welcome.

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: November 20, 2014, 10:42:15 am
content: you probably want a FET gate driver or something that can deliver more drive current like a push pull bjt output. slup169.pdf by Laszlo Baloghis worth a read.I did a buck converter with an ATTiny 461 that gave 3 channels. Using a micro based feedback loop you have to slow down the rate of change (plant).But if you slow it down enough it is stable and the user wont have any problems.I would check the data sheet of the LED you are using rather than just measure the current and voltage.

author: void_error
author_rank: Frequent Contributor
timestamp: November 20, 2014, 12:37:43 pm
content: Quote from: HackedFridgeMagnet on November 20, 2014, 10:42:15 amWas thinking of that in case MOSFET turn-on / turn-off times are too long. Push-pull BJT with base speed-up caps works well at 5V.Quote from: HackedFridgeMagnet on November 20, 2014, 10:42:15 amUnfortunately it's impossible to get the datasheet, no code or anything on the LED, it's probably one of those 10W LEDs you find on Banggood, with 9 LEDs in series. I guess I'm going to have to rely on measurements, as well as hooking up a scope to see the ripple of the integrated driver (which is sealed btw).It says 10W 1/2 input power on the back of the case which means there's no more than 9W reaching the LED. I'm not planning to run the LED at more than 8W anyway, it's too damn bright... actually... I might stick a magnifying glass underneath it and go frying ants, too bad it's almost winter and ants are not that common.For about 9W output power to the LED there's going to be roughly 1A drawn from a 12V supply. If the MCU-based version fails to work I'll just use a TL494 or MC34063 with the LED current set by the 5-bit DAC in the MCU.

author: Seekonk
author_rank: Super Contributor
timestamp: November 20, 2014, 01:14:34 pm
content: Just go and buy a $3 boost converter on ebay. My whole camp runs on those powering residential lighting products. If you don't run them at maximum there is no need to do current sensing. If you run them at maximum the LED is just going to die from heat. I wouldn't operate one of those (and I have a number of them) at more than 5W.

author: void_error
author_rank: Frequent Contributor
timestamp: November 20, 2014, 01:53:46 pm
content: Quote from: Seekonk on November 20, 2014, 01:14:34 pmAnd wait 6 weeks for it to arrive? No thanks. Plus, what do I learn if I just buy one and where's the fun in building a custom one?In the meanwhile, after a fairly short battle with the glue holding the LED driver I've managed to get some info from the label: it's a 250mA +/-5% 18-33V constant current source, with 30-31V across the LED which means less that 8W. Unfortunately the whole thing seems to be epoxy sealed so I won't be able to get inside it.

author: ManCave
author_rank: Regular Contributor
timestamp: November 20, 2014, 02:08:12 pm
content: Why use micro when you can just use a PWM control chip which is made for purpose and costs about $0.5 like TL494 or SG3524?

author: void_error
author_rank: Frequent Contributor
timestamp: November 20, 2014, 02:22:55 pm
content: Quote from: ManCave on November 20, 2014, 02:08:12 pmLearning while building something useful? I've fiddled a lot with TL494s before and still have some lying around, but it's not really a challenge as I already have a spreadsheet which I made a while back to calculate all the values for a boost converter and I won't learn anything new, that's why I want to use a micro.

author: dannyf
author_rank: Super Contributor
timestamp: November 20, 2014, 03:01:27 pm
content: It can be done but I am not sure why you need a mcu there.The simplest would be to put the whole circle + led inside of a bridge rectifier - they you can use DC controls on an AC circuit.

author: void_error
author_rank: Frequent Contributor
timestamp: November 20, 2014, 06:27:12 pm
content: Better idea: TL494 boost converter + 40193 + R-2R DAC. No software, dirt cheap, two buttons for brightness control, can have a preset startup brightness. 16 brightness levels are enough.

author: dannyf
author_rank: Super Contributor
timestamp: November 20, 2014, 06:38:53 pm
content: Think 555.

author: ManCave
author_rank: Regular Contributor
timestamp: November 21, 2014, 12:40:03 pm
content: Quote from: void_error on November 20, 2014, 02:22:55 pmMakes sense now

author: dannyf
author_rank: Super Contributor
timestamp: November 21, 2014, 02:05:46 pm
content: All you need to have is a reference against which you can compare the current through the led: if the current through the led is too high (vs. the reference), turn off the switch; Otherwise the switch is on.

author: void_error
author_rank: Frequent Contributor
timestamp: November 21, 2014, 02:34:53 pm
content: Quote from: dannyf on November 21, 2014, 02:05:46 pmI suppose you mean if the current is too high decrease the PWM duty cycle, otherwise increase it. I'd have to sync the interrupts to the PWM timer then so I don't change the duty cycle a million times a second (when PWM frequency is set in the 50-200kHz range) which would result in a huge mess and some weird stuff.Anyway, this doesn't have to be extremely accurate, +/-10% is acceptable.

author: dannyf
author_rank: Super Contributor
timestamp: November 21, 2014, 03:51:13 pm
content: I was thinking more about a self-oscillating power comparator, than a mcu.If you were to do it with an mcu, you could implement it via comparators built into most mcus.If you were to do it with adc + pwm generators, I would have a free-running adc adjusting pwm cycles.The issue with that set-up is1) latency: turning off the switch on or off a little bit too late could have yielded too high of a current through the load;2) stability / range of viable loads: if you are simply designing for one load, not a big problem. But getting a mix-signal loop to stable for a wide range of loads isn't for the faint of heart.As such, if you look at the typical mcus designed for power supplies, you will notice that they tend to be in the very high-end of mcus - 32-bit chips, fast adc + pwm generators, etc. Check out Freescale's offerings if you are interested.

author: void_error
author_rank: Frequent Contributor
timestamp: November 21, 2014, 04:17:15 pm
content: I figured it could be done with a cheap 8-bit MCU since the only variations in power are due to the LED voltage drop changing with temperature, but that's happens way too slow for the MCU to not manage to compensate. In other words, the load will draw an almost constant power, only changing slightly with temperature.In other words, there's only one known load - the LED, not even a challenge for the cheapest MCU. I'll probably test it this weekend with a 16F628A I have lying around, the 16F690 being a bit of a pain in the arse as far as hardware PWM configuration is concerned.

author: dannyf
author_rank: Super Contributor
timestamp: November 21, 2014, 05:38:42 pm
content: I am sure it can be done with a mcu (adc + pwm). I was just pointing out that it can be done more efficient with comparators (+switches), built-in or otherwise.

author: senso
author_rank: Frequent Contributor
timestamp: November 21, 2014, 05:49:41 pm
content: There are a couple app-notes using either PIC or AVR's for a buck/boost led driver using the built in comparator of the micros and then a PWM "dac" to set the set-point/close the feedback loop.

author: void_error
author_rank: Frequent Contributor
timestamp: November 21, 2014, 05:53:34 pm
content: The idea with the TL494 & 40192/40193 I had is quite practical and easy to implement as I already have the parts but it occupies more space than an 8-pin MCU (PWM + integrated comparator, just change reference to change current which can all be done in software) and I don't really learn anything new which is exactly what the plan is. It also has to fit in a small enclosure and the PCB has to be as simple as possible.Quote from: senso on November 21, 2014, 05:49:41 pmRead a few, that's why I'm attempting this with a micro rather than the analog way.

author: dannyf
author_rank: Super Contributor
timestamp: November 21, 2014, 09:34:50 pm
content: Roman Black (one heck of a hardware / software guy) did experiment with a pic-control'd smps. Check out his website. I think he did it via a power comparator but turning it over to adc + pwm isn't that big of a deal.When I get sometime, I will actually try that myself.