Homemade 3W LED driver

Hello, everyone! I'm trying to make a dimmable LED lamp for aquariums and, for about a month now, I'm trying to come up with a driver for the LEDs. I made some research and ended up finding a LED driver shield that uses the XL4001E1 IC to control 3W LEDs with PWM.

image
(Source: Next best pwm LED driver? xl4001e1 0-40v 2a - Lighting Forum - Nano-Reef Community)

I've bought one of those about 6 months ago, but, unfortunatelly, the shipping price of those shields to my country makes them too expensive for me to aford (I would need 5 of them). So, for that reason, I decided to make my own driver. I've bought the IC (XL4001E1 - https://datasheet.lcsc.com/lcsc/1811021113_XLSEMI-XL4001E1_C73347.pdf) and used some adpaters to make them suitable for my breadboard. I followed the instructions on the datasheet for LED constant current driver and used the enable pin to control the PWM (since this is how PWM control is handled on the shield I've bought before).

image

This is the circuit I came up with:

Since the breadboard photo looks absolutely terrible, here is the schematics:

With this circuit, I can turn on the LEDs, but i'm having a hard time controlling their brightness. On the datasheet, it's said that driving the enable pin high turns the LEDs off:

image

The thing is: when I connect the enable pin directly to VCC or to a pin set to high through "digitalWrite (6, HIGH)", it turns off. But when I try to control it using PWM (I tried using a potentiometer to control the PWM on pin 6, for example), the LEDs won't change brightness and won't even turn off. If I set the PWM voltage to 5V using the potentiometer, when I measure the voltage on the enable pin (on the IC), it reads 5V (the same voltage that makes it turn off when I connect directly to VCC or to a pin set to high using digitalWrite) but the LEDs are still on and shining brightly. At first, I thought that the problem was that I was using 12 VCC to power up the IC and 5 VCC to control the PWM, but, since I can turn the LEDs off using direct 5 VCC from Arduino, I've discarded this idea. Also, the shield that uses this same IC, has the exact same circuit: the PWM goes into the enable pin and the GND from Arduino and the source are shared. And the shield works perfectly. In the end, I even bought components with the exat same values as the ones used in the shield to test if they influenced something, but nothing changed. I have no idea what I have done wrong and I finally decided that I need help. I've tried everything but can't understand what is wrong with my circuit. Thanks in advance!

You chose not to use R1 and R2 in the current measurement at pin 5.

I mean the pin 4 circuit, sry.

It's only two resistors. It might not be your problem. I just see that and wonder if you made an informed choice there.

a7

I don't see any details about PWM dimming in the datasheet. :frowning:

A potentiometer is NOT PWM. It would seem like the enable pin is the correct PWM/dimming connection.

Note that there will (potentially) be two different "PWMs" at two different frequencies. Your dimming-control PWM comes from the Arduino, and there is PWM built-into the driver to control the "constant" current.

I hoped what the OP meant was that a potentiometer was read analogRead and used to inform an analaogWrite PWM.

And I haven't found it yet, but it does seem like a PWM of inreslted frequency can be used to dim.

@solidliquid do you get the desired behaviour from the module? If so, why not use the exact schematic of the module?

a7

First of all, thank you all for the replies.

Unfortunatelly, couldn't find any details about it either, except for the part in the beginning of the datasheet that briefly mentions the fact that a pwm control circuit can be used to adjust the duty ratio:

As alto777 comented, I actually used the potentiometer to control an analogWrite command on pin 6. Sorry for making that part confusing, I should have clarified a little more.

I actually decided to do that a while ago, but with no succes. I spent a good while following the trails in the module using a multimeter and the schematic I'm using is the same circuit as the module. My second guess after realising that the 5V was enough to disable the module and turn off the LEDs was that the PWM was being undestood as a floating state (the datasheet says that the floating state of the enable pin is considered default low, which should make the LEDs stay on), but then again, the module works perfectly with the same circuit. I'm not sure if I'm missing something here. I've tried several ICs (I bought 10 at the same time, that was the default quantity that came in the sabe bag) and none of them is being capable of dimming the lights.

Pro tip: when you have 10 of something and 2 or 3 don’t work, leave the rest alone.

I won’t say I’ve inadvertently destroyed all I had of a certain part because I tested them all with the same bad circuit. Won’t say it. :expressionless:

The PWM is “backwards”, that is to say narrow pulses bring much light, fat positive going pulses bring darkness.

If the module works but your copy circuit doesn’t, then all I got is you have failed to see everything on the module.

An Arduino output shoukd be able to drive the PWM input pin high and low, you could program and wire a very slow speed on/off signal and check to see that input to the IC going HIHG and LOW.

Say, have you tried just that? Or even just using a small resistor like 2K2 on the PWM input and switching the other end betwee GND and 5 volts to check basic on/off response?

a7

Really, really bad idea. :roll_eyes: :astonished: :thinking:

What is missing from that datasheet is the recommended PCB layout to be used. This is a switchmode device operating at 150 kHz. Those modules are designed specifically with the correct PCB layout. "Breadboarding" them is plain foolishness.

Don't totally waste your time. Use the correct modules. Just find a supplier with a more reasonable shipping price.

I tried it using 5VCC and GND from Arduino. The LEDs respond correctly that way (5V turns them off and 0V turns tem on). The dimming part is where i'm suffering to get working. But I will test a slow "high" and "low" to see how the circuit behaves.

Oh, thanks for the tip lol. Actually, I think I found that out after I accidentally burnt two of my ICs in the beginning of my project bacause I had wired them the wrong way.

I thought about that when it didn't work in the beginning, but I though it didn't made much sense. Apparently, I fooled myself then. The thing I don't really understand and would like to know more about (to avoid this kind of problem in the future) is how the PCB layout changes the functionality of the circuit, since the electrical connections are the same. Would there be any way I could make this circuit in a perfboard, for example?

Do you notice that one of the necessary components is an inductor?


Because you have just introduced no fewer than ten (as I count them) additional inductors into your circuit. :astonished:

You may think of them as "jumper wires".

Can you mount the SMD chips to perfboard?

Why not just use a MOSFET? What am I missing here?

Oh, I see. I didn't think the inductance of those wires would make such a difference. This may be a stupid question, but I'm really curious about this. Making the wires more "straight" would reduce that additional inductance?

Yes. Actually, that was the initial idea for the final project after testing. All the components and the Arduino would be mounted to a perfboard.

Since they need to stay on for a lot of time, I need some type of current limiting for when the LEDs heat up. I initially thought about using a mosfet, but after a post I made last year, people made me realise I would end up needing a driver (Controlling 13 3W LEDs using Arduino - #10 by solidliquid)

I just tested this. When I connect the enable pin directly to 5V, it keeps the LEDs off, but only if I turn the IC source on after conecting the pin to 5V. If I switch to 0V and then connect back the 5V without turning off the source, the LEDs keep glowing.

I also tested this, but the LEDs would only blink in a weird way. When the enable pin was high, the LED would light up faintly, and when low, it would light up brightly. When floating, it would keep that same faint glow. It wasn't a suuuuper faint glow, but it wasn't even close to the LED full glow. I'm not sure if I should try with another IC, since I already had different results a while ago, where I could turn the LEDs off and on with the enable pin, but couldn't control the brightness intensity (anything that wasn't 5V would make the LEDs go to full brightness).

I did not read the whole thread carefully so I maybe missed the answer: why do you need a driver for 3W LED? A current limiting resistor + constant voltage supply + PWM of a simple transistor is not good enough?

The problem is that when the LEDs get warmer, the current increases, what could end up burning the LED. So I would need a driver that senses the current and regulates it. I actually bought one of them already, but the price (at least for my country) is too expensive for me (I would need 5 of them). That's why I bought the IC and tried to make the driver myself.

What LED(s) are you using? Usually there is no risk of thermal runaway with reasonable current limiting resistor.

I'm using these LED lamps: https://www.aliexpress.com/item/32831596858.html?cv=47843&af=1424725&utm_campaign=1424725&aff_platform=api-new-hotproduct-download&mall_affr=pr3&utm_medium=cpa&aff_trace_key=3f0ee95de958454b92db07b1e57df410-1610415070637-07607&dp=7bd33334b0fe95917d70998fc5628ad4&terminal_id=f6aeb6743d3c49fbaa744b36314288b9&tmLog=new_Detail&utm_content=47843&utm_source=admitad


I though those more powerful LEDs always needed constant current drivers, since they heat up pretty quickly.

I never heard this before, but I haven't worked with high power LEDs. That might be true for SMD components because to limit 3.4V to 500mA with a zero-ohm load (dead short) all you need is a 6.8Ω, 2W resistor. If you hard-limit the current this way, I don't see how you can damage the LED.