Go Down

Topic: PWMming high powered leds smoothly (Read 5987 times) previous topic - next topic

Headroom

#15
Jan 15, 2015, 11:42 pm Last Edit: Jan 15, 2015, 11:44 pm by Headroom
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!
http://trippylighting.com

http://ledshield.wordpress.com/

skreech

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.

skreech

#17
Jan 20, 2015, 04:22 pm Last Edit: Jan 20, 2015, 06:50 pm by skreech
By the way I ended up modifying the pwm code as follows and got a very nice non linear dim:
Code: [Select]

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(https://diarmuid.ie/blog/post/pwm-exponential-led-fading-on-arduino-or-other-platforms) 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?

Paul__B

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.

skreech

#19
Jan 25, 2015, 02:28 pm Last Edit: Jan 25, 2015, 02:34 pm by skreech
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?

It would indeed.
okay i will try this solution: http://forum.arduino.cc/index.php?topic=288262.0 failing that i will try the manual approach. i just don't like using delays and will need to come up with some code..

Grumpy_Mike

Quote
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.

skreech

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...

Grumpy_Mike

Quote
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.

Chagrin

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.

Magicj

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

Headroom

#25
Feb 01, 2015, 01:41 pm Last Edit: Feb 01, 2015, 01:44 pm by Headroom
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.

http://trippylighting.com

http://ledshield.wordpress.com/

Paul__B

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.

skreech

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.

pjrc


Go Up