A small update.
All of the existing controllers currently available (that I am aware of anyway) utilise a direct, or linear, mapping between the required output level and the resultant PWM output to the led driver. For example if you set the required output to zero, then the PWM will be set to zero; if you set the required output to 100%, then the PWM will be set to 256 (there are 256 PWM steps in almost all controllers); if you set the required output to 50% then the PWM will be set to 128.
This all sounds good, but the problem is that there is not a linear relationship between the led current and the lumens (light) ouput. Whilst each led is slightly different , the following graph represents the relationship between current and lumens for a CREE XP-G R5 Cool White led.
As can be seen, this is not a straight line but a polynomial - using some very complicated mathematics you can determine the equation for the line of best fit (or, you can use the Trendline option in Excel which is much easier ;) ). The resultant equation is shown on the graph. Using this equation it can be seen that 1 amp produces 347 lumens but 500mA (ie 50% of 1 amp) produces 193 lumens, or 56% of the maximum i.e. over 10% more light then we should be getting.
So, we need to come up with an equation which can be used to adjust the PWM to reflect this non-linear relationship.
Based on the datasheet for the Meanwell LDD drivers I know that there is a direct relationship between the PWM control and the resultant current. So, the current value was mapped into a PWM value based on a 1 amp being represented by a PWM value of 4,096 (I am using a 12 bit PWM source rather than the standard 8 bit PWM thus the use of 4,096 rather than 256). And, the lumens were mapped into a percentage basis with 0% representing zero output and 100% representing 350 lumens output (the CREE XPG R5 outputs 347.7 lumens, rounded up to 350, at 1 amp).
This may not make much sense, but stay with me just a bit longer...
By then plotting the Percentage Output against the PWM , and using the Trendline option again, we arrive at the following graph:
So, we arrive at an equation of : y = 0.07950x2 + 32.99810x where y = PWM and x = required percentage output. For those mathematically minded, you will notice that the R² value = 1 - this means that the equation is a perfect fit for the line.
Using this equation, the calculated PWM for 100% output is 4,095 i.e. the same we were originally getting. But, the calculated PWM for 50% output is now 1,849 and not 2,047 (which is half of 4,095).
And so, using this equation rather than a direct linear mapping, we know that for every 1% change in the percentage output selected on the controller the actual light produced by the leds will also change by 1% - this will be the same across the full 100% range of the led's.
Note - I acknowledge that this equation will only be accurate when used with an XPG R5 Cool White led driven at 1 amp. But, I am confident that different leds would not be significantly different and so this equation will be used for all leds.
Now, was it really worth the time and effort to calculate this equation rather than use the direct mapping methodology that everyone else uses
Maybe not, but it does conform with my intention to make this the best controller available anywhere :)