Addressable LEDs Are Here - Updating the Fading Rainbow Light Show!

RPDMS Home Page Link LED technology has advanced from the 3mm and 5mm packages first used to produce Fading Rainbow devices (November 2011) to tenths of mm, miniaturized packages available in strips containing hundreds of LEDs. These strips, though useful to the Fading Rainbow Program for bigger and brighter displays, were still limited to reproducing a single RGB combination. The next step was major, smart-pixels so to speak!

Embedding an 8-bit PWM serial communication driver in each miniaturized LED enabled a single wire to carry different data blocks (24-bit RGB or 32-bit RGBW) to each pixel that in turn would display its color until updated by the strip controller or power is removed. A microcontroller or any programmable device capable of producing the critically timed data string is required. Lacking clock synchronization, proper color encoding/decoding depends upon very precise timing of the bit stream. Arduino-like boards with free detailed support from both the makers and sellers of smart pixels is probably the most common choice for this task.

Whereas the original Fading Rainbow consisted of seeing the individual colors in succession, we can now see the individual steps allowing us better understanding of visual comparison. Of course, there are limitations since the Fading Rainbow involves hundreds of thousands of RGB combinations. Right now you may be wondering, "Doesn't 8-bit RGB make 16,777,216 colors?"

Go here to see what happens to millions of missing colors.

Non-linearity of human brightness perception arose early in Fading Rainbow project. PWM values betwen 0 and 255 (8-bit Color) resulted in bigger visual changes for dark colors than for light. Really makes sense, 1 to 2 represents doubling the value but 254 to 255 is mere 0.4 percent! That first transition is a real killer for 8-bit PWM for LED's! Precisely why Fading Rainbow is 14-bit with 16383 steps between off and fully on. Instead of the first step of 0.4% we have 0.006% if needed. There is more.

What magnitude for a first step, the next, then...? What size and how many steps will produce a gradual, unnoticeable transition beween colors? Clues lie in colorimetry history beginning in 20's and 30's of the last Century. Researchers developing the 1931 CIE XYZ color space substituted the human photopic (cone derived) CIE luminosity function for the Y stimulus. 1931 CIE space was warped and nonuniform but served the original purpose, capability for a 3-parameter color specification, XYZ or more commonly xyY. More about 1931 CIE XYZ if you wish.

For 45 years colorimetry scientists sought a more uniform color space distribution where numerical differences and visual perception were in agreement. 1976 CIELab lightness L*, was accepted as being quite uniform. Below the color patches are the L* derivation equations from Y. Note there are two different equations. Why? Human rod vision luminosity function is different from the cone function Y stimulus of 1931 XYZ space. Low light and/or dark colors can involve both rod and cone vision. Yn is the normalized maximum, 100 for Lab space, 255 for 8-bit color and 16383 if 14-bit. The equivalent reverse transformation L* of 8 is represented by the patches sandwiched between 100 white and 0 black. Quite dark by comparison. Remember, true L* is based upon Yn of 100 making 8-bit equivalent ~20.

76CIELAB

76CIELAB

After some algebraic manipulation we get:

PWM = integer(MaxDuty * (((100*StepNumber/MaximumSteps)+16)/116)3+0.5)

and for 8-bit PWM strips:

PWM = integer(255 * (((100*PixelCount/LastPixel)+16)/116)3+0.5)

Use this equation in a spread sheet to build visually weighted tables for any pixel range(PixelCount to LastPixel). It was used in the initial 8-bit Fading Rainbow Light Show in 2011 as well as more recent developments of 14-bit color tables. It's visually accurate but originally thought to be unnecessary when using Adafruit's NeoPixel Library!

Color Sequenced Paths Around sRGB Color Solid Bottom View Color Sequenced Paths Around sRGB Color Solid Bottom View

sRGB Color Solid Top View Color Sequenced Paths Around sRGB Color Solid Top View

The above graphics illustrate the "nearest neighbor sequencing" of Fading Rainbow. At left are the bottom and top views of RGB color space with the hexagonal Rainbow traces shown on the right. The Rainbow begins with a single black color (0,0,0) and traverses RGB space to arrive at white (255,255,255). Only a few traces are shown for illustration. Several hundred thousand colors are presented by the Fading Rainbow and change smoothly except when approaching or leaving the near white or near black areas with limited RGB choices. Instead of presenting a succesion of individual colors, strips should be capable of displaying a constant fade from end to end of the 6 sides of RGB space. Blu-Mag, Mag-Red, Red-Ylo, Ylo-Grn, Grn-Cyn, and Cyn-Blue.

Click here to see how "nearest neighbor" can affect our perception.

Even though 8-bit PWM is woefully lacking precision for any serious color work, I was intrigued. Internet research revealed massive hobby involvement, but more importantly, free vendor support of addressible LED strips programmed using C++ running on Arduino boards. Adafruit's Uberguide discussion of human brightness non-linearity and gamma correction convinced me to start using their NeoPixel Library.

Vout = Vingamma, the general equation, even at gamma of 3 is not adequate for visual linearization. To see for myself, I ordered a 1-meter, 60 LED strip, downloaded the library to my Arduino IDE and started examining the library routines to be prepared when my strip arrived.

Apprehensions confirmed. The first fades looked terrible! The brightness of the first colors rose too fast and quickly reached a point with no apparent change or at least very little. More like uncorrected behavior. Examination of Adafruit_NeoPixel.cpp revealed the following function along with a full 8-bit PWM table that appeared to be installed into memory: int(math.pow((x)/255.0,gamma)*255.0+0.5) with gamma = 2.6. A 60 step gamma correction table was created and graphed along with my L* values and uncorrected PWM's for comparison. Following is that graph confirming my bad fades were most likely produced using uncorrected data. Repeating fade tests with 1976 CIE L* correction fixed them very well. Additional tests using the 2.6 gamma table was not as visually uniform, particularly when fading between two colors. The location of the mid-strip transition region should be just that, mid-strip.

Gamma Brightness Correction Graph

Further searching revealed a recently updated (2018-08-22) document entitled: LED Tricks: Gamma Correction still using the same function resulting in poorly corrected PWM's in the critical, most sensitive area below 20! Despite the following quote from LED Tricks: "It’s extraordinarily sensitive at the low end…we perceive changes there as more pronounced than objective measurement (or LED duty cycle numbers) would suggest".

Gamma Brightness Correction Graph

The stair stepping, an inherent problem of 8-bit color, will be minimzed by increasing bit depth as shown in the next graph.

Higher Resolution PWM

12-bit color depth virtually eliminates stair stepping but no practical resolution totally eliminates a larger first step. My 16-bit Fading Rainbow Show worked better but was more difficult to execute with 8-bit micrcontrollers. The Microchip PIC controller now used is 8-bit processor, 14-bit core with 3 independent 16-bit PWM channels. The 14-bit color tables, separate R, G, and B are easily stored in program memory.

Rod & Cone Sensitivity

The photopic curve is combination sensitivity of red, green, and blue cones. Scotopic curve is rod vision, sensitive only to light-dark levels. This scotopic vision was ignored by the 1931 CIE XYZ System. Unfortunately, rods are prime contributors to low-level brightness perception and must be considered when doing gamma correction. This oversight was repaired when standardizing 1976 CIE Lab color space ordering sytem. It's still not perfect but L* works quite well.

Until LED strips are available with built-in 12-bit PWM controllers, the current ones represent a significant forward step in lighting development.

You might be interested in more color science in other presentations. Just click on the house at the top and enjoy

Thanks for your attention and please, visit our dedicated Fading Rainbow Color Show Web site

E-mail inquiries, questions or suggestions. Please don't change the subject or your message may get junked. Thank you and goodbye for now.