Pages: [1]   Go Down
Author Topic: Brightness/Luminance Map  (Read 502 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 1
Posts: 38
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I believe I've seen these around the forum, but here's a PWM to brightness map for LEDs I came up with:

static byte lightPowerMap[256] = {
   0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,
   2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,
   4,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6,
   7,7,7,7,8,8,8,8,9,9,9,10,10,10,10,11,
   11,11,12,12,12,13,13,13,14,14,15,15,15,16,16,17,
   17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,
   25,25,26,26,27,28,28,29,29,30,31,31,32,32,33,34,
   34,35,36,37,37,38,39,39,40,41,42,43,43,44,45,46,
   47,47,48,49,50,51,52,53,54,54,55,56,57,58,59,60,
   61,62,63,64,65,66,67,68,70,71,72,73,74,75,76,77,
   79,80,81,82,83,85,86,87,88,90,91,92,94,95,96,98,
   99,100,102,103,105,106,108,109,110,112,113,115,116,118,120,121,
   123,124,126,128,129,131,132,134,136,138,139,141,143,145,146,148,
   150,152,154,155,157,159,161,163,165,167,169,171,173,175,177,179,
   181,183,185,187,189,191,193,196,198,200,202,204,207,209,211,214,
   216,218,220,223,225,228,230,232,235,237,240,242,245,247,250,252
};

The point of this map is that human perception of brightness follows a roughly logarithmic response curve, except at very low levels. Actually, the CIE 1931 formula I came across relates the two as follows:

Brightness = 116 * Luminance ^ (1/3) - 16         for luminance levels above 0.008856 (0 to 1 scale)
Brightness = 903.3 * Luminance                        for luminance levels at or below 0.008856

If you solve for brightness you get:

Luminance = ((Brightness + 16) / 116) ^ 3         for brightness levels above 7.9996 (0 to 100 scale; I suspect they mean 8 smiley)

Luminance = Brightness / 903.3                       for brightness levels at or below 7.9996 (smiley-cool

If you want 50% brightness (8 bit value of 128) you'd use a pulse width modulation value of 47 (47.3874, rounded), lightPowerMap[128].

This doesn't adjust for different perceptions of brightness of different colors, so basically it's most applicable to a white LED. On my aquarium light controller, which has banks of red, white and blue LEDs, it seems to work tolerably well. There are a few "jumps" apparent when you ramp brightness from 0 to 255, but they're relatively minor.

Your mileage (and perception smiley) may vary, of course.
Logged

Pages: [1]   Go Up
Jump to: