PWMming high powered leds smoothly

Yes I meant IRF520. here's the link. http://www.vishay.com/docs/91017/91017.pdf

And you will see that this in not a logic level FET, that one requires 10V on the gate to fully switch it on.

thanks - 'fully switch on' means 'let all current flow' right? what do i need to look at on the datasheet to ascertain this particular characteristic of a fet? the gate-source voltage / drain current relationship? If so is it a matter of making sure I supply enough voltage to reach the desired current? In my case I am only looking at 1A.

hat do i need to look at on the datasheet to ascertain this particular characteristic of a fet?

It is the on resistance called Ron - it is specified in ohms and it will have an associated Gate voltage with it. In that data sheet it says 10V, for a logic FET this will say 5V.

But like Paul says the problem it you are trying to PWM a constant current drive by interrupting the current.
You could try shunting the current with the PWM FET, it is a bit of a hack.

shunting.pdf (15.1 KB)

Grumpy_Mike:
You could try shunting the current with the PWM FET, it is a bit of a hack.

Sure is!

If it is a switchmode converter, it would have the same problems.

Paul__B:
If it is a switchmode converter, it would have the same problems.

Well no not quite, the converter will output the same current but the voltage will be lower than turn on voltage for the LEDs. This will prevent the voltage being forced to the maximum when the LEDs are off so there will not be so much variation in the voltage output.

However, this is pure speculation but I think it is worth a try. A lot depends on the way the constant current driver responds to the step change. The thinking is that the step change is smaller and so it might not give as much trouble.

While the arguments are valid, perhaps we can shorten the discussion in order to complete this simple project.

so get yourself one of these Constant Current LED drivers through eBay for example.

Connect GND to the Arduino GND and the DIM pin to a PWM pin on your Arduino.
Connect a 1.5A 12V power supply to the driver. Connect Arduino to USB.
Run proper fading sketch.
Done!

Thanks for this. Yes I came to this conclusion in one of the earlier posts. I have another question regarding this build which i will post in a new thread.

By the way I ended up modifying the pwm code as follows and got a very nice non linear dim:

if (_interval<=_pwmIntervals){
    _interval++;
    _auto_power=pow(_logxfactor,(_interval/_R))-1;
    auto_power=255-(_auto_power*(power_percentage/100));
    analogWrite(led,auto_power); 
}

Here are the results of the code plotted on a graph (I got the idea of doing this somewhere in this forum and would recommend it to anyone implementing their own dimming ).

Very informative guide here(Redirecting…) and also where the above code comes from.

Now I am facing one problem, however, and that is that at very low levels (the first 8 steps) the 'steps' are very conspicuous so I would like to find a way to smoothen that out. Would that mean increasing the resolution of the arduino pwm?

skreech:
Now I am facing one problem, however, and that is that at very low levels (the first 8 steps) the 'steps' are very conspicuous so I would like to find a way to smoothen that out. Would that mean increasing the resolution of the Arduino PWM?

It would indeed.

One - albeit tedious - approach is to resort to software PWM for such values, turning the PWM on for a few ms, then off for some ms, repeating this every 16 ms. Say when your PWM value gets down to 32, you instead set it to 256 and switch it repeatedly on for 2 ms and off for 14 ms. You can then continue to count it down but the intensity will be divided by 8.

Grumpy_Mike:
Well no not quite, the converter will output the same current but the voltage will be lower than turn on voltage for the LEDs. This will prevent the voltage being forced to the maximum when the LEDs are off so there will not be so much variation in the voltage output.

how would I calculate the value of the resistor required in the shunt circuit? I understand the function is to divert current away from the leds but am not sure how to calculate the value that would result in 'lower than turn on voltage' without leading to a short. Does it just need to provide less resistance than the led path?

Paul__B:
It would indeed.

okay i will try this solution: PWM resolution - Programming Questions - Arduino Forum failing that i will try the manual approach. i just don't like using delays and will need to come up with some code..

how would I calculate the value of the resistor required in the shunt circuit?

Take the current you want in your LED and subtract it in the current you get from the constant current supply. This extra current has to go down the resistor with only the LED's forward voltage across it.
So you know the voltage you have on the resistor, you know the current you want it to shunt, then ohms law will tell you the resistor value.
Then work out the power in the resistor, double it for luch and use a resistor of at least that power rating.

sorry I am missing something. I'll just lay out my thinking so please correct it if you can.

I thought the purpose was to pwm the shunt circuit so the current gets diverted from the leds to the shunt and thereby achieve dimming without interrupting the current output from the constant current driver. is this right? The duty cycle between the circuits gives me the led brightness I want.

If so, then when the current is switched i would want 0 current in the leds and all the current in the shunt.

But if I chose a resistor with a value calculated from the same voltage drop and current as the leds wouldn't the current just get split between these two circuits when the shunt is triggered, because both circuits now have the same resistance? I'm sure I've gone wrong somewhere...

I thought the purpose was to pwm the shunt circuit so the current gets diverted from the leds to the shunt and thereby achieve dimming without interrupting the current output from the constant current driver. is this right?

No.

The purpose of the shunt is the current produced by your LED driver is 700mA, your LED actually needs 350mA so the shunt will take that excess current.

However, if the resistor turns out to not drop more voltage than the LED needs it won't work at all.

You are clearly not getting this and it is not a proven design it is just an idea, so I don't think you are not up to trying this. Just forget it and get a constant current drive of the right current value and get one that is designed to be controlled by PWM.

Headroom:
so get yourself one of these Constant Current LED drivers through eBay for example.

That particular chip (PT4115) doesn't do well on the low side when fading it. Tends to shut off at about 20%. I was kinda impressed that OP got his to 2% but then I suppose that was due to burning all that power in the FET.

Meanwell LDD's are nice and compact and relatively cheap, and they do exactly what you require.

Chagrin:
That particular chip (PT4115) doesn't do well on the low side when fading it. Tends to shut off at about 20%. I was kinda impressed that OP got his to 2% but then I suppose that was due to burning all that power in the FET.

I don't remeber details as I just used that driver to prove a concept, however the reduction in dimming range for most LED driver chips comes from using a higher PWM frequency. The PT4115 has a dimming range of 5000:1 but only at 100Hz PWM frequency. I drove the PT4115 ( well, actually three of them) from a PCA9685 I2C LED driver that has 16 12-bit PWM outputs where I could change the PWM frequency from 40Hz to 1KHz from my library.

IIRC the normal Arduino PWM frequency is 500Hz so some reduction in dimming range can be expected.
I may have said this before but when trying to control things directly with PWM the standard Arduino boards are not the best boards. The Teensy 3.0 and 3.1 have 10/12 PWM pins with PWM resolution up to 16bit and configurable PWM frequency. The Teensy LC that will be released in March will offer a few less PWM pins but also likely at up to 16bit for about $12.
The Teensy 3.1 uses a ARM cortex M4 32bit MCU and the Teensy LC will use an M0. These boards offer many more things at full Arduino compatibility that you'll be pressed hard to find on any other Arduino board and definitely not at such low cost or size.

Rooting around in my bin of eBay acquisitions I came across a couple of 300 mA LED drivers/ power converters (i.e., 85-265V input).

These dirt-cheap units are in a fairly flimsy case; the underneath "lid" flipped off easily for the circuit module (loose inside) to be inspected. The isolation between primary and secondary of the transformer is somewhat dubious but of particular interest is that the secondary circuit consists of a diode and an electrolytic capacitor. This means that attempts to use PWM, either by a switch in series with the LED or a switched shunt, are quite clearly not going to work.

Headroom:
The Teensy 3.0 and 3.1 have 10/12 PWM pins with PWM resolution up to 16bit and configurable PWM frequency. The Teensy LC that will be released in March will offer a few less PWM pins but also likely at up to 16bit for about $12.
The Teensy 3.1 uses a ARM cortex M4 32bit MCU and the Teensy LC will use an M0. These boards offer many more things at full Arduino compatibility that you'll be pressed hard to find on any other Arduino board and definitely not at such low cost or size.

The teensy sounds great but china made unos are still around a quarter of its price. But I'll try the lc when its available. I think the greater pwm resolution is worth it.

skreech:
But I'll try the lc when its available.

It's available now. :slight_smile: