Hello! I want to advice to make new FastLED useful function )) I'm not

(варешяф рйезот) #1

Hello! I want to advice to make new FastLED useful function ))
I’m not good programmer (and not so good speaks English, sorry), but I think this function may be useful for many people.
Function, that calculating theoretical power consumption of current sketch.
As we know - with full brightness and full white LEDs current is about 60ma. I know, that there are many nuances, like power source, wires length and diameter and many-many others.
But it is interesting to know, rainbow algorithm how more take current by comparison with sinelon fo example.
And I think - function would be able to say that ))
Rainbow takes ~47% of total full white, I have already calcs it. I send rainbow with E1.31, than parsing universes values and summ them total. It was very uncomfortable ))
LEDS.getFPS() - not very accurate function, but useful.
LEDS.getPower() - may be also not very accurate, but useful )

As I know - we need to calc logarithm of total leds, that we drive. It is very hard for microprocessors like arduino or ESP8266, but we can do this not very often.
It would be smart to add parameters, like how often calc logarithm of leds array data. More frequently is mean more accurate.
This gives for us to look about current power consumption. But if we have many animations, it would be nice to add parameter, that would be say how often calculating logarithm of previously calculated logarithm of leds. With this we can know about total average sketch power needs (and power companies billings ) ).
As I see how this need to work: LEDS.getPower(100, 20); will calc every 100 msec(or every 100-th calling of FastLED.show():wink: (led1.r + led1.g+led1.b+led2.r+led2.g+led2.b+…ledN.b)/NUM_LEDS*3,
It will be CurrentPowerConsumption parameter.
And every 20 mesurements will average continuously to AvaregePowerConsumption parameter.
In serial it would print Curr: 112; Average: 187.
We can map it from 0:255 to 0:100 if we need to see in percents and easy calc in mAmps.

Hope you understand me ) May be my vision of this function is totally foolish. I’m not good programmer, But I think we need to know average power of our animations, that like truth info.
May be someone write this function.
Sorry for pore English. Thanks!

(Stefan Petrick) #2

FastLED allows it to limit the power consumtion of the leds.

// limit my draw to 5W

Read this for details: https://github.com/FastLED/FastLED/wiki/Power-notes

(варешяф рйезот) #3

@Stefan_Petrick I know about limiting. But I want to know HOW MUCH animation takes power!

(Mike Katchmar) #4

It is an interesting problem for code. But using a multimeter will give real results - you can look at instantaneous current draw or with a nice meter you can look at a max draw. With a modern oscilloscope you could do math and calculate RMS current over a period of time.

(Stefan Petrick) #5

It´s basically simple: Add all the r, g and b values of all NUM_LEDS together and multiply them with ±20mA/255. Relate that to global brigthness and you´re done. Do this every_n_milliseconds and output the result to serial monitor.

(Jason Coon) #6

Here’s the code FastLED uses: https://github.com/FastLED/FastLED/blob/master/power_mgt.cpp#L50

(варешяф рйезот) #7

@Stefan_Petrick this will give too much numbers. In your algorith - there need to be some function like RunningMedian
We need to summ all this numbers and calculate the average.
I can’t do this well, and I want to advice for somebody, who have experience with codding and algorithms to do this well and nice )
May be someone will interested to make it )
I can not make this algorithm and code it. And I do not understand platform limiting and other hard things in microcontroller programming. Sorry.

(варешяф рйезот) #8

@Jason_Coon Great! Please, give example how to use this function. If it is possible, please give two variants: more and less accurate.

(варешяф рйезот) #9

@Mike_Katchmar I have no good multimeter, that able to truthful measure 800Kbs data values )
And I think, for me and for many others like me - it will be OK, if we would have ability to measure power not with absolute precision, but near truth and without additional equipment )

(варешяф рйезот) #10

in comments here there are info about full black current:
WS2812 takes a lot of power when full black, just to power the chip. 48 LEDs took 140mA while 48 WS2813 LEDs, full back also, were only 40mA.

(Leon Yuhanov) #11

@Stefan_Petrick The method you mention is totally inaccurate, the relationship between a value for a colour and its power draw is not liner from all my testing

(варешяф рйезот) #12

@Leon_Yuhanov yes, it is not very accurate, but if we would have average value of leds RGB value - this would show for us how differ average from total.
For example, if total white is NUM_LEDS * 60 mAmps, and average calculated as 120, thats mean, that our sketch takes about 47% of total white. Not 10% and not 80%.
NUM_LEDS = 100. 47% of full white will be 60mA100leds = 6 Amps /10047 = 2.82A.
Thats mean, that if our animation does not have full white, we can use 5A power source and it gives to us some margin of safety. In another case - we need to buy 10A power source to have some margin of safety.
Yes, it is not accurate, but it better, then nothing.
Yes, I want more accurate function, but this algorithm have chances to live too, because we have no any another.

(Leon Yuhanov) #13

@fa25514ad7a4d6321c2d Your assumptions are incorrect. I suggest you grab a multi meter and make some measurements to see why i say this is a useless method.

(Stefan Petrick) #14

@Leon_Yuhanov So far I only cared about the max current draw and never measured with reduced brightness. But all current/brightness graphs I see on the internet look like a linear function which makes totally sense to me. The PWM shifts the on/off cycle linear as well. Because of this a gamma correction helps to adapt the linear brightness (=current) increase to the log perception of the eyes. Do you have any explanation why the current draw should not be a linear function? http://3.bp.blogspot.com/-_n0d3JI8xyo/U88z_FhEYsI/AAAAAAAAAL0/WZoWKiLl9TQ/s1600/ws2812-and-pl9823-supply-current.png

(Stefan Petrick) #15

About weak power supplys and “average” current: Even if the average is low basically the current draw oszillates between max and zero. This is what the PWM does - switching a LED on and off. That means for very short moments one led draws full current. If there are many (clockless) leds in a chain one can only guess if their PWM is in sync or not. Long story short: A weak power supply might work in combination with a big cap. But in the past i ran into serious problems caused by very short peak draws far above average which fried first the supply and then the leds…

(варешяф рйезот) #16

@Stefan_Petrick I’m agree about your cense of “average” current.
If user understand basics of electricity - he need to understand about PWM and others.
First of all I want to know power consumption of animations.
I don’t want to calc Power source wattage with average power of animation directly. This function just help to see approximated value of margin of safety that I would have when use powerful or less current source.
Most of “margin of safety” in USSR was 100% or more )) Thats why in ex-USSR countries peoples lives till now in houses, that was build 40-50 and more years ago and engineers designing them for 20-30 years using.
Also this true for communications, and many others.
For example, Ukraine is not collapsed till now by this “margins of safety”. In Ukraine municipal infrastructure was not updated ~30 years. It was made 30-80- years ago with service life ~20 years. “Under the moon nothing lasts” and if Ukraine not find the mind as soon as possible, any margins of safety doesn’t help.