Go Down

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

skreech

Jan 10, 2015, 07:33 am Last Edit: Jan 10, 2015, 07:37 am by skreech
Hi - I wasn't sure whether this is the right place to ask this so feel free to tell me I'm wrong. I'm basically trying to dim some high powered leds using an rf520 (these are 3v 1A leds) and and am coming across two problems:
1) The leds are not fading to black entirely. At around 2% brightness they just switch off. This is pretty low but still noticeable. I'd like to try and achieve a smoother fade to black if possible.
2) I don't seem to be able to achieve a non-linear dim that looks better to the eye. I have both log and sine wave equations in there and they work a lot better than just straight linear but I can't seem to make the dim curve steeper (i.e. dim more slowly at the start and faster at the end). So my leds look as though they are at full brightness until halfway through the fade. :-(

I basically don't know if this is because of the hardware or code.

Here are snippets of what I am doing:
LOG
Code: [Select]

const int _pwmIntervals=14660;
float _R;
static int _interval=0;
unsigned int _logxfactor=2;
static float _auto_power=0;

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

SINE
Code: [Select]

while dimming:
  _sinfactor=_sinfactor+(4.712/(twilight_length*3000));
  auto_power=(sin(_sinfactor)*127.5+127.5);
  analogWrite(led,auto_power);


Thanks very much for your help!

Grumpy_Mike

Quote
I basically don't know if this is because of the hardware or code.
So you post the code but not the schematic?

skreech

#2
Jan 10, 2015, 06:27 pm Last Edit: Jan 10, 2015, 06:27 pm by skreech
it's just an arduino and some leds connected to a transistor. I have no schematic for that.

Grumpy_Mike

#3
Jan 10, 2015, 09:07 pm Last Edit: Jan 10, 2015, 09:08 pm by Grumpy_Mike
it's just an arduino and some leds connected to a transistor. I have no schematic for that.
Then the circuit is wrong,
1) You have no resistor. So what limits the current? The impedance of the supply?

2) You don't need a resistor actually you need a constant current supply.

3) No schematic means you have wired it up wrong anyway.

skreech

The LEDs are working so I'm not sure if the circuit is 'wrong'. I'm just not able to exercise as fine a control over pwm as I'd like.

Here is the schematic anyway. I am using an off-the-shelf constant current driver for leds.

Paul__B

You mean an IRF520, don't you?  Otherwise there would be a problem with no base resistor.  Suggest you give us a link for it.

And your constant current driver is definitely only a 2-terminal device?

skreech

#6
Jan 11, 2015, 09:39 am Last Edit: Jan 11, 2015, 09:45 am by skreech Reason: uploaded wrong image
Yes I meant IRF520. here's the link. http://www.vishay.com/docs/91017/91017.pdf

The driver has 4 leads coming out of it (2 for ac and 2 for dc) so I have updated the schematic a little.


Paul__B

#7
Jan 11, 2015, 10:30 am Last Edit: Jan 11, 2015, 10:33 am by Paul__B
The driver has 4 leads coming out of it (2 for AC and 2 for DC) so I have updated the schematic a little.
Oh, shivers, no!

I realised that just after I posted, have since been searching for my previous explanation.

You mean a constant current power converter.

You absolutely cannot use these with PWM.

Simple as that.

skreech

#8
Jan 11, 2015, 11:43 am Last Edit: Jan 11, 2015, 11:45 am by skreech
hmm I have to admit that I don't really understand the post and just the like the poster there, it does seem to work... If you don't mind spelling out the dangers clearly more for me I would appreciate it.

In the meantime - okay. I'll  just get a driver that accepts pwm inputs and wire it up like this.

My initial question still remains though, which is how can I improve my control over the pwm but maybe we can save that until I try it with the new driver.

Paul__B

#9
Jan 11, 2015, 01:42 pm Last Edit: Jan 11, 2015, 01:44 pm by Paul__B
hmm I have to admit that I don't really understand the post and just the like the poster there, it does seem to work... If you don't mind spelling out the dangers clearly more for me I would appreciate it.
I did in the further post there.

It is pretty straightforward.  By definition, a constant current supply is doing its darndest to supply a constant current.  If you attempt to fight this by switching that current on and off - called "PWM" - and making it a non-constant current, then you are deliberately asking for trouble and that "trouble" will take the form either of being unable to control it "properly" - or sooner or later something burns.

Also note as in the previous discussions on this topic - plenty of them - that if you use a ballast designed for a 0 to 10V control input, you generally have to feed it with a smoothed voltage if you are using PWM to synthesise that voltage.  Unless it specifically says that you can feed it with PWM.

Grumpy_Mike

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

skreech

#11
Jan 11, 2015, 05:36 pm Last Edit: Jan 11, 2015, 05:38 pm by skreech
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.

Grumpy_Mike

#12
Jan 11, 2015, 05:52 pm Last Edit: Jan 11, 2015, 06:53 pm by Grumpy_Mike
Quote
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.

Paul__B

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.

Grumpy_Mike

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.

Go Up