Power consumed on a line controlled by PWM

Hi

I'd like to measure the power consumed by LED lights which are dimmed using PWM. Is it accurate to use the voltage for the purpose of the calculation as VCC * duty-cycle? That is, if the line is on for 50% of the time, and input voltage is 12V that the effective voltage is 6V, or is it a more complex relationship than this?

Also I'm presuming a hall effect ammeter (like an Alegro ACS715, for example this one http://www.pololu.com/catalog/product/1186) will be content to report the current on the line regardless of the frequency of PWM. Is that a safe presumption?

Thanks Geoff

More or less, yes. If you apply 12V to your LED at 50% duty cycle or 6V at 100% duty cycle you should perceive the same brightness, since you are delivering the same amount of average power to the LED.

Now, this assumes the LED is “linear”, in that twice the current gives twice the brightness. This is pretty much mostly somewhat generally true, but there are limits (e.g., you definitely do not want to try 120V at 5% duty cycle!) and the relationship is not perfectly linear.

As for the ACS715, the answer is given by the 4th bullet point on the left side of the datasheet’s front page: “80 kHz bandwidth”. This means that oscillations well below 80 kHz will be “tracked” by the ACS715, that is, if you do PWM at 1 kHz for example the ACS715 will report high current, no current, high current, no current, etc., tracking the PWM oscillations. Now well above 80 kHz you will get a steady state DC value that corresponds to the average current and you won’t see the PWM oscillations (well, not very much). In between, you’ll get a mix.


The QuadRAM shield: add 512 kilobytes of external RAM to your Arduino Mega/Mega2560

I was wondering that in this thread:

http://arduino.cc/forum/index.php?topic=90096.0

I would say the duty cycle would affect the effective current more than the effective voltage. That is, you are interrupting the voltage, so it stays the same, but the "power" delivered is less because there is less of it (time-wise).

I presume the problem with LEDs is that they will heat up and fail, so if you only heat them briefly they get a chance to cool down again. Well, that's the theory.

I did some research at the time without finding a conclusive answer. One school of thought was that PWM was actually better because you are not just heating up a resistor for no real purpose.

RuggedCircuits: As for the ACS715, the answer is given by the 4th bullet point on the left side of the datasheet's front page: "80 kHz bandwidth". This means that oscillations well below 80 kHz will be "tracked" by the ACS715...

That's brilliant news since the Arduino analogWrite() will have a far higher frequency than 80kHz. I had read that bullet, but didn't comprehend the significance, thankyou![quote author=Nick Gammon link=topic=103538.msg776558#msg776558 date=1335656114] I would say the duty cycle would affect the effective current more than the effective voltage. That is, you are interrupting the voltage, so it stays the same, but the "power" delivered is less because there is less of it (time-wise). [/quote]That is quiet confusing - PWM as it's used for analogWrite() is supposed to simulate a range of voltages by timeslicing, but I get where you're coming from. I suspect that if the Alegro sensors will give me a reliable reading, and if I know my total input voltage, since P = VI is a linear relationship the duty cycle will work appropriately regardless. I'm hoping this will look something like P = VI / (value / 255) ; where value is what we fed the analogWrite() to arrive at the present LED brightness level.[quote author=Nick Gammon link=topic=103538.msg776558#msg776558 date=1335656114] I was wondering that in this thread:

http://arduino.cc/forum/index.php?topic=90096.0 [/quote] And that's very clever sir - going to have to try that myself !

Thanks, as always, for your advice guys. I think I've got enough now to start buying the bits for this one, cheers! Geoff

strykeroz: That's brilliant news since the Arduino analogWrite() will have a far higher frequency than 80kHz.

No it won't. See the reference page for analogWrite.

The frequency of the PWM signal is approximately 490 Hz.

Curse it. That lower case k was significant.

You can change the pwm frequency, and I think its possible to go above 80khz, you justneed to set a prescaler search change arduino pwm frequency and you'll probably find it

You have two measures of current. 1) The peak current - that is the real current that flows when the LED is on. 2) The average or RMS current, this is a current equivalent to what it would be if it were on all the time. In the case of a rectangular waveform the RMS is the average.

You need to use the RMS for things like power dissipation and brightness. You need to use the peak current for things like current rating of devices, drivers and power supply requirements.

One school of thought was that PWM was actually better because you are not just heating up a resistor for no real purpose.

You are heating up the resistor just the same in both situations. With PWM the heat is applied in small bursts which is smoothed out by the thermal time constant of the bulk of the resistor.

Grumpy_Mike:
You are heating up the resistor just the same in both situations.

In my circuit here:

http://arduino.cc/forum/index.php/topic,90096.0.html

I did not have a series resistor, so therefore it didn’t heat up.

Thanks though for clarifying about the average current.

Grumpy_Mike: You have two measures of current. 1) The peak current - that is the real current that flows when the LED is on. 2) The average or RMS current, this is a current equivalent to what it would be if it were on all the time. In the case of a rectangular waveform the RMS is the average.

From this I think I might take a different angle, and be able to calculate the instantaneous power used without directly measuring it. If I put the hall effect sensor inline without PWM, I'll get the peak current value for #1 given the LEDs will not be changing, which is a constant I can apply in the sketch. Using the known supply voltage which is regulated at 12V and the pre-measured peak current drawn by the lighting when it's flat out, I should then be able to calculate the RMS current at any given PWM value. As I control the PWM that's always going to be known and is the only value that will change.

Does that approach work? Geoff

[quote author=Nick Gammon link=topic=103538.msg777049#msg777049 date=1335699801]

Grumpy_Mike: You are heating up the resistor just the same in both situations.

In my circuit here:

http://arduino.cc/forum/index.php/topic,90096.0.html

I did not have a series resistor, so therefore it didn't heat up. [/quote] So where is the current limiting happening in that circuit then?

I should then be able to calculate the RMS current at any given PWM value. As I control the PWM that's always going to be known and is the only value that will change.

Yes that will do.

Grumpy_Mike: Yes that will do.

Thanks guys - as always, I truly appreciate the time you put into providing advice here.

Cheers ! Geoff

I would suggest a series resistor, especially for longterm predictable results, leds can heat up very fast and will blow before you even know it

Grumpy_Mike: So where is the current limiting happening in that circuit then?

Thanks for the suggestion Mike. I replied in the thread I linked to. Basically it would seem that I was wrong to omit them.

Surely there's resistance in the circuit that makes the PWM? And why would I need a resistor to a led if I keep the duty to 10% at 5V? It doesn't make the led terribly bright without one.

I remember a 555 project back in the 90's that drove a led at 9V for short pulses. Didn't build it but it looked interesting and the led was supposed to last long enough to play laser tag.

Leds die of heat. Until then isn't most of the current they get turned into light?

Surely there's resistance in the circuit that makes the PWM?

Yes thee is some source impedance but not enough to keep the current down to safe levels.

And why would I need a resistor to a led if I keep the duty to 10% at 5V?

Because it is the peak current that exceeds the specification of both the LED and the driver, but mainly the driver.

It doesn't make the led terribly bright without one.

The brightness is not important it is the peak current.

I did some tests on an arduino with an PWM output of 1 on 255 off, it was very dim. I got a peak current of over 250mA from the arduino, that is not going to do it any good. Remember 40mA is the point when damage starts to be done according to the data sheet. http://www.thebox.myzen.co.uk/Tutorial/LEDs.html

I remember a 555 project back in the 90's that drove a led at 9V for short pulses.

People also stick pins into frogs and pull legs off insects, it doesn't make it right.

Leds die of heat.

That is only one cause of death. Depletion of charge carriers is the main cause of failure in LEDs, the main cause of charge carrier depletion is high current density.